Writing a Simple Publisher and Subscriber (Python)

From Lofaro Lab Wiki
Jump to: navigation, search

It is strongly recommended that the steps in Writing a Simple Publisher and Subscriber (C++) are followed before continuing

1) In a terminal, move to your beginner_tutorials folder and source your setup file:

  cd ~/catkin_ws/src/beginner_tutorials
./devel/setup.bash 

2) Create the directory scripts:

mkdir scripts
cd scripts

Writing the Publisher Node

1) Create the file talker.py:

  gedit talker.py

2) 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.

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.py:

  gedit listener.py

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.

Building Nodes

1) Go to your catkin workspace and make the package:

cd ~/catkin_ws
catkin_make