Understanding the roslaunch command

Let's go one step back and use a minimal launch file to understand the syntax of these kinds of scripts:

$ roslaunch rviz_basics gopigoMinimal_rviz_simple.launch

As we saw with rosrun, the structure of the ROS command is very similar:

  • First is the command name itself, roslaunch.
  • Second is the package name, rviz_basics.
  • The third is the script we will execute, gopigoMinimal_rviz_simple.launch.

The content of the gopigoMinimal_rviz_simple.launch file looks like this:

<launch>
<!-- set these parameters on Parameter Server -->
<param name="robot_description" textfile="$(find rviz_basics)/urdf/gopigoMinimal.urdf" />

<!-- Start 3 nodes: joint_state_publisher, robot_state_publisher and rviz -->

<!-- Send joint values -->
<node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher"/>

<!-- Combine joint values to TF-->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

<node name="rviz" pkg="rviz" type="rviz" args="-d $(find rviz_basics)/rviz/gopigoMinimal.rviz" required="true" />
</launch>

The syntax, in XML format, should be familiar to you. In this file, there are three types of tags:

  • <launch> </launch>: Delimits the block of lines that are part of the roslaunch description.
  • <node />: This is the sentence that's used to execute a ROS node. It is equivalent to the rosrun command that we explained in the previous chapter. Due to this, the equivalent command to a <node /> tagged line is as follows:
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

is equivalent to...

$ rosrun robot_joint_state_publisher state_publisher

You can easily infer that the pkg attribute of the <node> tag is the package name and that the attribute type refers to the script that contains the code of this node.

  • <param /> stands for parameter and is a new ROS concept. It contains a value that is stored in the ROS parameter server that you can visualize as the place where the robot's characterization is stored. A whole set of parameters defines a specific robot configuration. The ROS parameter server, as explained in the ROS official documentation (http://wiki.ros.org/Parameter%20Server), is as follows:
"It is a shared, multi-variate dictionary that is accessible via network APIs. Nodes use this server to store and retrieve parameters at runtime. As it is not designed for high performance, it is best used for static, non-binary data such as configuration parameters."

In our particular case, we have the following declaration in the launch file:

 <param name="robot_description" textfile="$(find rviz_basics)/urdf/gopigoMinimal.urdf" />

The robot_description parameter is the path where the URDF file is stored. You will see that such a path contains an environment variable in the $(find rviz_basics) textfile attribute. This is a very nice feature that ROS provides out of the box so that you don't have to provide absolute or relative paths. The find command is applied to the rviz_basics package and returns the absolute path of the package, that is, ~/catkin_ws/src/book/Chapter4_RViz_basics. The $ sign means the value of, in the same way as you would do for system environment variables.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset