Testing Publisher and Subscriber nodes
$ cd catkin_ws $ catkin_make $ source devel/setup.bash
$ roscore $ rosrun beginner_tutorials talker.py $ rosrun beginner_tutorials listener.py
Rospy Service & Client
Step1: Define the service message(srv file) Step2: Create a ROS server node Step3: Create a ROS client node Step4: Execute the service Step5: Consume the service by the client
Create srv folder inside beginner_tutorials. Make a service file AddTwoInts.srv inside srv folder.
int64 a
int64 b
---
int64 sum
Make changes in package.xml by adding these 2 lines, These lines will generate request and response It is responsible for reading service file and converting it to source code.
message_generation
message_runtime
Make changes in CMakelist.txt
Inside find_package Add the following line:
message_generation
Add Service file
add_service_files( FILES AddTwoInts.srv )
After making changes in package.xml and CMakelist.txt, Build your package
catkin_make source devel/setup.bash
Make a file add_two_ints_server.py inside scripts folder
make the script executable by chmod +x add_two_ints_server.py
Last updated
Was this helpful?