Skip to content

Commit 410de38

Browse files
committed
Add ActionServer::publish_feedback() method
This still needs to be hooked up to the ActionServerGoalHandle, though.
1 parent 598e066 commit 410de38

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

rclrs/src/action/server.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,22 @@ where
331331
}
332332
.ok()
333333
}
334+
335+
pub(crate) fn publish_feedback(&self, goal_id: &GoalUuid, feedback: &<T as rosidl_runtime_rs::Action>::Feedback) -> Result<(), RclrsError> {
336+
let feedback_rmw = <<T as rosidl_runtime_rs::Action>::Feedback as Message>::into_rmw_message(std::borrow::Cow::Borrowed(feedback));
337+
let mut feedback_msg = <T as rosidl_runtime_rs::ActionImpl>::create_feedback_message(&goal_id.0, &*feedback_rmw);
338+
unsafe {
339+
// SAFETY: The action server is locked through the handle, meaning that no other
340+
// non-thread-safe functions can be called on it at the same time. The feedback_msg is
341+
// exclusively owned here, ensuring that it won't be modified during the call.
342+
// rcl_action_publish_feedback() guarantees that it won't modify `feedback_msg`.
343+
rcl_action_publish_feedback(
344+
&*self.handle.lock(),
345+
&mut feedback_msg as *mut _ as *mut std::ffi::c_void,
346+
)
347+
}
348+
.ok()
349+
}
334350
}
335351

336352
impl<T> ActionServerBase for ActionServer<T>

0 commit comments

Comments
 (0)