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 namedcatkin_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 thesetup.bash
script for the ROS distribution specified by<ros-distro>
.source /opt/ros/melodic/setup.bash
sources thesetup.bash
script for the ROS melodic distribution.source <path_to_catkin_ws>/devel/setup.bash
sources thesetup.bash
script that was automatically created when thecatkin_make
command was successfully runsource ~/asclinic-system/catkin_ws/devel/setup.bash
sources thesetup.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 theROS Master
and therosout
noderosrun [package_name] [node_name]
launches the node named[node_name]
from the package named[package_name]
rosrun asclinic_pkg template_cpp
launches the node namedtemplate_cpp
from the package namedasclinic_pkg
Note the
rosrun
command requires that theROS Master
and therosout
nodes are already running, i.e., by runningroscore
first.
roslaunch [package] [filename.launch]
starts nodes as defined in the launch file named[filename.launch]
that is located in thelaunch/
folder of[package]
Note the
roslaunch
command actually searches for launch files anywhere within the package, but keeping them in folder namedlaunch/
is good practiceNote the
roslaunch
command can be used whether or not theROS Master
and therosout
are already running. If not already running, thenroslaunch
will also launch theROS Master
androsout
nodes.
roslaunch asclinic_pkg template.launch
starts nodes as defined in the filetemplate.launch
that is located in thelaunch/
folder of theasclinic_pkg
packageroslaunch asclinic_pkg template.launch alsopython:=true
as above but with the argumentalsopython
set totrue
, 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 therosnode
command that is used to display information about ROS nodes that are currently runningrosnode list -h
displays the manual entry for thelist
command ofrosnode
rosnode list
displays a list of the currently running nodes, also known as the active nodesrosnode info [node_name]
displays information about the node named[node_name]
, including any publishers, subscribers, and services of that nodesrosnode info template_cpp
displays information about the node namedtemplate_cpp
if it is currently running
Displaying information about topics
rostopic
displays the manual entry for therostopic
command that is used to display information about current ROS topicsrostopic list -h
displays the manual entry for thelist
command ofrostopic
rostopic list
displays a list of all topics currently subscribed to and publishedrostopic list -v
displays a verbose list of topics subscribed to and published, including their message type and number of subscribers and publishersrostopic info [topic]
displays a information about[topic]
, including its message type, and the name of node subscribing and publishing to the topicrostopic 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 aroslaunch
command and hence kill the nodes launched by that terminal.