ros2_rust
ros2_rust copied to clipboard
Warn or error on unknown ROS arguments
Currently, there is no warning for unknown ROS arguments, for instance:
cargo run --bin minimal_subscriber -- --ros-args --params-file=lol.yaml
This does not load the parameter file lol.yaml, since ROS 2 doesn't support the = syntax here (it should be a space instead).
I think this can be done using rcl_arguments_get_unparsed_ros().
Depending on which approach would be chosen (warn or error) there should be logging (#184) implemented before or not. In case of warn prompting, logging mechanism is necessary, since error won't be returned from Context::new() and log call should happen there. Error raising variant would be simpler, since the only thing to do would be to add new enum to RclrsError (with Display implementation) and handle unparsed arguments similarly to non-ROS ones as in #147.
I think that warn is more appropriate and logging mechanism should be implemented anyway, so in this case this issue will be blocked by #184. To make work more parallel maybe introduce bare logging interface without implementation, so call to it could be performed and this issue will be independent of #184 progress.
Yes, I agree logging is probably the way to go. Theoretically we could also make Context::new() return something like
struct ContextWithExtraInfo {
context: Context,
unparsed_ros_args: Vec<String>
}
but that's cumbersome to use.