diff --git a/zenoh-plugin-ros2dds/src/route_action_cli.rs b/zenoh-plugin-ros2dds/src/route_action_cli.rs index 7d5eb58..9ae59b2 100644 --- a/zenoh-plugin-ros2dds/src/route_action_cli.rs +++ b/zenoh-plugin-ros2dds/src/route_action_cli.rs @@ -154,7 +154,8 @@ impl RouteActionCli<'_> { }) } - async fn activate(&mut self) -> Result<(), String> { + // Announce the route over Zenoh via a LivelinessToken + async fn announce_route(&mut self) -> Result<(), String> { self.is_active = true; // create associated LivelinessToken @@ -163,6 +164,7 @@ impl RouteActionCli<'_> { &self.zenoh_key_expr_prefix, &self.ros2_type, )?; + log::debug!("{self} announce via token {liveliness_ke}"); let ros2_name = self.ros2_name.clone(); self.liveliness_token = Some(self.context.zsession .liveliness() @@ -178,8 +180,9 @@ impl RouteActionCli<'_> { Ok(()) } - fn deactivate(&mut self) { - log::debug!("{self} deactivate"); + // Retire the route over Zenoh removing the LivelinessToken + fn retire_route(&mut self) { + log::debug!("{self} retire"); // Drop Zenoh Publisher and Liveliness token // The DDS Writer remains to be discovered by local ROS nodes self.is_active = false; @@ -256,7 +259,7 @@ impl RouteActionCli<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if 1st local node added, activate the route if self.local_nodes.len() == 1 { - if let Err(e) = self.activate().await { + if let Err(e) = self.announce_route().await { log::error!("{self} activation failed: {e}"); } } @@ -274,7 +277,7 @@ impl RouteActionCli<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if last local node removed, deactivate the route if self.local_nodes.is_empty() { - self.deactivate(); + self.retire_route(); } } diff --git a/zenoh-plugin-ros2dds/src/route_action_srv.rs b/zenoh-plugin-ros2dds/src/route_action_srv.rs index a0caa25..3905721 100644 --- a/zenoh-plugin-ros2dds/src/route_action_srv.rs +++ b/zenoh-plugin-ros2dds/src/route_action_srv.rs @@ -140,7 +140,8 @@ impl RouteActionSrv<'_> { }) } - async fn activate(&mut self) -> Result<(), String> { + // Announce the route over Zenoh via a LivelinessToken + async fn announce_route(&mut self) -> Result<(), String> { self.is_active = true; // create associated LivelinessToken @@ -149,6 +150,7 @@ impl RouteActionSrv<'_> { &self.zenoh_key_expr_prefix, &self.ros2_type, )?; + log::debug!("{self} announce via token {liveliness_ke}"); let ros2_name = self.ros2_name.clone(); self.liveliness_token = Some(self.context.zsession .liveliness() @@ -164,8 +166,9 @@ impl RouteActionSrv<'_> { Ok(()) } - fn deactivate(&mut self) { - log::debug!("{self} deactivate"); + // Retire the route over Zenoh removing the LivelinessToken + fn retire_route(&mut self) { + log::debug!("{self} retire"); // Drop Zenoh Publisher and Liveliness token // The DDS Writer remains to be discovered by local ROS nodes self.is_active = false; @@ -242,7 +245,7 @@ impl RouteActionSrv<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if 1st local node added, activate the route if self.local_nodes.len() == 1 { - if let Err(e) = self.activate().await { + if let Err(e) = self.announce_route().await { log::error!("{self} activation failed: {e}"); } } @@ -260,7 +263,7 @@ impl RouteActionSrv<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if last local node removed, deactivate the route if self.local_nodes.is_empty() { - self.deactivate(); + self.retire_route(); } } diff --git a/zenoh-plugin-ros2dds/src/route_publisher.rs b/zenoh-plugin-ros2dds/src/route_publisher.rs index 9204948..59a427d 100644 --- a/zenoh-plugin-ros2dds/src/route_publisher.rs +++ b/zenoh-plugin-ros2dds/src/route_publisher.rs @@ -248,8 +248,6 @@ impl RoutePublisher<'_> { .map_err(|e| format!("Failed to lisetn of matchibng status changes: {e}",))? }; - // Ok(route) - Ok(RoutePublisher { ros2_name, ros2_type, diff --git a/zenoh-plugin-ros2dds/src/route_service_cli.rs b/zenoh-plugin-ros2dds/src/route_service_cli.rs index 0ac84cc..b45d1aa 100644 --- a/zenoh-plugin-ros2dds/src/route_service_cli.rs +++ b/zenoh-plugin-ros2dds/src/route_service_cli.rs @@ -190,7 +190,8 @@ impl RouteServiceCli<'_> { }) } - async fn activate(&mut self) -> Result<(), String> { + // Announce the route over Zenoh via a LivelinessToken + async fn announce_route(&mut self) -> Result<(), String> { self.is_active = true; // if not for an Action (since actions declare their own liveliness) @@ -201,6 +202,7 @@ impl RouteServiceCli<'_> { &self.zenoh_key_expr, &self.ros2_type, )?; + log::debug!("{self} announce via token {liveliness_ke}"); let ros2_name = self.ros2_name.clone(); self.liveliness_token = Some(self.context.zsession .liveliness() @@ -217,8 +219,9 @@ impl RouteServiceCli<'_> { Ok(()) } - fn deactivate(&mut self) { - log::debug!("{self} deactivate"); + // Retire the route over Zenoh removing the LivelinessToken + fn retire_route(&mut self) { + log::debug!("{self} retire"); // Drop Zenoh Publisher and Liveliness token // The DDS Writer remains to be discovered by local ROS nodes self.is_active = false; @@ -250,7 +253,7 @@ impl RouteServiceCli<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if 1st local node added, activate the route if self.local_nodes.len() == 1 { - if let Err(e) = self.activate().await { + if let Err(e) = self.announce_route().await { log::error!("{self} activation failed: {e}"); } } @@ -262,7 +265,7 @@ impl RouteServiceCli<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if last local node removed, deactivate the route if self.local_nodes.is_empty() { - self.deactivate(); + self.retire_route(); } } diff --git a/zenoh-plugin-ros2dds/src/route_service_srv.rs b/zenoh-plugin-ros2dds/src/route_service_srv.rs index 8c57746..8250a30 100644 --- a/zenoh-plugin-ros2dds/src/route_service_srv.rs +++ b/zenoh-plugin-ros2dds/src/route_service_srv.rs @@ -207,7 +207,8 @@ impl RouteServiceSrv<'_> { }) } - async fn activate(&mut self) -> Result<(), String> { + // Announce the route over Zenoh via a LivelinessToken + async fn announce_route(&mut self) -> Result<(), String> { // For lifetime issue, redeclare the zenoh key expression that can't be stored in Self let declared_ke = self .context @@ -262,6 +263,7 @@ impl RouteServiceSrv<'_> { &self.zenoh_key_expr, &self.ros2_type, )?; + log::debug!("{self} announce via token {liveliness_ke}"); let ros2_name = self.ros2_name.clone(); self.liveliness_token = Some(self.context.zsession .liveliness() @@ -278,8 +280,9 @@ impl RouteServiceSrv<'_> { Ok(()) } - fn deactivate(&mut self) { - log::debug!("{self} deactivate"); + // Retire the route over Zenoh removing the LivelinessToken + fn retire_route(&mut self) { + log::debug!("{self} retire"); // Drop Zenoh Publisher and Liveliness token // The DDS Writer remains to be discovered by local ROS nodes self.zenoh_queryable = None; @@ -311,7 +314,7 @@ impl RouteServiceSrv<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if 1st local node added, activate the route if self.local_nodes.len() == 1 { - if let Err(e) = self.activate().await { + if let Err(e) = self.announce_route().await { log::error!("{self} activation failed: {e}"); } } @@ -323,7 +326,7 @@ impl RouteServiceSrv<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if last local node removed, deactivate the route if self.local_nodes.is_empty() { - self.deactivate(); + self.retire_route(); } } diff --git a/zenoh-plugin-ros2dds/src/route_subscriber.rs b/zenoh-plugin-ros2dds/src/route_subscriber.rs index 3414b52..141c7e8 100644 --- a/zenoh-plugin-ros2dds/src/route_subscriber.rs +++ b/zenoh-plugin-ros2dds/src/route_subscriber.rs @@ -160,7 +160,8 @@ impl RouteSubscriber<'_> { }) } - async fn activate(&mut self, discovered_reader_qos: &Qos) -> Result<(), String> { + // Announce the route over Zenoh via a LivelinessToken + async fn announce_route(&mut self, discovered_reader_qos: &Qos) -> Result<(), String> { log::debug!("{self} activate"); // Callback routing message received by Zenoh subscriber to DDS Writer (if set) let ros2_name = self.ros2_name.clone(); @@ -232,7 +233,8 @@ impl RouteSubscriber<'_> { Ok(()) } - fn deactivate(&mut self) { + // Retire the route over Zenoh removing the LivelinessToken + fn retire_route(&mut self) { log::debug!("{self} deactivate"); // Drop Zenoh Subscriber and Liveliness token // The DDS Writer remains to be discovered by local ROS nodes @@ -306,7 +308,7 @@ impl RouteSubscriber<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if 1st local node added, activate the route if self.local_nodes.len() == 1 { - if let Err(e) = self.activate(discovered_reader_qos).await { + if let Err(e) = self.announce_route(discovered_reader_qos).await { log::error!("{self} activation failed: {e}"); } } @@ -318,7 +320,7 @@ impl RouteSubscriber<'_> { log::debug!("{self} now serving local nodes {:?}", self.local_nodes); // if last local node removed, deactivate the route if self.local_nodes.is_empty() { - self.deactivate(); + self.retire_route(); } }