node标签
在标签指定一个ROS 节点,这是最常见的roslaunch标签,因为它支持最重要的功能:启动和关闭节点。
roslaunch不保证节点开始的顺序。因为没有办法从外部知道节点何时被完全初始化,所以所有被启动的节点必须是稳健的,以便以任何顺序启动。
node节点中,今天用到的比较多的有 pkg type name args output value
pkg =“mypackage” 节点包。
type =“nodetype” 节点类型。必须有一个具有相同名称的相应可执行文件。
name =“nodename”节点基名称。注意:name不能包含命名空间。请改用ns属性。
args =“arg1 arg2 arg3” (可选)传递参数到节点。
output 一般为screen或者log,默认为log(日志文件)
value 给定值
讲一下为什么要在launch文件中添加以下部分:
<node pkg="tf" type="static_transform_publisher" name="link1" args="0 0 0 0 0 0 laser laser_link 100" />
<node pkg="tf" type="static_transform_publisher" name="link2" args="0 0 0 0 0 0 base_link laser 100" />
<node pkg="laser_scan_matcher" type="laser_scan_matcher_node"
name="laser_scan_matcher_node" output="screen">
<param name="fixed_frame" value = "odom"/>
<param name="max_iterations" value="10"/>
</node>
为什么需要laser——laser_link、base_link——laser这两个tf
首先是laser到base_link的tf,这是因为laser_scan_matcher需要这样一个tf(roswiki中laser_scan_matcher部分4.2.1)
另外在本launch文件中,前面有两个node将数据发布在laser_link中,需要将这些数据转换到laser,才能和其他的node联系起来。(每个坐标系不是一座孤岛,相互之间是有联系的,数据才能够通用起来)
(当然在launch文件中也可以省掉laser——laser_link这一步的tf,这需要在文件中修改前面两个node中的frame_id以及child_frame_id的设定值为laser。)
在laser_scan_matcher_node中,将fixed_frame的值设定为odom,是因为gmapping需要一个odom(里程计信息),原本的默认值是world
两个tf
tf的写法是有格式的,这个在roswiki中就找得到:
<launch>
<node pkg="tf" type="static_transform_publisher" name="link1_broadcaster" args="1 0 0 0 0 0 1 link1_parent link1 100" />
</launch>
static_transform_publisher工具用于发布两个参考系之间的静态坐标变换,两个参考系一般不发生相对位置变化
name是自己取的,给这个node取一个名字
args 有两种格式,一种是位移+旋转角,一种是四元数表达:
static_transform_publisher x y z yaw pitch roll frame_id child_frame_id period_in_ms
static_transform_publisher x y z qx qy qz qw frame_id child_frame_id period_in_ms
frame_id和 child_frame_id就对应参与变换的两个坐标系
period_in_ms是发布频率,一般默认值为100ms