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

waitUntilFormed/Broken can raise exception while the state is changed (galactic/humble) #97

Closed
wants to merge 1 commit into from

Conversation

daisukes
Copy link

bool Bond::waitUntilFormed(rclcpp::Duration timeout)
{
// std::unique_lock<std::mutex> lock(mutex_);
rclcpp::Clock steady_clock(RCL_STEADY_TIME);
rclcpp::Time deadline(steady_clock.now() + timeout);
rclcpp::Rate r(100);
while (sm_.getState().getId() == SM::WaitingForSister.getId()) {
if (!rclcpp::ok()) {
break;
}
rclcpp::Duration wait_time = rclcpp::Duration(100ms);
if (timeout >= rclcpp::Duration(0.0s)) {
rclcpp::Clock steady_clock(RCL_STEADY_TIME);
wait_time = std::min(wait_time, deadline - steady_clock.now());
}
if (wait_time <= rclcpp::Duration(0.0s)) {
break; // The deadline has expired
}
r.sleep();
}
return sm_.getState().getId() != SM::WaitingForSister.getId();
}

sm_.getState() is not protected by the mutex and can be a null state.

This issue is addressed in the ros2 branch, but navigation2@humble does not seem to work with the latest bondcpp release.

So, I wanted to include the fix for humble release.

@clalancette
Copy link
Contributor

I ended up updating Humble to use the ros2 branch, so this should no longer be required. I'm going to close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants