【ROS教程】编写launch文件

@TOC


1.launch文件有哪些标签

2.node标签

2.1 必选属性

2.2 可选属性

2.3 可选子级标签

  1. <env>

  2. <remap>

  3. <rosparam>

  4. <param>

3.include标签

3.1 必选属性

3.2 可选属性

3.3 可选子级标签

  1. <env>

  2. <arg>

4.remap标签

4.1 必选属性

5.param标签

  • 作为\<node>子级标签时,相当于私有命名空间。

5.1 必选属性

5.2 可选属性

roslaunch 确定参数类型的规则如下:

  • 如果包含 '.' 的数字解析未浮点型,否则为整型

  • "true" 和 "false" 是 bool 值(不区分大小写)

  • 其他是字符串

6.rosparam标签

6.1 必选属性

6.2 可选属性

7.group标签

7.1 可选属性

7.2 可选子级标签

  • 其他所有标签都是其子级标签

8.arg标签

8.1 必选属性

8.2 可选属性

8.3 示例

<launch>
  <!-- declare arg to be passed in -->
  <arg name="hoge" /> 

  <!-- read value of arg -->
  <param name="param" value="$(arg hoge)"/>
</launch>

9.env标签

9.1 必选属性

10.全局示例

<launch>
  <!-- local machine already has a definition by default.
       This tag overrides the default definition with
       specific ROS_ROOT and ROS_PACKAGE_PATH values -->
  <machine name="local_alt" address="localhost" default="true" ros-root="/u/user/ros/ros/" ros-package-path="/u/user/ros/ros-pkg" />
  <!-- a basic listener node -->
  <node name="listener-1" pkg="rospy_tutorials" type="listener" />
  <!-- pass args to the listener node -->
  <node name="listener-2" pkg="rospy_tutorials" type="listener" args="-foo arg2" />
  <!-- a respawn-able listener node -->
  <node name="listener-3" pkg="rospy_tutorials" type="listener" respawn="true" />
  <!-- start listener node in the 'wg1' namespace -->
  <node ns="wg1" name="listener-wg1" pkg="rospy_tutorials" type="listener" respawn="true" />
  <!-- start a group of nodes in the 'wg2' namespace -->
  <group ns="wg2">
    <!-- remap applies to all future statements in this scope. -->
    <remap from="chatter" to="hello"/>
    <node pkg="rospy_tutorials" type="listener" name="listener" args="--test" respawn="true" />
    <node pkg="rospy_tutorials" type="talker" name="talker">
      <!-- set a private parameter for the node -->
      <param name="talker_1_param" value="a value" />
      <!-- nodes can have their own remap args -->
      <remap from="chatter" to="hello-1"/>
      <!-- you can set environment variables for a node -->
      <env name="ENV_EXAMPLE" value="some value" />
    </node>
  </group>
</launch>

Last updated