Skip to content

Commit 5afd784

Browse files
committed
Fix rclrs to compile after rebase
Update uses of a `Mutex<rcl_node_t>` with a `NodeHandle`, as was done elsewhere in the crate. Also, correct the documented UUID size to 16 rather than 24. The minimal_action_client compiles, but the minimal_action_server does not yet, complaining about expecting the `rmw` versions of messages rather than the idiomatic ones.
1 parent 1ecc46d commit 5afd784

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

rclrs/src/action.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{rcl_bindings::*, RclrsError};
1+
use crate::{rcl_bindings::*, NodeHandle, RclrsError};
22
use std::sync::{Arc, Mutex, MutexGuard};
33

44
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
@@ -34,7 +34,7 @@ where
3434
T: rosidl_runtime_rs::Action,
3535
{
3636
/// Creates a new action client.
37-
pub(crate) fn new(rcl_node_mtx: Arc<Mutex<rcl_node_t>>, topic: &str) -> Result<Self, RclrsError>
37+
pub(crate) fn new(node_handle: Arc<NodeHandle>, topic: &str) -> Result<Self, RclrsError>
3838
where
3939
T: rosidl_runtime_rs::Action,
4040
{
@@ -56,7 +56,7 @@ where
5656
T: rosidl_runtime_rs::Action,
5757
{
5858
/// Creates a new action server.
59-
pub(crate) fn new(rcl_node_mtx: Arc<Mutex<rcl_node_t>>, topic: &str) -> Result<Self, RclrsError>
59+
pub(crate) fn new(node_handle: Arc<NodeHandle>, topic: &str) -> Result<Self, RclrsError>
6060
where
6161
T: rosidl_runtime_rs::Action,
6262
{
@@ -79,7 +79,7 @@ impl<T> ServerGoalHandle<T>
7979
where
8080
T: rosidl_runtime_rs::Action,
8181
{
82-
pub fn new(rcl_handle: Arc<rcl_action_goal_handle_t>, goal_request: Arc<T>) -> Self {
82+
pub fn new(rcl_handle: Arc<rcl_action_goal_handle_t>, goal_request: Arc<T>) -> Self {
8383
Self {
8484
rcl_handle,
8585
goal_request: Arc::clone(&goal_request),

rclrs/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ pub use node::*;
4444
pub use parameter::*;
4545
pub use publisher::*;
4646
pub use qos::*;
47-
use rcl_bindings::rcl_context_is_valid;
48-
use rcl_bindings::rcl_action_goal_handle_t;
4947
pub use rcl_bindings::rmw_request_id_t;
48+
use rcl_bindings::{rcl_action_goal_handle_t, rcl_context_is_valid};
5049
pub use service::*;
5150
pub use subscription::*;
5251
pub use time::*;

rclrs/src/node.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,11 @@ impl Node {
215215
///
216216
/// [1]: crate::ActionClient
217217
// TODO: make action client's lifetime depend on node's lifetime
218-
pub fn create_action_client<T>(
219-
&self,
220-
topic: &str,
221-
) -> Result<Arc<ActionClient<T>>, RclrsError>
218+
pub fn create_action_client<T>(&self, topic: &str) -> Result<Arc<ActionClient<T>>, RclrsError>
222219
where
223220
T: rosidl_runtime_rs::Action,
224221
{
225-
let action_client = Arc::new(ActionClient::<T>::new(
226-
Arc::clone(&self.rcl_node_mtx),
227-
topic,
228-
)?);
222+
let action_client = Arc::new(ActionClient::<T>::new(Arc::clone(&self.handle), topic)?);
229223
// self.clients
230224
// .push(Arc::downgrade(&client) as Weak<dyn ClientBase>);
231225
Ok(action_client)
@@ -245,10 +239,7 @@ impl Node {
245239
where
246240
T: rosidl_runtime_rs::Action,
247241
{
248-
let action_server = Arc::new(ActionServer::<T>::new(
249-
Arc::clone(&self.rcl_node_mtx),
250-
topic,
251-
)?);
242+
let action_server = Arc::new(ActionServer::<T>::new(Arc::clone(&self.handle), topic)?);
252243
// self.servers
253244
// .push(Arc::downgrade(&server) as Weak<dyn ClientBase>);
254245
Ok(action_server)

rclrs/src/rcl_bindings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ cfg_if::cfg_if! {
138138
pub struct rosidl_message_type_support_t;
139139

140140
pub const RMW_GID_STORAGE_SIZE: usize = 24;
141-
pub const RCL_ACTION_UUID_SIZE: usize = 24;
141+
pub const RCL_ACTION_UUID_SIZE: usize = 16;
142142

143143
extern "C" {
144144
pub fn rcl_context_is_valid(context: *const rcl_context_t) -> bool;

0 commit comments

Comments
 (0)