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

ROS2: Override param value when running the node

asked 2020-10-06 05:47:54 -0600

kk2105 gravatar image

updated 2020-10-18 21:36:00 -0600

Hi Guys,

ROS Version used : Dashing

I have a ROS2 package with below parameters set in params.yaml file.

node_name:  
  ros__parameters:
    node_topic : /some/topic
    scenario_id : scenario_1

I run my node ros2 run package_name executable_name __params:=params.yaml so that it takes the parameters value set in params.yaml file.

Now I would like to change value only for scenario_id while running the ros node in command line. Something like this ros2 run package_name executable_name _scenario_id:=check_scenario.

I have looked into the ros2 tutorials. As per the tutorials given, looks like setting the parameters value in command line is not supported in Dashing.

Could anybody please suggest me if there is a way to do it?

Thank you,
KK

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-11-01 05:41:22 -0600

bergercookie gravatar image

It's now possible to do that with, at least, the ROS2 Foxy version.

--ros-args -p scenario_id:="check_scenario"

I also think the format for specifying multiple parameters via YAML has also changed.

Instead of __params:=params.yaml you know need to do --ros-args --params-file params.yaml

See the "Summary" section of this document: https://design.ros2.org/articles/ros_...

edit flag offensive delete link more
1

answered 2020-10-20 15:44:44 -0600

jacobperron gravatar image

You are correct that setting individual parameters from the command-line is not supported in Dashing.

However, I think you can achieve what you want by passing multiple parameters files. For example, create a second parameters file, params2.yaml with the following contents:

node_name:  
  ros__parameters:
    scenario_id : check_scenario

and then pass after the first parameters file on the command-line:

ros2 run package_name executable_name __params:=params.yaml __params:=params2.yaml

The general rule is parameters in files passed later will override parameters from earlier files.

edit flag offensive delete link more

Comments

Reading your question again, I'm not sure if this is the answer you were looking for. Basically, you cannot set individual parameters directly from the command-line Dashing.

jacobperron gravatar image jacobperron  ( 2020-10-20 15:46:59 -0600 )edit

Thanks for your answer. That was helpful. However, I would really like if changing individual parameter values will be supported in future for Dashing as well. I have number of scenarios (20+), only that one value needs to be changed based on the requirement. Creating a params file for each scenario can be done, but may not be the ideal way to do.

kk2105 gravatar image kk2105  ( 2020-10-21 01:06:10 -0600 )edit
1

It is very unlikely that this feature will be added to Dashing. We avoid backporting large changes to older ROS distributions so that we can maintain stability within a release. For example, backporting this feature would likely require that existing users of Dashing change their syntax for remapping from the command-line.

If you would really like this feature, I recommend upgrading to a newer ROS distribution.

jacobperron gravatar image jacobperron  ( 2020-10-21 11:37:43 -0600 )edit

Yea.. Thanks for the update. Rest of the software stack is running with dashing. Until and unless the entire stack gets updated I cant update only this. :-(

kk2105 gravatar image kk2105  ( 2020-10-21 22:32:25 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2020-10-06 05:47:54 -0600

Seen: 1,512 times

Last updated: Nov 01 '21