Skip to content

Commit c8ad0ff

Browse files
committed
Add documentation and clean up
1 parent 0d1bec0 commit c8ad0ff

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

rclrs/src/action.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub use client::{ActionClient, ActionClientBase};
99
pub use server::{ActionServer, ActionServerBase};
1010
pub use server_goal_handle::ServerGoalHandle;
1111

12+
/// A unique identifier for a goal request.
1213
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1314
pub struct GoalUuid(pub [u8; RCL_ACTION_UUID_SIZE]);
1415

@@ -35,13 +36,20 @@ impl fmt::Display for GoalUuid {
3536
}
3637
}
3738

39+
/// The response returned by an [`ActionServer`]'s goal callback when a goal request is received.
3840
pub enum GoalResponse {
41+
/// The goal is rejected and will not be executed.
3942
Reject = 1,
43+
/// The server accepts the goal and will begin executing it immediately.
4044
AcceptAndExecute = 2,
45+
/// The server accepts the goal and will begin executing it later.
4146
AcceptAndDefer = 3,
4247
}
4348

49+
/// The response returned by an [`ActionServer`]'s cancel callback when a goal is requested to be cancelled.
4450
pub enum CancelResponse {
51+
/// The server will not try to cancel the goal.
4552
Reject = 1,
53+
/// The server will try to cancel the goal.
4654
Accept = 2,
4755
}

rclrs/src/action/client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ where
6868
{
6969
// SAFETY: Getting a zero-initialized value is always safe.
7070
let mut rcl_action_client = unsafe { rcl_action_get_zero_initialized_client() };
71-
let type_support = <T as rosidl_runtime_rs::Action>::get_type_support()
72-
as *const rosidl_action_type_support_t;
71+
let type_support = T::get_type_support() as *const rosidl_action_type_support_t;
7372
let topic_c_string = CString::new(topic).map_err(|err| RclrsError::StringContainsNul {
7473
err,
7574
s: topic.into(),

rclrs/src/action/server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ where
7777
{
7878
// SAFETY: Getting a zero-initialized value is always safe.
7979
let mut rcl_action_server = unsafe { rcl_action_get_zero_initialized_server() };
80-
let type_support = <T as rosidl_runtime_rs::Action>::get_type_support()
81-
as *const rosidl_action_type_support_t;
80+
let type_support = T::get_type_support() as *const rosidl_action_type_support_t;
8281
let topic_c_string = CString::new(topic).map_err(|err| RclrsError::StringContainsNul {
8382
err,
8483
s: topic.into(),

rclrs/src/action/server_goal_handle.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::{rcl_bindings::*, GoalUuid, RclrsError, ToResult};
2-
use std::{
3-
marker::PhantomData,
4-
sync::{Arc, Mutex},
5-
};
2+
use std::sync::{Arc, Mutex};
63

74
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
85
// they are running in. Therefore, this type can be safely sent to another thread.
@@ -173,6 +170,16 @@ where
173170
pub fn goal(&self) -> Arc<ActionT::Goal> {
174171
Arc::clone(&self.goal_request)
175172
}
173+
174+
/// Send an update about the goal's progress.
175+
///
176+
/// This may only be called when the goal is executing.
177+
///
178+
/// Returns an error if the goal is in any state other than executing.
179+
pub fn publish_feedback(&self, feedback: Arc<ActionT::Feedback>) -> Result<(), RclrsError> {
180+
// TODO: Invoke public_feedback callback
181+
todo!()
182+
}
176183
}
177184

178185
impl<ActionT> Drop for ServerGoalHandle<ActionT>

rclrs/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub use parameter::*;
4545
pub use publisher::*;
4646
pub use qos::*;
4747
pub use rcl_bindings::rmw_request_id_t;
48-
use rcl_bindings::{rcl_action_goal_handle_t, rcl_context_is_valid};
4948
pub use service::*;
5049
pub use subscription::*;
5150
pub use time::*;

0 commit comments

Comments
 (0)