#ros #rosrust #dynamic-reconfigure

rosrust_dynamic_reconfigure

dynamic_reconfigure implementation for rosrust

2 unstable releases

0.2.0 Jul 4, 2023
0.1.0 May 25, 2023

#59 in Robotics

MIT/Apache

77KB
1.5K SLoC

rosrust_dynamic_reconfigure

CI Status Crates.io Docs.rs Documentation for main

This is currently very much WIP and more of an experiment how to best implement it in rust.

The dynamic_reconfigure API

In the process of developing this crate, I noticed that there wasn't any conclusive documentation on the API used by dynamic_reconfigure. This section is my attempt at providing that.

The {namespace} is the place where the config is "hosted" normally ~.

Names are expected to match the pattern [a-zA-Z][a-zA-Z0-9_]* and descriptions can be any string not containing quotes, i.e. " and '^2. Though quotes are probably fine, this might just be a limitation of the original library.

Endpoints

A Node implementing dynamic_reconfigure needs to provide^3:

  • A latched publisher providing the ConfigDescription at {namespace}/parameter_descriptions.
  • A latched publisher providing the Config at {namespace}/parameter_updates.
  • A service with type Reconfigure at {namespace}/set_parameters.

Properties

Additionally to the publishers/service dynamic_reconfigure reads on initialization and writes parameters at {namespace}/{parameter_name}.

Data Format

ConfigDescription Message

Group[] groups
Config max
Config min
Config dflt
Values

max and min describe the ranges for all int and double values, while dflt contains the default value for all parameters (see Config).

Groups

groups contains the hierarchical structure of the configuration, with the root of the configuration being the group with id=0, all other groups are subgroups of the group whose id matches their parent.

string name
string type
ParamDescription[] parameters
int32 parent 
int32 id

type concerns how the group is displayed in e.g. rqt_reconfigure, which currently supports^4:

  • empty ('') Normal group
  • collapse Group is collapsible, collapse state is controlled by state
  • tab Shows the group as a tab
  • hide If state is false hides the group
  • apply Shows an Apply button and only submits input when clicked.
ParamDescription

params describes the parameters that belong to a group.

string name
string type
uint32 level
string description
string edit_method

type is the data type, either^1:

  • str
  • bool
  • int
  • double

level provides a way to optimize partial updates, where the levels of all modified properties are | binary-ored to create a bit mask.

If edit_method is non-empty, the field is an enum. The contents are then expected to be the repr() (almost JSON) string of the required constants^5: (one way repr() differs from JSON is its use of single quotes for strings, though in the decoding direction " should be supported as well, meaning this is only an issue for parsing as long as no escapes are used.)

{
    "enum_description": "{description}",
    "enum": [ // for every variant
        {
            "name": "{variant_name}",
            "type": "{variant_type}", // Not used by rqt_reconfigure (should be the same as the param)
            "value": "{variant_value}",
            "description": "{variant_description}"
            // .. srcline + srcfile
        }
    ]
}

Config Message

BoolParameter[] bools
IntParameter[] ints
StrParameter[] strs
DoubleParameter[] doubles
GroupState[] groups
Values

bools, ints, strs and doubles hold the flattened values for each datatype.

string name
{type} value
Groups

groups contain the hierarchical information similar to ParamDescription.

string name
bool state
int32 id
int32 parent

state controls state of collapse and hide.

Dependencies

~28–41MB
~867K SLoC