What is best practice for parameters which are empty lists in ros2

asked 2022-02-22 12:54:04 -0600

msmcconnell gravatar image

updated 2022-02-22 12:55:08 -0600

I recently discovered that loading a parameter which is an empty list value in ROS2 Foxy is not supported. For example a yaml file containing

my_string_list_param: [] # This will cause an exception to be thrown

It seems that the parameter loaders complain that the type of the parameter cannot be determined and therefore empty sequences are rejected see here https://github.com/ros2/launch_ros/bl...

I believe empty lists are a very reasonable need for node configurations. My question, is what is the best practice in this case? What is the most ROS2 way to define empty list parameters? My main thought at the moment is a separate flag parameter which denotes if the list parameter is empty but this requires additional logic in the loading node. For some uses having the parameter be optional could also work, but this assumes a case where the default is empty and this my not always be the best choice from a configuration management perspective.

edit retag flag offensive close merge delete

Comments

Could you find an answer?

Dben gravatar image Dben  ( 2022-10-20 04:16:46 -0600 )edit
1

Unfortunately no, I'm currently using a workaround of [' '] to store an single space string to indicate list empty and handling it with custom code.

msmcconnell gravatar image msmcconnell  ( 2023-02-02 11:01:13 -0600 )edit

Currently still an open issue: https://github.com/ros2/rclcpp/issues...

BenC gravatar image BenC  ( 2023-06-27 09:22:27 -0600 )edit