Ask Your Question

Revision history [back]

If you don't use a forward slash, "ros::param::get" gets a parameter from the node's namespace, but not its private namespace. If you put that parameter tag inside of a <node> tag, it will be in this private namespace.

For example, the following roslaunch xml:

<param name="camera_topic_root" value="/camera/image_rect">
<group ns="group_ns">
    <param name="camera_topic_ns" value="/camera/image_rect">
    <node name="node_name" pkg="foo" type="bar" >
        <param name="camera_topic_private" value="/camera/image_rect">
    </node>
</group>

Would set the parameters:

/camera_topic_root
/group_ns/camera_topic_ns
/group_ns/node_name/camera_topic_private

To get these parameters with the ros::param::get API, you could do each of the following:

ros::param::get("/camera_topic_root",camera_topic);    // /camera_topic_root
ros::param::get("camera_topic_ns",camera_topic);       // /group_ns/camera_topic_ns
ros::param::get("~camera_topic_private",camera_topic); // /group_ns/node_name/camera_topic_private

This is documented slightly less succinctly here.