Skip to content

Commit

Permalink
Add warning when user add tf2 buffer to a transform listener while us…
Browse files Browse the repository at this point in the history
…ing csm
  • Loading branch information
JafarAbdi committed Aug 11, 2021
1 parent 89e71ae commit a0b6b0c
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ void CurrentStateMonitor::startStateMonitor(const std::string& joint_states_topi
}
if (tf_buffer_ && !robot_model_->getMultiDOFJointModels().empty())
{
// If a dedicated thread is enabled for the buffer this probably mean the user is adding them either through
// tf2_ros::TransformListener or themselves, so we print a warning message telling that transformCallback is doing
// the same duplicate operation
if (tf_buffer_->isUsingDedicatedThread())
{
RCLCPP_WARN(LOGGER, "The tf2_ros::Buffer is attached to tf2_ros::TransformListener and the internal tf "
"subscribers inside CurrentStateMonitor, you may want to remove the transform listener to "
"avoid duplicate addition to the same transforms");
}
tf_buffer_->setUsingDedicatedThread(true);
middleware_handle_->createDynamicTfSubscription(
std::bind(&CurrentStateMonitor::transformCallback, this, std::placeholders::_1, false));
Expand Down

0 comments on commit a0b6b0c

Please sign in to comment.