Skip to content
ManalFallatah edited this page Jul 31, 2020 · 3 revisions

Publisher Subscriber Nodes ROSLaunch wiki!

How to run a publisher(talker) and subscriber(listener) nodes will be addressed in this page using ROS-NOETIC and PYTHON3

First it will be assumed that you already have ROS-NOETIC and PYTHON3 installed in your Ubuntu 20.

Basically, the nodes will be placed and launched from a package inside the catkin workspace.

At the very beginning we will learn how to do a ros catkin workspace, by the following lines in the terminal:

$ mkdir -p ~/<Workspace_folder_name>/src

Then move inside the workspace to create the package:

$ cd <Workspace_folder_name>

$ cd src

Initialize the workspace:

$ catkin_init_workspace

In the src folder create the package:

$ catkin_create_pkg <Package_name> std_msgd raspy roscpp

Which indicates the package name, the package dependencies and the file types (Python or C++) files.

Move into the package to make a script folder to place all the codes/files.

$ cd <Package_name>

$ mkdir scripts

$ cd scripts

Now to create our talker and listener nodes files.

$ touch listener.py

$ touch talker.py

You can check the files in the scripts folder or by typing ls. Open the files from files manager and write the codes.

Now make your codes executable and make sure it works

$ chmod +x listener.py

$ chmod +x talker.py

Now to setup all the work, go to the workspace folder

$ catkin_make

This command line need to be excutade eveytime you make changes in the CMakelist_file

$ roscore

Then in new Terminal:

$ source devel/setup.bash

$ rosrun <package_name> talker.py

Also with the listener.py file to make sure it is working

To check and see what catkin node and topics are working, type:

$ rosnodes list

$ rostopics list

For a graphical digram

$ rqt_graph

Clone this wiki locally