From c0af2a377dc32807fd6b5820686c0a9acd8259ca Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Fri, 30 Aug 2024 15:41:48 +0200 Subject: [PATCH] Fix -i option: remap it to the ZenohID --- README.md | 12 +++++++----- zenoh-bridge-ros2dds/src/bridge_args.rs | 6 ------ zenoh-bridge-ros2dds/src/zenoh_args.rs | 14 +++++++++++++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3cecd21..f0c6d95 100644 --- a/README.md +++ b/README.md @@ -228,8 +228,10 @@ NOTE: the bridge prefixes ALL topics/services/actions names with the configured ## Admin space -The bridge exposes some internal states via a Zenoh admin space under `@//ros2/**`, where `` is the unique id of the bridge (configurable). -This admin space can be queried via Zenoh `get()` operation. If the REST plugin is configured for the bridge for instance via `--rest-http-port 8000` argument, those URLs can be queried: -- [http://\:8000/@/\/ros2/dds/**]() : to get all the DDS Readers/Writers discovered by the bridge -- [http://\:8000/@/\/ros2/node/**]() : to get all ROS nodes with their interfaces discovered by the bridge -- [http://\:8000/@/\/ros2/route/**]() : to get all routes between ROS interfaces and Zenoh established by the bridge +The bridge exposes some internal states via a Zenoh admin space under `@//ros2/**`, where `` is the unique Zenoh ID of the bridge (configurable). +This admin space can be queried via Zenoh `get()` operation. If the REST plugin is configured for the bridge for instance via `--rest-http-port 8000` argument, such URLs can be queried: +- [http://\:8000/@/local/ros2/node/**]() : to get all ROS nodes with their interfaces discovered by the bridge +- [http://\:8000/@/local/ros2/dds/**]() : to get all the DDS Readers/Writers discovered by the bridge +- [http://\:8000/@/local/ros2/route/**]() : to get all routes between ROS interfaces and Zenoh established by the bridge +- [http://\:8000/@/*/ros2/node/**]() : to get all ROS nodes discovered by all bridges +- [http://\:8000/@/*/ros2/route/**/cmd_vel]() : to get all routes between established by all bridges on `cmd_vel` topic diff --git a/zenoh-bridge-ros2dds/src/bridge_args.rs b/zenoh-bridge-ros2dds/src/bridge_args.rs index b75b610..0f1fa7c 100644 --- a/zenoh-bridge-ros2dds/src/bridge_args.rs +++ b/zenoh-bridge-ros2dds/src/bridge_args.rs @@ -28,11 +28,6 @@ use crate::zenoh_args::CommonArgs; pub struct BridgeArgs { #[command(flatten)] pub session_args: CommonArgs, - /// The identifier (as an hexadecimal string, with odd number of chars - e.g.: 0A0B23...) that zenohd must use. - /// WARNING: this identifier must be unique in the system and must be 16 bytes maximum (32 chars)! - /// If not set, a random UUIDv4 will be used. - #[arg(short, long, verbatim_doc_comment)] - pub id: Option, /// A ROS 2 namespace to be used by the "zenoh_bridge_dds" node' #[arg(short, long)] pub namespace: Option, @@ -97,7 +92,6 @@ impl From<&BridgeArgs> for Config { fn from(args: &BridgeArgs) -> Self { let mut config = (&args.session_args).into(); - insert_json5_option(&mut config, "plugins/ros2dds/id", &args.id); insert_json5_option(&mut config, "plugins/ros2dds/namespace", &args.namespace); if let Some(domain) = args.domain { insert_json5(&mut config, "plugins/ros2dds/domain", &domain); diff --git a/zenoh-bridge-ros2dds/src/zenoh_args.rs b/zenoh-bridge-ros2dds/src/zenoh_args.rs index b80c076..295fb2e 100644 --- a/zenoh-bridge-ros2dds/src/zenoh_args.rs +++ b/zenoh-bridge-ros2dds/src/zenoh_args.rs @@ -46,6 +46,10 @@ pub struct CommonArgs { /// A configuration file. pub config: Option, #[arg(short, long)] + /// The Zenoh identifier (as an hexadecimal string, in lowercase - e.g.: a0b23...) that this bridge must use. If not set, a random unsigned 128bit integer will be used. + /// WARNING: this id must be unique in the system and must be 32 chars maximum (128 bits)! + #[arg(short, long)] + id: Option, /// The Zenoh session mode [default: router]. pub mode: Option, #[arg(short = 'e', long)] @@ -73,9 +77,17 @@ impl From<&CommonArgs> for Config { Some(path) => Config::from_file(path).unwrap(), None => Config::default(), }; + if let Some(id) = &value.id { + let _ = config.set_id( + id.parse() + .expect("Error with option --id (expecting a hexadecimal ZenohId)"), + ); + } if value.mode.is_some() { // apply mode set via command line, overwritting mode set in config file - config.set_mode(value.mode.map(Into::into)).unwrap(); + config + .set_mode(value.mode.map(Into::into)) + .expect("Error with option --mode"); } else if config.mode().is_none() { // no mode set neither via command line, neither in config file - set Router mode by default config