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

Why can't I 'get' my rosrun parameters?

asked 2014-08-12 23:29:04 -0600

falseazure gravatar image

updated 2014-08-12 23:31:49 -0600

I have a node that should be able to run other nodes. It has a basic method of doing so using

system("rosrun myproject Robot robotname:='Botty'");

This should set the parameter robotname to 'Botty'. In my Robot node file, I have this code that should retrieve that parameter:

std::string robotname;
n.getParam("robotname", robotname);

However, nothing is printed. When I execute rosparam list, the corresponding parameter is /RobotNode1/robotname. What am I doing wrong? I think that rosparam list output might be a good hint - is there a way to set that parameter when executing rosrun without referencing RobotNode1?

[edit] n is a NodeHandle.

edit retag flag offensive close merge delete



Note that robotname:='Botty' does not set /RobotNode1/robotname, but just /robotname. Use _robotname:=Botty for parameters in the node's namespace.

dornhege gravatar image dornhege  ( 2014-08-13 04:20:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-13 01:04:03 -0600

BennyRe gravatar image

/RobotNode1/robotname means that this parameter has been set in the private namespace of the node.

So, you have to create a private node handle to retrieve this parameter. Do this:

ros::NodeHandle private_node_handle("~");
edit flag offensive delete link more


Thank you!

falseazure gravatar image falseazure  ( 2014-08-13 01:18:29 -0600 )edit

I just spent several hours trying to get the parameter fetching to work, because someone thought it was a good idea to use this private and public parameter setting thing.

db gravatar image db  ( 2019-05-23 14:17:15 -0600 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2014-08-12 23:29:04 -0600

Seen: 3,940 times

Last updated: Aug 13 '14