Ask Your Question
0

Adding parameters by command line in EloquentROS2 is not working like tutorial

asked 2020-04-01 09:44:03 -0500

bluemoon93 gravatar image

updated 2020-04-01 09:55:23 -0500

I'm following this tutorial to add a few parameters to my ROS2 node. My package iris_lama_ros2 has a node slam2d_ros which I run with

ros2 run iris_lama_ros2 slam2d_ros --ros-args -p some_int:=42

And on my code, I want to retrieve this parameter and store it on a local variable.

int local_some_int;
node->get_parameter("some_int", local_some_int);

Problem is, this doesn't work. And even on another terminal, only a use_sim_time is found

$ ros2 param list slam2d_ros
    use_sim_time

Am I doing something obviously wrong? Or do I need to setup my package and node to take parameters with some specific configuration?

edit retag flag offensive close merge delete

Comments

Does your slam2d_ros node declare the some_int parameter ? In ROS2 parameters must be declared beforehand by default, otherwise you need to explicitly allow undeclared parameters. Some more details and links at https://answers.ros.org/question/3259...

marguedas gravatar image marguedas  ( 2020-04-01 10:53:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-14 05:59:00 -0500

bluemoon93 gravatar image

@marguedas was correct. This was the correct code.

int local_some_int;
node->declare_parameter("some_int"); 
node->get_parameter("some_int", local_some_int);

And now the param list shows some_int.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-04-01 09:44:03 -0500

Seen: 18 times

Last updated: Apr 14