Skip to content

Commit 6da2e69

Browse files
committed
Integrate RMW message methods into ActionImpl
Rather than having a bunch of standalone traits implementing various message functions like `ExtractUuid` and `SetAccepted`, with the trait bounds on each associated type in `ActionImpl`, we'll instead add these functions directly to the `ActionImpl` trait. This is simpler on both the rosidl_runtime_rs and the rclrs side.
1 parent 555b267 commit 6da2e69

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

rclrs/src/action/server.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
wait::WaitableNumEntities,
66
Clock, DropGuard, Node, RclrsError, ENTITY_LIFECYCLE_MUTEX,
77
};
8-
use rosidl_runtime_rs::{Action, Message, Service};
8+
use rosidl_runtime_rs::{Action, ActionImpl, Message, Service};
99
use std::{
1010
ffi::CString,
1111
sync::{atomic::AtomicBool, Arc, Mutex, MutexGuard},
@@ -165,7 +165,7 @@ where
165165
writer_guid: [0; 16],
166166
sequence_number: 0,
167167
};
168-
type RmwRequest<T> = <<<T as rosidl_runtime_rs::ActionImpl>::SendGoalService as Service>::Request as Message>::RmwMsg;
168+
type RmwRequest<T> = <<<T as ActionImpl>::SendGoalService as Service>::Request as Message>::RmwMsg;
169169
let mut request_rmw = RmwRequest::<T>::default();
170170
let handle = &*self.handle.lock();
171171
unsafe {
@@ -186,10 +186,9 @@ where
186186
mut request_id: rmw_request_id_t,
187187
accepted: bool,
188188
) -> Result<(), RclrsError> {
189-
type RmwResponse<T> = <<<T as rosidl_runtime_rs::ActionImpl>::SendGoalService as Service>::Response as Message>::RmwMsg;
189+
type RmwResponse<T> = <<<T as ActionImpl>::SendGoalService as Service>::Response as Message>::RmwMsg;
190190
let mut response_rmw = RmwResponse::<T>::default();
191-
// TODO(nwn): Set the `accepted` field through a trait, similarly to how we extracted the UUID.
192-
// response_rmw.accepted = accepted;
191+
<T as ActionImpl>::set_goal_response_accepted(&mut response_rmw, accepted);
193192
let handle = &*self.handle.lock();
194193
let result = unsafe {
195194
// SAFETY: The action server handle is locked and so synchronized with other
@@ -232,8 +231,7 @@ where
232231
Err(err) => return Err(err),
233232
};
234233

235-
let mut uuid = GoalUuid::default();
236-
rosidl_runtime_rs::ExtractUuid::extract_uuid(&request, &mut uuid.0);
234+
let uuid = GoalUuid(<T as ActionImpl>::get_goal_request_uuid(&request));
237235

238236
let response: GoalResponse = {
239237
todo!("Optionally convert request to an idiomatic type for the user's callback.");

0 commit comments

Comments
 (0)