Robotics StackExchange | Archived questions

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

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/blob/b6f187aeae25975435a776de0017bf6c704cb591/launch_ros/launch_ros/utilities/evaluate_parameters.py#L50

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.

Asked by msmcconnell on 2022-02-22 13:54:04 UTC

Comments

Could you find an answer?

Asked by Dben on 2022-10-20 04:16:46 UTC

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.

Asked by msmcconnell on 2023-02-02 12:01:13 UTC

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

Asked by BenC on 2023-06-27 09:22:27 UTC

Answers