Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[moveit_ros] fix race condition when stopping trajectory execution (backport #3198) #3239

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,7 @@ void TrajectoryExecutionManager::clear()
{
if (execution_complete_)
{
std::scoped_lock slock(execution_state_mutex_);
for (TrajectoryExecutionContext* trajectory : trajectories_)
delete trajectory;
trajectories_.clear();
Expand All @@ -1329,7 +1330,7 @@ void TrajectoryExecutionManager::clear()
}
}
else
RCLCPP_ERROR(LOGGER, "Cannot push a new trajectory while another is being executed");
RCLCPP_FATAL(LOGGER, "Expecting execution_complete_ to be true!");
}

void TrajectoryExecutionManager::executeThread(const ExecutionCompleteCallback& callback,
Expand Down Expand Up @@ -1365,7 +1366,13 @@ void TrajectoryExecutionManager::executeThread(const ExecutionCompleteCallback&

// only report that execution finished successfully when the robot actually stopped moving
if (last_execution_status_ == moveit_controller_manager::ExecutionStatus::SUCCEEDED)
waitForRobotToStop(*trajectories_[i - 1]);
{
std::scoped_lock slock(execution_state_mutex_);
if (!execution_complete_)
{
waitForRobotToStop(*trajectories_[i - 1]);
}
}

RCLCPP_INFO(LOGGER, "Completed trajectory execution with status %s ...", last_execution_status_.asString().c_str());

Expand Down
Loading