ros2-rust / ros2_rust

Rust bindings for ROS 2
Apache License 2.0
963 stars 134 forks source link

Add support for parameters #130

Open nnmm opened 2 years ago

nnmm commented 2 years ago

This likely depends, in part, on the service/client functionality to be added soon.

The relevant functions are in https://github.com/ros2/rcl/blob/master/rcl/include/rcl/arguments.h

nnmm commented 2 years ago

@esteve @jhdcs What do you think, should we support the parameter semantics rclcpp had before Dashing, i.e. allow_undeclared_parameters and automatically_declare_initial_parameters? https://github.com/ros2/ros2_documentation/pull/187/files

These flags seem to be there mostly for backwards compatibility (though the the blackboard parameter server is cited as an example use-case). I'd find it nice if we could avoid the complexity incurred by these options.

nnmm commented 2 years ago

I noticed that implementing parameter services will cause a dependency on rcl_interfaces. That means we'd need to release that package onto crates.io as well.

ashquarky commented 1 year ago

Is there any movement on this? I'm making a driver and would like to have ~cmd_vel_timeout. I saw _parameter_map is in Node now but not used or exported?

nnmm commented 1 year ago

Hi @ashquarky – development from my side happens in bursts and I must say I have not made progress with parameters since last year. But I've now picked it up again (partly thanks to your comment :P), so there's a good chance you'll see progress on this in the coming week or so. Your use case seems to be a simple parameter set through the command line or yaml, right? Not through parameter services.

texhnolyze commented 1 year ago

Hey @nnmm have you started with this yet? I'd be happy to try implement it (but might need some pointers), as I've already had a look at adding a get_parameter_value method for local parameters, which I use a lot by combination of yaml config and launch files.

Concerning allow_undeclared_parameters and automatically_declare_parameters_from_overrides I feel, that it is reasonable to require all parameters to be predefined, however when utilizing a yaml config file I think it is tedious to require predeclaration of all those (especially if there are quite a few). Because of that I would support allowing the automatically_declare_parameters_from_overrides.

To clarify what would this issue entail:

nnmm commented 1 year ago

@texhnolyze Yes, I've started, although at a slower pace than I had planned. Parameters are just complex, the difficulty lies not so much in translating from C++, but in deciding which subset of parameters functionality is suitable for a first version in Rust, and how to do adapt things to be maybe less ugly than in C++. I plan to focus on that a bit more in the time ahead.

ashquarky commented 1 year ago

Sorry I'm late to the party, I'm just getting back into my project now. I'd be happy with just commandline stuff, yeah! Just to tweak some of the constants in the driver.

nnmm commented 1 year ago

I clarified my thinking on parameters today a little bit (by reading up on & drawing a state diagram of rclcpp's parameters). I think we can probably give direct (read-only) access to the parameter overrides (the command line stuff) for now. I think it is conceptually simple to do so, and rclcpp seems to be leaning in that direction too with https://github.com/ros2/rclcpp/pull/2090, though they only expose the names, not the values.