ROS COMMAND LINE

The list below provides the essential commands for performing tasks within the ROS framework, but it is by no means exhaustive.

The ROS Tutorials are a great place to start for understanding these commands in more details, some highlights are:

Compiling

  • catkin_make compiles the ROS package when called from the ROS workspace folder of the repository, i.e., from the folder named catkin_ws

  • catkin_make_isolated compiles each ROS package separately as per its CMakeList, and then sources the resulting environment.

  • See the catkin_make documentation and catkin packages tutorial for more usages and descriptions.

Sourcing a ROS package

  • source /opt/ros/<ros-distro>/setup.bash sources the setup.bash script for the ROS distribution specified by <ros-distro>.

  • source /opt/ros/melodic/setup.bash sources the setup.bash script for the ROS melodic distribution.

  • source <path_to_catkin_ws>/devel/setup.bash sources the setup.bash script that was automatically created when the catkin_make command was successfully run

  • source ~/asclinic-system/catkin_ws/devel/setup.bash sources the setup.bash script for when this repository was cloned to the default location for the logged in user, i.e., to ~/asclinic-system/

  • echo $ROS_PACKAGE_PATH to display which paths are sources in the current terminal session.

Launching nodes

  • roscore launches the ROS Master and the rosout node

  • rosrun [package_name] [node_name] launches the node named [node_name] from the package named [package_name]

  • rosrun asclinic_pkg template_cpp launches the node named template_cpp from the package named asclinic_pkg

    • Note the rosrun command requires that the ROS Master and the rosout nodes are already running, i.e., by running roscore first.

  • roslaunch [package] [filename.launch] starts nodes as defined in the launch file named [filename.launch] that is located in the launch/ folder of [package]

    • Note the roslaunch command actually searches for launch files anywhere within the package, but keeping them in folder named launch/ is good practice

    • Note the roslaunch command can be used whether or not the ROS Master and the rosout are already running. If not already running, then roslaunch will also launch the ROS Master and rosout nodes.

  • roslaunch asclinic_pkg template.launch starts nodes as defined in the file template.launch that is located in the launch/ folder of the asclinic_pkg package

  • roslaunch asclinic_pkg template.launch alsopython:=true as above but with the argument alsopython set to true, which is then then used inside the launch file to also launch the template python node

Displaying information about nodes

  • rosnode displays the manual entry for the rosnode command that is used to display information about ROS nodes that are currently running

  • rosnode list -h displays the manual entry for the list command of rosnode

  • rosnode list displays a list of the currently running nodes, also known as the active nodes

  • rosnode info [node_name] displays information about the node named [node_name], including any publishers, subscribers, and services of that nodes

  • rosnode info template_cpp displays information about the node named template_cpp if it is currently running

Displaying information about topics

  • rostopic displays the manual entry for the rostopic command that is used to display information about current ROS topics

  • rostopic list -h displays the manual entry for the list command of rostopic

  • rostopic list displays a list of all topics currently subscribed to and published

  • rostopic list -v displays a verbose list of topics subscribed to and published, including their message type and number of subscribers and publishers

  • rostopic info [topic] displays a information about [topic], including its message type, and the name of node subscribing and publishing to the topic

  • rostopic info /asclinic/template_topic displays a information about the topic /asclinic/template_topic

  • rostopic echo [topic] displays the data published on [topic]

  • rostopic hz [topic] displays the publishing rate of [topic]

Miscellaneous

  • Ctrl-C stop the currently active command, for example, to stop a roslaunch command and hence kill the nodes launched by that terminal.



Creative Commons License
Paul N. Beuchat, 2023