[Draft]Add structured parameter support
Description
Adds additional API that allows the user to access structured YAML parameters as a YAML::Node (part of yaml-cpp in rclcpp. Original GSOC proposal can be found here
Essentially, given a parameter YAML file such as
<node>:
ros__parameters:
passenger_size:
min:
x: 0.6
y: 0.4
z: 0.17
max:
x: 0.850
y: 0.65
z: 0.47
In the code, the user can declare a structured yaml parameter as
this->declare_parameter("passenger_size", YAML::Node(""));
And get access to all the elements under passenger_size as
YAML::Node passenger_size = this->get_parameter("passenger_size").as_yaml();
They can then access individual fields using the standard dict() syntax
double max_x = passenger_size['max']['x'];
double_min_x = passenger_size['min']['x'];
Users can also now set yaml parameters through the ros2 CLI. The syntax is very similar to the one already used for setting messages. For example:
ros2 param set <node> passenger_size "{min: {x : 0.1, y: 0.2, z: 0.3}, max: [1, 2, "hello"] }"
will change passenger size as
min:
x: 0.1
y: 0.2
z: 0.3
max:
- 1
- 2
- hello
Fixes # (issue)
Is this user-facing behavior change?
Yes, it adds an additional parameter type that they can use. None of the existing parameter types are affected. Support for existing namespaced parameters is not affected. If required users will still be able to access individual namespaced parameters such as passenger_size.min.x, passenger_size.max.x, etc.
Did you use Generative AI?
No.
Additional Information
- Companion
rclpyPR: https://github.com/ros2/rclpy/pull/1494 - Companion
rclPR: https://github.com/ros2/rcl/pull/1254 - Compantion
rcl_interfacesPR: https://github.com/ros2/rcl_interfaces/pull/183