ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to set parameter in rosrun command line?

asked 2020-05-22 00:24:40 -0600

improve100 gravatar image

updated 2020-05-22 00:25:13 -0600

my code:

ros::NodeHandle priv_nh("~");

priv_nh.getParam ("filename", filename_);

i use:

rosrun my_package my_node _filename:=test

it is not working.

edit retag flag offensive close merge delete

Comments

Please show a complete piece of code. There is a chance you are missing some lines which could cause the problems you are having.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-22 03:40:17 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-05-22 01:24:33 -0600

You could set the param first after starting roscore.

rosparam set filename test
rosrun my_package my_node
edit flag offensive delete link more

Comments

global nodehandle setting parameter can use rosrun commandline .private nodehandle not.

improve100 gravatar image improve100  ( 2020-05-22 01:33:59 -0600 )edit

Emmm, you may add node_name before the filename, like "rosparam set node_name/filename test"

tianb03 gravatar image tianb03  ( 2020-05-22 01:56:19 -0600 )edit
0

answered 2020-05-25 16:40:25 -0600

borgcons gravatar image

If filename_ is an std::string then:

rosrun my_package my_node _filename:="test"
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-05-22 00:24:40 -0600

Seen: 1,715 times

Last updated: May 25 '20