Skip to content

feat(parameter): apply --ros-args parameter overrides from argv - #6

Merged
MaxiMaerz merged 1 commit into
batch/sync-upstream-2026-09from
batch/ros-args-params
Sep 30, 2026
Merged

MaxiMaerz merged 1 commit into
batch/sync-upstream-2026-09from
batch/ros-args-params

Conversation

@MaxiMaerz

Copy link
Copy Markdown

Summary

A hiroz node can now get its parameters from the standard ROS command line: --ros-args --params-file <file> -p name:=value. rclcpp and rclpy nodes get parameters the same way. The batch-robotics backend needs this change, because its launcher gives the configuration of the backend as a ROS parameters file.

The new API:

  • hiroz::ros_args::RosArgs::parse(args) and RosArgs::from_env() parse argv as rcl does. remaining_args() returns the arguments that are not ROS arguments.
  • ZNodeBuilder::with_ros_args(&RosArgs) applies the overrides to the node at build(). The overrides replace the declared defaults, also for read-only parameters.

Behaviour:

  • --params-file can occur more than one time. -p and --param take [node:]name:=value. A later source wins over an earlier source.
  • Any other argument in a --ros-args section is an error, as UnknownROSArgsError is in rclcpp.
  • Overrides that the builder sets win over argv, as NodeOptions::parameter_overrides do in rclcpp.

The YAML loader now follows rcl more closely. This also changes with_parameter_file:

  • Nested mappings become dotted parameter names. Before, the loader dropped them.
  • A sequence of integers becomes an integer array. Before, it became a byte array.
  • A value of a type that the loader does not support, and a sequence of mixed types, are errors. Before, the loader dropped them.

This PR is stacked on #5. Merge that PR first.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test -p hiroz --lib --tests (20 new tests for ros_args and the YAML loader)
  • cargo test -p hiroz-tests --features ros-msgs,jazzy --test parameter_tests (14 of 14, with the new test_ros_args_parameter_overrides)

All pass.

🤖 Generated with Claude Code

hiroz::ros_args::RosArgs parses the argv of a process as rcl does. The
arguments after --ros-args are ROS arguments. A section ends at -- or at
the end of argv, and argv can have more than one section.
remaining_args() returns all other arguments.

RosArgs supports these arguments:

- --params-file <path>, one or more times.
- -p or --param with [node:]name:=value.

All sources apply in the order of argv, and a later value wins over an
earlier value. RosArgs reads and validates the parameter files when it
parses argv. Any other argument in a --ros-args section is an error, as
UnknownROSArgsError is in rclcpp.

ZNodeBuilder::with_ros_args(&RosArgs) matches the overrides against the
fully qualified name of the node at build(). The overrides replace the
declared defaults, also for read-only parameters. Overrides that the
builder sets still win, as NodeOptions::parameter_overrides do in
rclcpp.

The YAML loader now parses a file into one entry for each selector and
matches each entry separately. Thus -p values and files use one parser.
The loader now also follows rcl more closely:

- Nested mappings become dotted parameter names.
- A selector matches one segment at a time. * matches one segment and
  ** matches any number of segments.
- The loader accepts relative namespace keys and nested namespace keys.
- A sequence of integers becomes an integer array, not a byte array.
- A value of a type that the loader does not support, and a sequence of
  mixed types, are errors. Before, the loader dropped them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxiMaerz MaxiMaerz self-assigned this Sep 29, 2026
@MaxiMaerz
MaxiMaerz added this pull request to stack #7 September 29, 2026 12:18
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-30 12:33 UTC

@MaxiMaerz
MaxiMaerz requested a review from pschmutz September 29, 2026 12:26
@MaxiMaerz
MaxiMaerz marked this pull request as ready for review September 29, 2026 12:26
@MaxiMaerz
MaxiMaerz merged commit cbcef1f into batch-robotics Sep 30, 2026
6 of 7 checks passed
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.

2 participants