From 85b739e61819fcdfdb8f281a9110af0a6201d538 Mon Sep 17 00:00:00 2001 From: Adam Prochownik Date: Wed, 19 Aug 2026 09:40:13 +0200 Subject: [PATCH 1/3] Create the node's /rosout publisher rcl_node_init() does not create the per-node /rosout publisher; the client library has to call rcl_logging_rosout_init_publisher_for_node() itself, as rclcpp and rclpy both do. Without it rcl_logging_rosout_output_handler() finds no publisher registered for the node's logger name and drops every record, so r2r logs only ever reach the console. rcl/logging_rosout.h was also not included by the bindgen wrapper, so the functions had no bindings at all. --- r2r/src/nodes.rs | 20 +++++++++++++++++++- r2r_rcl/src/rcl_wrapper.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/r2r/src/nodes.rs b/r2r/src/nodes.rs index 11b78448e..2f209ae06 100644 --- a/r2r/src/nodes.rs +++ b/r2r/src/nodes.rs @@ -182,7 +182,7 @@ impl Node { /// Creates a ROS node. pub fn create(ctx: Context, name: &str, namespace: &str) -> Result { - let (res, node_handle) = { + let (res, mut node_handle) = { let mut ctx_handle = ctx.context_handle.lock().unwrap(); let c_node_name = CString::new(name).unwrap(); @@ -203,6 +203,20 @@ impl Node { }; if res == RCL_RET_OK as i32 { + // rcl_node_init() does not create the node's /rosout publisher -- + // the client library has to, exactly as rclcpp and rclpy do. Without + // this, rcl_logging_rosout_output_handler() finds no publisher + // registered for the node's logger name and silently drops every + // record, so logs only ever reach the console. + if unsafe { rcl_logging_rosout_enabled() } { + let ret = unsafe { rcl_logging_rosout_init_publisher_for_node(node_handle.as_mut()) }; + if ret != RCL_RET_OK as i32 { + log::error!("could not create /rosout publisher for node ({})", ret); + unsafe { rcl_node_fini(node_handle.as_mut()) }; + return Err(Error::from_rcl_error(ret)); + } + } + let ros_clock = Arc::new(Mutex::new(Clock::create(ClockType::RosTime)?)); #[cfg(r2r__rosgraph_msgs__msg__Clock)] let time_source = { @@ -1694,6 +1708,10 @@ impl Drop for Node { p.destroy(self.node_handle.as_mut()); } unsafe { + if rcl_logging_rosout_enabled() { + // Mirrors the init in Node::create; must happen before node_fini. + rcl_logging_rosout_fini_publisher_for_node(self.node_handle.as_mut()); + } rcl_node_fini(self.node_handle.as_mut()); } } diff --git a/r2r_rcl/src/rcl_wrapper.h b/r2r_rcl/src/rcl_wrapper.h index d72a24d43..52b32404d 100644 --- a/r2r_rcl/src/rcl_wrapper.h +++ b/r2r_rcl/src/rcl_wrapper.h @@ -14,6 +14,10 @@ // logging #include +// per-node /rosout publisher (rcl does not create it in rcl_node_init; +// the client library has to do it, like rclcpp/rclpy do) +#include + // errors #include From 819cd3f2ebc0b75ec9a7bfcf4e4dc91651831fe5 Mon Sep 17 00:00:00 2001 From: Adam Prochownik Date: Mon, 14 Sep 2026 11:56:46 +0200 Subject: [PATCH 2/3] R2R is generarating multiple errors after updating toolchaing to 1.95.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - unpredictable_function_pointer_comparisons — r2r_rcl/build.rs calls bindgen with .derive_partialeq(true), so every generated struct holding a C function pointer gets a derived PartialEq. rustc ≥ 1.85 flags those comparisons since function addresses aren't guaranteed unique. Added a crate-root allow in 3rdparty/r2r/r2r_rcl/src/lib.rs:10, next to the existing improper_ctypes allows that cover the same generated file. - unused import: r2r_actions::* — r2r/src/error.rs:2. Every reference in that file is already fully qualified (r2r_actions::RCL_RET_ACTION_NAME_INVALID , etc.), so the glob was genuinely dead. Removed. - associated function new is never used — UntypedActionSupport::new in r2r/src/msg_types.rs:284. It's only called from new_from, which r2r_msg_gen generates per action type; this workspace exposes no action types, so the generated body has zero call sites. Added #[allow(dead_code)] with a comment rather than deleting it — the function is live in any workspace that does have actions. --- r2r/src/error.rs | 1 - r2r/src/msg_types.rs | 3 +++ r2r_rcl/src/lib.rs | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/r2r/src/error.rs b/r2r/src/error.rs index 64b351b5e..e2da35f11 100644 --- a/r2r/src/error.rs +++ b/r2r/src/error.rs @@ -1,5 +1,4 @@ #![allow(non_camel_case_types)] -use r2r_actions::*; use r2r_rcl::*; use thiserror::Error; diff --git a/r2r/src/msg_types.rs b/r2r/src/msg_types.rs index 524dff0aa..dca8670de 100644 --- a/r2r/src/msg_types.rs +++ b/r2r/src/msg_types.rs @@ -281,6 +281,9 @@ pub struct UntypedActionSupport { } impl UntypedActionSupport { + // Only called from the generated `new_from`, whose body has no call sites when + // the workspace exposes no action types. + #[allow(dead_code)] fn new() -> Self where T: WrappedActionTypeSupport, diff --git a/r2r_rcl/src/lib.rs b/r2r_rcl/src/lib.rs index b55335fd0..b6a7648e8 100644 --- a/r2r_rcl/src/lib.rs +++ b/r2r_rcl/src/lib.rs @@ -7,6 +7,11 @@ // It could be good to still warn if building with an older rust version. #![allow(improper_ctypes)] #![allow(improper_ctypes_definitions)] +// bindgen derives PartialEq on structs holding C function pointers, which rustc +// >= 1.85 flags because function addresses are not guaranteed to be unique. The +// comparisons live in generated code we do not control, and nothing in r2r relies +// on them being meaningful. +#![allow(unpredictable_function_pointer_comparisons)] include!(concat!(env!("OUT_DIR"), "/rcl_bindings.rs")); use std::ffi::{CStr, CString}; From 9f8fca4404a4b1548885182b191e0b848503d0a1 Mon Sep 17 00:00:00 2001 From: Wiktor Bajor Date: Mon, 23 Nov 2026 13:30:42 +0100 Subject: [PATCH 3/3] [RBTSW-949] Fix action expiration in r2r --- r2r/src/action_servers.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/r2r/src/action_servers.rs b/r2r/src/action_servers.rs index d9ecdf0e3..373262af6 100644 --- a/r2r/src/action_servers.rs +++ b/r2r/src/action_servers.rs @@ -429,9 +429,12 @@ where fn handle_goal_expired(&mut self) { let mut goal_info = WrappedNativeMsg::::new(); - let mut num_expired = 1; + let mut num_expired = 0; - while num_expired > 1 { + // Must run until nothing is left to expire: this call is what re-arms + // or cancels the expire timer, which otherwise stays ready and makes + // every rcl_wait return at once. + loop { let ret = unsafe { rcl_action_expire_goals(&self.rcl_handle, &mut *goal_info, 1, &mut num_expired) }; @@ -439,11 +442,15 @@ where log::debug!("action server: could not expire goal."); return; } + if num_expired == 0 { + return; + } let gi = action_msgs::msg::GoalInfo::from_native(&goal_info); let uuid = uuid_msg_to_uuid(&gi.goal_id); log::debug!("goal expired: {} - {}", uuid, num_expired); - // todo - // self.goals.remove(&uuid); + // rcl has freed the goal handle, so the pointer must go too. + self.goals.remove(&uuid); + self.cancel_senders.remove(&uuid); self.result_msgs.remove(&uuid); self.result_requests.remove(&uuid); }