Expand description
Parameter server for nros
This crate provides a ROS 2 compatible parameter server for embedded systems.
Parameters live in storage the CALLER places and lends to the server
(ParameterStorage / ParameterTable); MAX_PARAMETERS is only the
default capacity of that storage.
§Example
use nros_params::{
ParameterDescriptor, ParameterServer, ParameterStorage, ParameterType, ParameterValue,
};
// phase-382 W2' — storage is CALLER-OWNED: place it (a `static`, a struct
// field, a local), then lend it. `ParameterStorage` defaults to
// `MAX_PARAMETERS` slots; any length works, and the server's capacity is
// whatever it is handed.
let mut storage = ParameterStorage::<8>::new();
let mut server = ParameterServer::new_in(storage.as_table());
// Declare a simple parameter
server.declare("max_speed", ParameterValue::Double(1.0));
// Declare a parameter with constraints
let desc = ParameterDescriptor::new("velocity", ParameterType::Double)
.unwrap()
.with_description("Maximum velocity in m/s")
.with_float_range(0.0, 10.0, 0.1);
server.declare_with_descriptor("velocity", ParameterValue::Double(5.0), Some(desc));
// Get and set parameters
assert_eq!(server.get_double("max_speed"), Some(1.0));
server.set_double("max_speed", 2.0);§Features
std- Enable standard library supportalloc- Enable heap allocation
Re-exports§
pub use server::LegacyParameterBuilder;pub use server::ParameterServer;pub use server::ParameterStorage;pub use server::ParameterTable;pub use typed::MandatoryParameter;pub use typed::OptionalParameter;pub use typed::ParameterBuilder;pub use typed::ParameterError;pub use typed::RangeConvertible;pub use typed::ReadOnlyParameter;pub use typed::UndeclaredParameters;pub use types::FloatingPointRange;pub use types::IntegerRange;pub use types::MAX_ARRAY_LEN;pub use types::MAX_BYTE_ARRAY_LEN;pub use types::MAX_PARAM_NAME_LEN;pub use types::MAX_PARAMETERS;pub use types::MAX_STRING_VALUE_LEN;pub use types::Parameter;pub use types::ParameterDescriptor;pub use types::ParameterRange;pub use types::ParameterType;pub use types::ParameterValue;pub use types::ParameterVariant;pub use types::SetParameterResult;