Skip to content

Commit

Permalink
Gracefully handle jump back in time
Browse files Browse the repository at this point in the history
Without this patch, the SimpleActionServer was rejecting new goals
from the new (reset) timeline until time catches up.
  • Loading branch information
rhaschke committed Sep 7, 2023
1 parent 3558eb3 commit 8a25b03
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions actionlib/include/actionlib/server/simple_action_server_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ void SimpleActionServer<ActionSpec>::goalCallback(GoalHandle goal)
boost::recursive_mutex::scoped_lock lock(lock_);
ROS_DEBUG_NAMED("actionlib", "A new goal has been received by the single goal action server");

// check that the timestamp is past or equal to that of the current goal and the next goal
if ((!current_goal_.getGoal() || goal.getGoalID().stamp >= current_goal_.getGoalID().stamp) &&
(!next_goal_.getGoal() || goal.getGoalID().stamp >= next_goal_.getGoalID().stamp))
// check that the timestamp is past or equal to that of the current goal and the next goal (or time was reset)
ros::Time now = ros::Time::now();
if ((!current_goal_.getGoal() || goal.getGoalID().stamp >= current_goal_.getGoalID().stamp || now < current_goal_.getGoalID().stamp) &&
(!next_goal_.getGoal() || goal.getGoalID().stamp >= next_goal_.getGoalID().stamp || now < next_goal_.getGoalID().stamp))
{
// if next_goal has not been accepted already... its going to get bumped, but we need to let the client know we're preempting
if (next_goal_.getGoal() && (!current_goal_.getGoal() || next_goal_ != current_goal_)) {
Expand Down

0 comments on commit 8a25b03

Please sign in to comment.