Difference between revisions of "Writing a Simple Publisher and Subscriber (C++)"
(Created page with "==Writing a Simple Publisher and Subscriber (C++)== '''Writing the Publisher Node''' 1) In a terminal, move to your beginner_tutorials folder: <nowiki>cd ~/catkin_ws/src/b...") |
(No difference)
|
Revision as of 18:35, 17 October 2014
Writing a Simple Publisher and Subscriber (C++)
Writing the Publisher Node
1) In a terminal, move to your beginner_tutorials folder:
cd ~/catkin_ws/src/beginner_tutorials
2) Create the file talker.cpp:
gedit src/talker.cpp
3) In the gedit editor, paste all from this link. Save the file and close the editor. For information on what is inside this file, see this link. In a nutshell, it initializes the ROS system, advertise what we are doing, and finally loop what we are doing.
Writing the Subscriber Node
1) In a terminal, move to your beginner_tutorials folder:
cd ~/catkin_ws/src/beginner_tutorials
2) Create the file listener.cpp:
gedit src/listener.cpp
3) In the gedit editor, paste all from this link. Save the file and close the editor. For information on what is inside this file, see this link. In a nutshell, it initializes the ROS system, subscribes to the topic 'chatter', spin (wait for messages), when message arrives call the chatterCallback() function.
Building Nodes