Repository navigation
feat(parameter): apply --ros-args parameter overrides from argv - #6
Merged
Merged
Conversation
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
added this pull request to stack #7
September 29, 2026 12:18
|
MaxiMaerz
marked this pull request as ready for review
September 29, 2026 12:26
pschmutz
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)andRosArgs::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 atbuild(). The overrides replace the declared defaults, also for read-only parameters.Behaviour:
--params-filecan occur more than one time.-pand--paramtake[node:]name:=value. A later source wins over an earlier source.--ros-argssection is an error, asUnknownROSArgsErroris in rclcpp.NodeOptions::parameter_overridesdo in rclcpp.The YAML loader now follows rcl more closely. This also changes
with_parameter_file:This PR is stacked on #5. Merge that PR first.
Verification
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test -p hiroz --lib --tests(20 new tests forros_argsand the YAML loader)cargo test -p hiroz-tests --features ros-msgs,jazzy --test parameter_tests(14 of 14, with the newtest_ros_args_parameter_overrides)All pass.
🤖 Generated with Claude Code