困扰了我挺久的一个小问题,在使用 ROS param 传入参数时,有时候并不会生效,也就是参数并不能传进去!
launch
大概是这样:
<?xml version="1.0"?>
<launch>
<node pkg="location_node" type="location_node" name="location_node" output="screen">
<param name="~frame_id" value="base_link" />
</node>
</launch>
src
源码中为:
nh_.param<double>("frame_id", frame_id, "base_link");
然后就是无法传入,后来 查看 param
信息
like@like:~/fusion$ rosparam list
/location_node/frame_id
原来是在 launch
中如果定义了 name
,那么便会加在参数名上!
因此 launch
修改如下, name
改为空:
<?xml version="1.0"?>
<launch>
<node pkg="location_node" type="location_node" name="" output="screen">
<param name="~frame_id" value="base_link" />
</node>
</launch>
这个时候便可以正确传入了,当然也可以在 src
中把这个 name
加上。
小小的细节问题~