Ask Your Question
0

Print error on non-existent param in launch file

asked 2020-05-21 03:03:02 -0500

Rufus gravatar image

updated 2020-05-21 03:03:38 -0500

A common mistake I make is setting a param with the wrong name, e.g.

<param name="min_x" value="1.0"/>

instead of

<param name="x_min" value="1.0"/>

Most of the time, the incorrectly named param does not exist. I would like to know if there's a way to detect non-existent params and show a warning which will very likely hint in an incorrectly named param.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-05-21 06:33:00 -0500

gvdhoorn gravatar image

updated 2020-05-21 06:34:30 -0500

A common mistake I make is setting a param with the wrong name, e.g.

<param name="min_x" value="1.0"/>

instead of

<param name="x_min" value="1.0"/>

Most of the time, the incorrectly named param does not exist.

Thing is: by adding that param element, min_x does exist. You've just created a parameter with that name.

I would like to know if there's a way to detect non-existent params and show a warning which will very likely hint in an incorrectly named param.

That would be great, but how would roslaunch know which parameters your node(s) accept(s)? In ROS 1, there is no infrastructure for roslaunch to use. There is also no way for nodes to indicate which parameters they need/look at.


Edit: what would be good and which would also avoid many of the problems with this, is for nodes to not use any default values for parameters. Instead, they should fail immediately if they can't find a parameter.

In case you set min_x, but the node requires x_min, it prints an error and it's immediately clear you've made a mistake with the parameter name.

edit flag offensive delete link more

Comments

1

In ROS 2, this is different: parameters have to be declared by a node (#q325960). This is exactly to make it explicit which parameters a node accepts (ros2/demos/demo_nodes_cpp/src/parameters/set_and_get_parameters.cpp). Whether this can be used by launch_ros I don't remember right now. But it is a step in the right direction.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-21 06:33:19 -0500 )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

2 followers

Stats

Asked: 2020-05-21 03:03:02 -0500

Seen: 10 times

Last updated: May 21