DEV Community

Cover image for tutorial of ROSLaunch file usage
Tianyi Xiang
Tianyi Xiang

Posted on

tutorial of ROSLaunch file usage

Writing ROSlaunch file is inevitable always.I am here to briefly desrible some important elements in ROS launch file.

I post an example of moveit roslaunch file here:

<launch>

  <!-- This file makes it easy to include the settings for sensor managers -->  

  <!-- Params for the octomap monitor -->
  <!--  <param name="octomap_frame" type="string" value="some frame in which the robot moves" /> -->
  <param name="octomap_resolution" type="double" value="0.025" />
  <param name="max_range" type="double" value="5.0" />

  <!-- Load the robot specific sensor manager; this sets the moveit_sensor_manager ROS parameter -->
  <arg name="moveit_sensor_manager" default="ur5e" />
  <include file="$(find ur5e_moveit_config)/launch/$(arg moveit_sensor_manager)_moveit_sensor_manager.launch.xml" />
  <rosparam command="load" file="$(find panda_moveit_config)/config/sensors_kinect_pointcloud.yaml" />
</launch>
Enter fullscreen mode Exit fullscreen mode
<launch>
  <node name="my_robot_node" pkg="my_robot_package" type="my_node" output="screen" />
</launch>

Enter fullscreen mode Exit fullscreen mode

1.<launch> is the root element. define whole launch file

  1. <param> used to publish simple parameters to ROS parameter server, like here we publish the value of "octomap_resolution" with type="double" value="0.025" to the ROS parameter server. Then the main programs can automatically subsrible the octomap_resolution value after starting.

  2. <rosparam>this can be also seen as publishing parameters to the ROS parameter server. But it publish parameters inside yaml file, this enable writing complex and bunch of parameters inside yaml file. like sensors_kinect_pointcloud.yaml

  3. <arg> is to define a argument which can be used to share at current ROS launch file.

  4. <node> is to embed and rosrun a ROS .py file or .cpp file that contains a node. . where the name="node_name" is the node name that can define randomly. pkg="package_name" is the package name, tips for finding ros package is rospack list. is the cpp or .py file's name.

  5. <include> is used to include other .launch file in the current .launch file.

Top comments (0)