ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

roscpp parameters with roslaunch remapping

asked 2014-03-03 13:14:23 -0500

stebl gravatar image

How can I access roscpp parameters if the node name has been remapped with roslaunch?

launch file,

<node pkg="my_package" type="my_package_node" name="remapped_name" ns="my_namespace">
    <param name="camera_index" value="$(arg camera_index)" />

in cpp file,

ros::init(argc, argv, "node_default_name");
ros::NodeHandle n;

ros::param::get("node_default_name/camera_index", camera_index); // Fails
ros::param::get("remapped_name/camera_index", camera_index); // Works 

n.getParam("node_default_name/camera_index", camera_index); // Fails
n.getParam("remapped_name/camera_index", camera_index); // Works

How can I get the parameters in the .cpp file without knowing the node name? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-03-03 15:17:21 -0500

brice rebsamen gravatar image

I think you should use the private namespace:

ros::param::get("~camera_index", camera_index);

ros::NodeHandle nh("~");
nh.getParam("camera_index", camera_index);


edit flag offensive delete link more


Yep, worked for me, thanks! ros::NodeHandle nh("~"); nh.getParam("camera_index", camera_index);

stebl gravatar imagestebl ( 2014-03-05 11:44:27 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

The deadline to submit a proposal to present at ROSCon 2017 is June 25, 2017. Submit yours now!

Question Tools

1 follower


Asked: 2014-03-03 13:14:23 -0500

Seen: 896 times

Last updated: Mar 03 '14