build details

Show: section status errors & todos local changes recent changes last change in-page changes feedback controls

Minimal ROS node - pkg_name

Modified 2018-10-29 by Russell Buchanan

Andrea Censi

previous task next (11 of 12) index
for:Russell Buchanantask

The following was marked as "special-par-assigned".

Andrea Censi

File book/software_devel/35_ros/45-ROS-pkg_name.md.

File book/software_devel/35_ros/45-ROS-pkg_name.md
in repo duckietown/docs-software_devel branch master commit 7dc8051b
last modified by Russell Buchanan on 2018-10-29 12:49:07

Created by function create_notes_from_elements in module mcdp_docs.task_markers.

This document outline the process of writing a ROS package and nodes in Python.

To follow along, it is recommend that you duplicate the pkg_name folder and edit the content of the files to make your own package.

Launch File

Modified 2018-06-22 by Andrea Censi

You should always write a launch file to launch a node. It also serves as a documentation on the I/O of the node.

Let’s take a look at launch/test.launch.

    <node name="talker" pkg="pkg_name" type="talker.py" output="screen">

        <param name="~pub_timestep" value="0.5"/>

        <remap from="~topic_b" to="~topic_a"/>

For the <node>, the name specify the name of the node, which overwrites rospy.init_node() in the __main__ of talker.py. The pkg and type specify the package and the script of the node, in this case it’s talker.py.

Don’t forget the .py in the end (and remember to make the file executable through chmod).

The output="screen" direct all the rospy.loginfo to the screen, without this you won’t see any printouts (useful when you want to suppress a node that’s too talkative.)

The <param> can be used to set the parameters. Here we set the ~pub_timestep to 0.5. Note that in this case this sets the value of talker/pub_timestep to 0.5.

The <remap> is used to remap the topic names. In this case we are replacing ~topic_b with ~topic_a so that the subscriber of the node actually listens to its own publisher. Replace the line with

<remap from="~topic_b" to="talker/topic_a"/>

will have the same effect. This is redundant in this case but very useful when you want to subscribe to a topic published by another node.

No questions found. You can ask a question on the website.