-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix: /tf and /static_tf topics' inconsistencies #2676
Fix: /tf and /static_tf topics' inconsistencies #2676
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch @Arun-Prasad-V ! Working good also on my environment.
As we fix this, I think we can add a warning also when disabling the dynamic tf
so, as we have in line 989:
ROS_WARN("Publishing dynamic camera transforms (/tf) at %g Hz", _tf_publish_rate);
We can add something similar at line ~1002, something like:
ROS_WARN("Publishing dynamic camera transforms to topic (/tf) has been stopped");
so, when user do
ros2 param set /camera/camera tf_publish_rate 0.0
he will get warning about that
@@ -37,7 +37,6 @@ void BaseRealSenseNode::getParameters() | |||
startDynamicTf(); | |||
}); | |||
_parameters_names.push_back(param_name); | |||
startDynamicTf(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change the behavior from default start publishing to not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I tested it now, if we put
This way, we will not see any of |
@@ -58,6 +58,7 @@ | |||
{'name': 'initial_reset', 'default': 'false', 'description': "''"}, | |||
{'name': 'allow_no_texture_points', 'default': 'false', 'description': "''"}, | |||
{'name': 'pointcloud.ordered_pc', 'default': 'false', 'description': ''}, | |||
{'name': 'publish_tf', 'default': 'true', 'description': 'enable/disable publishing tf'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to explain more in the description field, specially for these two parameters since they can confuse users.
publish_tf
: [bool] enable/disable publishing static or dynamic TFtf_publish_rate
: [double] rate in HZ for publishing dynamic TF
Also, I would prefer to explanation and elaborate more in the README.md file, where we explain about publish_rate
and tf_publish_rate
1- to explain that publish_tf:=false
will not publish any static/dynamic TFs, even if tf_publish_rate
is bigger than 0.0
2- to explain that publish_tf:=true
, will automatically publish static TFs. If dynamic TFs are needed, user should set the tf_publish_rate
for it, and it should be > 0.0
3- to mention that the default value is publish_tf:=true
with tf_publish_rate:=0.0
which means publishing static TFs as default behavior.
Take into mind that this fix is not covering the whole problem from issue #2522 The static broadcaster ( But the dynamic broadcaster ( We need to figure out how to solve it, maybe to use a HashMap instead of vector of tf_msgs, (see P.S. |
Added fix for the issue " Root cause:
Fix details:
|
Great job @Arun-Prasad-V. |
const std::string& child_frame_id) | ||
{ | ||
std::vector<geometry_msgs::msg::TransformStamped>::iterator it; | ||
struct find_tf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to move this struct outside this method.
and maybe name it with another name since using find_tf with find_if might be confusing while reading the code.
if (_publish_tf) | ||
{ | ||
std::lock_guard<std::mutex> lock_guard(_publish_tf_mutex); | ||
publishStaticTransforms(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we publish static transforms only at this point, then I think we should change calcAndPublishStaticTransforms
name to be just calculcateStaticTransforms
or even calcualteTransforms
since we use it for static and dynamic TFs
This is affecting line 358
|
||
if (_publish_tf) | ||
{ | ||
std::lock_guard<std::mutex> lock_guard(_publish_tf_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this part from line 201 to line 217 should be in a separate function.
Like we have PublishStaticTransforms()
which uses publish_static_tf
inside it, we can have UnpublishStaticTransforms(<params>)
which will use unpublish_static_tf
inside it.
} | ||
else | ||
{ | ||
ROS_WARN("Currently not publishing dynamic camera transforms (/tf)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question, can you remind me when we will get to here ? In which scenario ?
} | ||
|
||
// intra-process do not support latched QoS, so we need to disable intra-process for this topic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this part from line 1008 to line 1024 into a seperate function
resetStaticTransformBroadcaster(_static_tf_broadcaster)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixing #2522
Issues Fixed:
/static_tf
topic is getting listed even whenpublish_tf:=false
tf_publish_rate
param is dynamically changed from 0.0 to >0.0,/tf
topic is not getting published/tf
topic has only the TFs of last started sensor and not the TFs of previously started sensors