Skip to content

Commit 7e1303d

Browse files
authored
Reset preempt_request after canceling execution (moveit#689)
1 parent 584197a commit 7e1303d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

capabilities/test/test_task_execution.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ TEST_F(PandaMoveTo, preemptExecution) {
6060
}
6161

6262
EXPECT_EQ(result.val, moveit_msgs::msg::MoveItErrorCodes::PREEMPTED);
63+
64+
// After preempting motion reset the task and make sure we can successfully plan and execute motion again
65+
rclcpp::sleep_for(std::chrono::seconds(1));
66+
t.reset();
67+
ASSERT_TRUE(t.plan());
68+
result = t.execute(*t.solutions().front());
69+
EXPECT_EQ(result.val, moveit_msgs::msg::MoveItErrorCodes::SUCCESS);
6370
}
6471

6572
int main(int argc, char** argv) {

core/src/task.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ moveit::core::MoveItErrorCode Task::execute(const SolutionBase& s) {
316316
while (result_future.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready) {
317317
if (pimpl()->preempt_requested_) {
318318
auto cancel_future = execute_ac_->async_cancel_goal(goal_handle);
319+
this->resetPreemptRequest();
319320
if (rclcpp::spin_until_future_complete(execute_solution_node_, cancel_future) !=
320321
rclcpp::FutureReturnCode::SUCCESS) {
321322
RCLCPP_ERROR(execute_solution_node_->get_logger(), "Could not preempt execution");

0 commit comments

Comments
 (0)