Skip to content

Conversation

@Rahul-K-A
Copy link

@Rahul-K-A Rahul-K-A commented Aug 30, 2025

Description

Original GSOC proposal here. Adds additional API that allows the user to access structured YAML parameters as dict() in rclpy.
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

self.declare_parameter('passenger_size', dict())

And get access to all the elements under passenger_size as

passenger_size = self.get_parameter('passenger_size').get_yaml_parameter_as_dict()

They can then access individual fields using the standard dict() syntax

print(passenger_size['max']['x'])
print(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 namespaced 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

  1. Companion rcl PR: [Draft]Add structured parameter support rcl#1254
  2. Companion rclcpp PR: [Draft]Add structured parameter support rclcpp#2944
  3. Compantion rcl_interfaces PR: Add structured parameter support  rcl_interfaces#183

Rahul-K-A and others added 4 commits August 18, 2025 23:17
Signed-off-by: Rahul K.A <karahul209@gmail.com>
Signed-off-by: Rahul K.A <karahul209@gmail.com>
Signed-off-by: Rahul K.A <karahul209@gmail.com>
@Rahul-K-A
Copy link
Author

Tagging this as a draft, because Im yet to add in tests/ apply linter. Once done,will remove the draft tag. Maintainers are welcome to start reviewing it in the meantime

@Rahul-K-A
Copy link
Author

Tagging this as a draft, because Im yet to add in tests/ apply linter. Once done,will remove the draft tag. Maintainers are welcome to start reviewing it in the meantime

Signed-off-by: Rahul K.A <karahul209@gmail.com>
…arameter

Signed-off-by: Rahul K.A <karahul209@gmail.com>
@spacether
Copy link

Could the parameter be of type typeddict?
And that typeddict has the keys min and max which have values that see Parameters with specific types? min could be a typedddict with x y and Z keys and float parameter values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants