Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Rahul-K-A
Copy link

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

Description

Adds support for YAML structures as a parameter type. Original GSOC proposal here. Essentially with a 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

The user will now able to access min and max as individual parameters. These parameters will be available in rclcpp as a YAML::Node or as a dict() in Python. The rcl specific changes primarily include modifications to rcl parser that:

  1. Add support for strucrured yaml field in rcl_variant_t as a C string (char *)
  2. Modifies the YAML document parsing code to detect nesting
  3. If a nesting of parameters it detected, the parser will automatically write all subsequent events to the structured yaml events
  4. The parser uses the indentations (map_depth) to determine when to stop writing to the YAML structure

Support for namespaced existing namespaced parameters is not affected. If required users will still be able to access individual parameters such as passenger_size.min.x, passenger_size.max.x, etc.

Fixes # (issue)

Is this user-facing behavior change?

Somewhat(?). The new changes will allow the user to define use new parameter types. Old methods of getting parameters still work

Did you use Generative AI?

No.

Additional Information

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

Rahul-K-A and others added 18 commits July 22, 2025 20:13
…te it into the YAML parser

Signed-off-by: Rahul K.A <[email protected]>
Signed-off-by: Rahul K.A <[email protected]>
Signed-off-by: Rahul K.A <[email protected]>
@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

@asherikov
Copy link

  1. does this work?
<node>:
  ros__parameters:
    passenger_size:
       - x: 0.6
       - x: 0.850
  1. "The parser uses the indentations": do you mean nesting? yaml may be in compact form or JSON
  2. "automatically write all subsequent events to the structured yaml events": not clear, when the folowing is double and when it is yaml?
<node>:
  ros__parameters:
    passenger_size:
      min:
        x: 0.6

Copy link
Contributor

@jmachowinski jmachowinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rough first pass, need to look at the code in more detail

int64_t * integer_value; ///< If integer, gets stored here
double * double_value; ///< If double, gets stored here
char * string_value; ///< If string, gets stored here
char * yaml_value; ///< If structured YAML, gets stored here -> Is this right?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char * yaml_value; ///< If structured YAML, gets stored here -> Is this right?
char * yaml_value; ///< If structured YAML, gets stored here

}

// rahul-k-a: TODO Combine this with the parameter allocation part of
// `write_structured_parameter_to_string` and put everything in a seperate functiong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this todo solved or still relevant ?

// make sure that the parameter index of the yaml parameter is not overwritten
// By default, if a namespace is detected, then the parameter entry in the param
// table is replaced by its immediate chile
// This is done for optimization (?) - Rahul-K-A
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This is done for optimization (?) - Rahul-K-A
// This is done for optimization

RCUTILS_SET_ERROR_MSG("Could not initialize the emitter");
}

size_t max_string_length = 100000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size_t max_string_length = 100000;
const size_t max_string_length = 100000;


size_t max_string_length = 100000;
size_t written_size = 0;
unsigned char nested_param_string_allocator[100000];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unsigned char nested_param_string_allocator[100000];
unsigned char nested_param_string_allocator[max_string_length];

Or is this a cpp feature and does not work for C code ?

yaml_parser_delete(&parser);
});

size_t max_string_length = 100000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size_t max_string_length = 100000;
const size_t max_string_length = 100000;



size_t written_size = 0;
char nested_param_string_allocator[100000];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char nested_param_string_allocator[100000];
char nested_param_string_allocator[max_string_length];

might not work in C

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.

4 participants