-
Notifications
You must be signed in to change notification settings - Fork 205
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
TF2 Buffer crash due to timer not destructed #460
Comments
Yep, this is definitely a bug, and is also most likely the reason for ros2/rviz#703 . I've attempted a few fixes of this, but I have not yet been able to get something that fixes it completely. I'm still trying. |
Hello @BriceRenaudeau! Thanks for bringing this up. I am currently helping to look into this too, but can't seem to recreate the problem reliably other than repeatedly toggling a costmap in rviz2 randomly. Could you provide a sample of how you're recreating it? |
Hi, I cannot give you the full code, but I can provide you with the critical parts. So I create a node with the costmap and a MyNode(): Node("my_node")
{
// Init costmap
costmap_ros_ = std::make_shared<nav2_costmap_2d::Costmap2DROS>("local_costmap", "", "my_node");
costmap_thread_ = std::make_unique<nav2_util::NodeThread>(costmap_ros_);
costmap_active_ = false;
// init costmap
costmap_ros_->configure();
costmap_ros_->activate();
costmap_active_ = true;
// Init param handler
param_handler_ = std::make_shared<rclcpp::ParameterEventHandler>(this);
static_layer_cb_handler_ = param_handler_->add_parameter_callback(
"static_layer.enabled",
std::bind(&MyNode::static_layer_cb, this, std::placeholders::_1),
"/my_node/local_costmap"
);
} Then in the ParamEventHandler I catch the config and restart the costmap. void MyNode::static_layer_cb(const rclcpp::Parameter param) {
if (costmap_ros_->get_current_state().label() == "active") {
if (param.as_bool() != use_static_layer) {
use_static_layer = param.as_bool();
// reload costmap
RCLCPP_INFO(get_logger(), "Costmap param has changed : Reset costmap");
costmap_ros_->deactivate();
//rclcpp::Rate(2).sleep(); // my durty fix
costmap_ros_->cleanup();
costmap_ros_->configure();
costmap_ros_->activate();
}
}
return;
} Hence every time you change a parameter it will restart the costmap auto parameter_client = std::make_shared<rclcpp::AsyncParametersClient>(shared_from_this(), "/my_node/local_costmap", rmw_qos_profile_parameters);
auto set_results = parameter_client->set_parameters({rclcpp::Parameter("static_layer.enabled", false)}); |
Hello @BriceRenaudeau! I just created a PR targeting I have this branch applying the same fix to |
@aaronchongth, many thanks for the PR. |
Hi, |
I believe it did, but confirmation would be much appreciated. |
Is it possible to have it backported on galactic? |
As it was put into Rolling, unfortunately not. That fix was a change to the API and ABI of tf2 and rviz, which isn't allowed in released distributions. There may be a way to backport it while preserving API and ABI, but that would take a bunch of time. If you are interested in attempting a backport, I can give you some pointers on what you would need to change to keep it API and ABI compatible. |
Given that this was fixed long ago, I'm going to close this issue. Please feel free to reopen if you are still seeing the problem. |
Bug report
Steps to reproduce the issue
Create a costmap_2D with some plugins.
Then repeatedly configure - activate - deactivate - cleanup.
Expected behavior
The costmap is repeatedly activated and deactivated without a crash.
Actual behavior
After some time, the node crash due to a segfault.
Additional information
Using backward_ros I got this detailed failure.
This crash might be due to the tf2_ros
waitForTransform
function that creates a timer to call a callback:geometry2/tf2_ros/src/buffer.cpp
Lines 258 to 261 in 8e508d0
When cleaning the costmap, the buffer is destructed but the Timer still exists and the callback function doesn't exist anymore hence the timer creates a segfault.
The crash happens after the call of
tf_buffer_->canTransform
:https://github.com/ros-planning/navigation2/blob/e5a4c844c748233dc4d3039b1ea5809c81dac45f/nav2_costmap_2d/src/costmap_2d_ros.cpp#L219-L221
My false fix
To avoid this crash I added a delay(transform_tolerance_) between deactivate() and cleanup().
To let the timer trigger before
.reset()
The text was updated successfully, but these errors were encountered: