Skip to content

Commit

Permalink
checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
esteve committed Jul 17, 2023
1 parent 3f35e5d commit 53925ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
31 changes: 30 additions & 1 deletion examples/minimal_action_server/src/minimal_action_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,36 @@ fn handle_cancel(_goal_handle: Arc<GoalHandleFibonacci>) -> rclrs::CancelRespons

fn execute(goal_handle: Arc<GoalHandleFibonacci>) {
println!("Executing goal");
thread::sleep(std::time::Duration::from_millis(100));
let feedback = example_interfaces::action::Fibonacci_Feedback {
sequence: Vec::new(),
};
feedback.sequence.push(0);
feedback.sequence.push(1);
let result = example_interfaces::action::Fibonacci_Result {
sequence: Vec::new(),
};

let mut i = 1;
while i < goal_handle.goal().unwrap().order && rclrs::ok() {
if goal_handle.is_canceling() {
result.sequence = feedback.sequence.clone();
goal_handle.canceled(&result);
println!("Goal canceled");
return;
}
// Update sequence
feedback.sequence.push(feedback.sequence[i as usize] + feedback.sequence[(i - 1) as usize]);
// Publish feedback
goal_handle.publish_feedback(&feedback);
println!("Publishing feedback");
thread::sleep(std::time::Duration::from_millis(100));
}
// Check if goal is done
if rclrs::ok() {
result.sequence = feedback.sequence.clone();
goal_handle.succeed(&result);
println!("Goal succeeded");
}
}

fn handle_accepted(goal_handle: Arc<GoalHandleFibonacci>) {
Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ where
{
pub(crate) fn new(rcl_handle: Arc<rcl_action_goal_handle_t>) {}

pub(crate) fn is_canceling() -> bool {
pub(crate) fn is_canceling(&self) -> bool {
false
}

pub(crate) fn is_active() -> bool {
pub(crate) fn is_active(&self) -> bool {
false
}

pub(crate) fn is_executing() -> bool {
pub(crate) fn is_executing(&self) -> bool {
false
}
}

0 comments on commit 53925ff

Please sign in to comment.