配置案例

Node节点

常规配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" encoding="utf-8" ?>
<launch>
    <!--
     pkg: package名称
     type: 可执行程序名称
     name: 节点名称
     -->
    <node pkg="turtlesim"
          type="turtlesim_node"
          name="turtlesim1"
          respawn="true"
          respawn_delay="2"
          output="screen"
          ns="hi"
    ></node>

    <!--
        respawn: 是否重启. 默认false
        respawn_delay:重启延时
    -->

    <!--
        output: 日志输出到什么位置。 screen | log. 默认为log
    -->

    <!--
        ns: 命名空间
    -->
</launch>

启动参数配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="utf-8" ?>
<launch>

    <!--
    args="arg1 arg2 arg3"
     -->
    <node pkg="config_pkg"
          type="my_args"
          name="my_args"
          respawn="true"
          respawn_delay="2"
          output="screen"
          ns="hi"
          args="arg1 arg2 arg3"
    ></node>

</launch>

topic映射配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="utf-8" ?>
<launch>
    <node pkg="turtlesim"
          type="turtlesim_node"
          name="turtlesim1"
          respawn="true"
          respawn_delay="2"
          output="screen"
          ns="hi">
        <!--

        remap: from to
          将subscriber的topic路径进行修改
          将publisher的topic路径进行修改
        -->
        <remap from="/hi/turtle1/cmd_vel" to="/vel"></remap>
        <remap from="/hi/turtle1/pose" to="/pose"></remap>

    </node>

</launch>

内置param配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="utf-8" ?>
<launch>
    <node pkg="config_pkg"
          type="my_args"
          name="my_args"
          respawn="true"
          respawn_delay="2"
          output="screen"
          ns="hi"
          args="arg1 arg2 arg3">

        <!--
            param:
            type: str|int|double|bool|yaml
            http://wiki.ros.org/roslaunch/XML/param
        -->

        <param name="key1" type="str" value="hello"></param>
        <param name="key2" type="int" value="1"></param>
        <param name="key3" type="double" value="3.14"></param>
        <param name="key4" type="bool" value="true"></param>

    </node>
</launch>

外置Param

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="utf-8" ?>
<launch>

    <param name="key1" type="str" value="hello"></param>
    <param name="key2" type="int" value="1"></param>
    <param name="key3" type="double" value="3.14"></param>
    <param name="key4" type="bool" value="true"></param>

    <node pkg="config_pkg"
          type="my_args"
          name="my_args"
          respawn="true"
          respawn_delay="2"
          output="screen"
          ns="hi"
          args="arg1 arg2 arg3">

        <!--
            param:
            type: str|int|double|bool|yaml
            http://wiki.ros.org/roslaunch/XML/param
        -->

    </node>
</launch>

外置arg配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="utf-8" ?>
<launch>

    <!--
     name: required
     default: optional
     value: optional
     doc: optional
     -->

    <arg name="hi"></arg>

    <param name="key1" type="str" value="$(arg hi)"></param>

    <node pkg="config_pkg"
          type="my_args"
          name="my_args"
          respawn="true"
          respawn_delay="2"
          output="screen"
          ns="hi"
          args="arg1 arg2 arg3">

        <!--
            param:
            type: str|int|double|bool|yaml
            http://wiki.ros.org/roslaunch/XML/param
        -->
    </node>
</launch>