Commit Graph

19 Commits

Author SHA1 Message Date
Martin Dahl 455ea630ec Release 0.9.5 2025-04-22 10:27:18 +02:00
Martin Dahl aa180c5b15
Add `/set_parameters_atomically` (#120, #121)
* Fixed failing `ros2 param ...` on r2r nodes for Jazzy (#120)

Add `/set_parameters_atomically` service to `make_parameter_handler_internal` in `nodes.rs` to fix failing `ros2 param ...` on r2r nodes for Jazzy.

* Atomic behavior for `set_parameters_atomically` (#121).

---------

Co-authored-by: Desmond Germans <desmond@germansmedia.nl>
2025-04-22 10:20:32 +02:00
Martin Dahl ad25b72e76 Release 0.9.4 2024-11-21 13:56:42 +01:00
Martin Dahl b1134a6ef0 Release 0.9.3 2024-11-09 09:54:48 +01:00
Martin Dahl 2236b2ac12 Release 0.9.2 2024-10-13 11:30:34 +02:00
Martin Dahl 09c8a8ae11 Release 0.9.1 2024-10-12 10:18:47 +02:00
Martin Dahl 21948154fe Release 0.9.0 2024-05-17 12:17:43 +02:00
Michal Sojka e9f375e8f6 Make the order of parameters deterministic
GUI tools for working with parameters (at least Foxglove Studio, rqt
and rig_reconfigure) show the parameters in the same order as returned
by the ListParameters service. r2r stores the parameters in a HashMap,
which iterates keys and values in arbitrary order. The result is that
the GUI tools show the parameters in different order after every node
invocation, which can be quite annoying.

To make the order deterministic, we change the parameter storage from
HashMap to IndexMap, which iterates the map in insertion order.
According to the indexmap documentation, IndexMap is a drop-in
replacement of HashMap so this change should not require code changes
in applications using r2r. At least r2r examples and my projects
needed no changes.
2024-04-29 20:33:50 +02:00
aeon 95fdea3b9c Run rustfmt using new configuration 2024-04-08 12:57:34 +02:00
Martin Dahl 03c873c22d Release 0.8.4 2024-03-19 13:30:06 +01:00
Martin Dahl 3ae831acb3 Release 0.8.3 2024-01-14 10:48:21 +01:00
Martin Dahl 6bc1f5f27b Release 0.8.2 2023-12-11 15:29:35 +01:00
Martin Dahl 2316022f02 Release 0.8.1 2023-11-30 13:00:43 +01:00
Martin Dahl 4d9da2b7a7 Release 0.8.0 2023-10-05 11:44:22 +02:00
Martin Dahl f2c8a67c0c Prepare for release 0.8.0 2023-10-05 10:51:38 +02:00
Michal Sojka 00d7a3db0b Derive ROS parameter description from field doc comments
With this change, adding doc comments to fields of structures used
with `#[derive(RosParams)]` results in those comments being used as
parameter description.

See r2r/examples/parameters_derive.rs for how to use and test this
feature.

*BREAKING CHANGE*

This commit changes r2r public API. Previously Node::params contained
HashMap<String, ParameterValue>, now it contains HashMap<String, Parameter>.

If you previously used the ParameterValue from this HashMap, now you
can get the same by using the .value field of the Parameter structure.
2023-10-05 08:34:22 +02:00
Michal Sojka c12a6fdb76 r2r_macros: Remove TODO
The code is already merged, so renaming makes little sense.
2023-10-05 08:34:22 +02:00
Martin Dahl 29404f1982 Update README 2023-09-22 08:47:46 +02:00
Michal Sojka a3fe422cd6 Implement derive(RosParams) macro and surrounding infrastructure
With this, declaring and handling node parameters becomes easy. One
just needs to define a structure(s) containing the parameters such as:

    #[derive(RosParams, Default, Debug)]
    struct Params {
        par1: f64,
        par2: i32,
        str: String,
    }

And then instantiate and register it with:

    let params = Arc::new(Mutex::new(Params::default()));
    let (paramater_handler, _) = node.make_derived_parameter_handler(params.clone())?;

This will add three parameters `par1`, `par2` and `str` to the node.
Their type will be `Double`, `Integer` and `String` respectively.
Other Rust types such as `f32` or differently sized integers, e.g.
`u16` are also supported and registered as appropriate ROS parameter
types.

After spawning the handler, e.g.:

    spawner.spawn_local(paramater_handler)?;

changing a parameter with external ROS tools (e.g. `ros2 param set`)
will result in changing the appropriate field in the `Params`
structure. Type conversion is handled automatically. For example,
setting an `i8` field (represented as `Integer` ROS parameter) will
succeed if the value is in range -128 to 127 and fail with appropriate
error message for other values.

The other direction also works: Changing a value in the `Params`
structure will be visible outside of the Node via the `get_parameters`
service.

It is also possible to organize the parameters as several nested
structures with parameters. Then, parameter names of different nesting
levels will be separated by `.`. For example `nested.par3`. See the
full example in `parameters_derive.rs`.
2023-09-22 08:42:29 +02:00