天天看点

ROS launch文件设置ROS 文件设置launch文件

ROS 文件设置

launch files

  • ROS 文件设置
    • launch
  • launch文件

launch

launch文件

<launch>
  <!-- turtlebot_teleop_key already has its own built in velocity smoother -->
  <node pkg="turtlebot_teleop" type="turtlebot_teleop_key.py" name="turtlebot_teleop_keyboard"  output="screen">
    <param name="scale_linear" value="0.5" type="double"/>
    <param name="scale_angular" value="1.5" type="double"/>
    <remap from="turtlebot_teleop_keyboard/cmd_vel" to="/cmd_vel"/>   <!-- cmd_vel_mux/input/teleop"/-->
  </node>
</launch>
           

All launch files are contained within a tag. Inside that tag, you can see a tag, where we specify the following parameters:

  1. pkg=“package_name” # Name of the package that contains the code of the ROS program to execute
  2. type=“python_file_name.py” # Name of the program file that we want to execute
  3. name=“node_name” # Name of the ROS node that will launch our Python file
  4. output=“type_of_output” # Through which channel you will print the output of the Python file
  • output

    将标准输出显示在屏幕上而不是记录在日志中,

    output="screen"

  • respawn

    请求复位,当该属性的值为

    respawn="true"

    时,roslaunch会在该节点崩溃时重新启动该节点
  • required

    必要节点,当该值为

    required="true"

    时,roslaunch会在该节点终止时终止其他活跃节点。
  • 启动前缀

    在启动命令加上前缀。例如当其设置为

    launch-prefix="xterm -e"

    时,效果类似于

    xterm -e rosrun X X

    。也就是为该节点保留独立的终端。
  • ns

    在命名空间中启动节点。

  • 重映射

    使用方法

    remap from="original-name(turtle/pose)"to"new-name(tim)"

  • 包含其他文件

    include file="path to launch file"

    在启动文件中包含其他启动文件的内容(包括所有的节点和参数),可使用如下命令使路径更为简单

    include file="($find package-name)/launch-file-name"

  • 启动参数(launch arguments)

    为了使启动文件便于配置,roslaunch还支持启动参数,有时也简称为参数甚至args,其功能有点像可执行程序中的局部变量。

    声明参数:

    arg name="arg-name"

    然而这样的声明并不是必须的(除非你想要给它赋值或设置为默认值,见后续内容),但是这是一个好的做法,因为这样能使读者比较清楚启动文件需要哪些参数

    参数赋值:

    roslaunch package-name launch-file-name arg-name:=arg-value

    <arg name=”arg-name” default=”arg-value”/>

    <arg name=”arg-name” value=”arg-value”/>

    获取参数:一旦参数值被声明并且被赋值,你就可以利用下面的arg 替换(arg substitution)语法来使用该参数值了:$(arg arg-name)每个该替换出现的地方,roslaunch 都将它替换成参数值。在示例中,我们在 group 元素中的 if 属性使用了一次 use_sim3 参数。