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

High latency in TF propagation #359

Closed
Myzhar opened this issue Oct 9, 2018 · 12 comments · Fixed by #551
Closed

High latency in TF propagation #359

Myzhar opened this issue Oct 9, 2018 · 12 comments · Fixed by #551
Labels
bug Something isn't working waiting on upstream waiting on a change in an upstream dependency

Comments

@Myzhar
Copy link

Myzhar commented Oct 9, 2018

I'm porting the Stereolabs ZED 3D camera package to ROS2 and I cannot work with TF because of the high latency.
I'm sure that the TF messages propagates because I can see them using the ros2 topic and the ros2 run tf2_ros tf2_echo CLI commands... but Rviz receives them with many seconds of latency (sometimes I see frame axis move in Rviz after 2 or 3 three seconds after I stopped the node).

I thought that it was a problem with our node until I made a test with the "dummy robot" example and I figured out that the latency is a general problem:

  • Run the example:
    $ ros2 launch dummy_robot_bringup dummy_robot_bringup.launch.py
  • Open $ rviz2
  • Set the fixed frame to world
  • Add a TF plugin viewer. You will see the robot link moving
  • Add a LaserScan plugin and subscribe to /scan

At this point you will see the simulated laser scan on the oscillating link of the robot and you will notice how it is rendered in late respect to its reference frame.
Furthermore you will notice a lot of errors
Could not transform from [single_rrbot_hokuyo_link] to [world] in the LaserScan plugin
and
[ERROR] [rviz2]: Lookup would require extrapolation into the future. Requested time 1538495387.01342 but the latest data is at time 1538495386.98954, when looking up transform from frame [single_rrbot_hokuyo_link] to frame [world]
in the console where RVIZ2 has been executed

image

I read that a solution was provided for a similar issue and I updated ROS2 and Rviz2 to the latest version of the master branch, but the issue is still present.
I also tried to change RMW, but each of the three available options have the same problem.

@Martin-Idel-SI
Copy link
Contributor

Martin-Idel-SI commented Oct 9, 2018

This is connected to #332.
As far as I can see the problem is the following: the laser scan display currently asks for a transform at specific times - for a laser scan these times are not just one time point, but a range of times. Previously, the message filter made sure that the transform was available by allowing for some tolerance and doing some stuff behind the scene, but since message filters weren't available in ros2 until very recently, they aren't used, yet.

I would expect this bug to persist until #55 is resolved.

@Myzhar
Copy link
Author

Myzhar commented Oct 9, 2018

I read the #332, but it does not explain why I get the TF updates in Rviz2 even after that the node has been stopped. It seems like there is somewhere a queue that is processed very slowly

@Martin-Idel-SI
Copy link
Contributor

Martin-Idel-SI commented Oct 9, 2018

Hmm..., I can't reproduce this.

I see the following:

  • the laser scan is only very rarely rendered due to missing transforms and therefore it often seems as if it was late but that's only because I don't see the latest scan but an old one (at least in your image, the rendered scan is also not the last scan message you received as that one wasn't rendered due to missing transform).
  • When I stop the dummy robot, no new laser scan gets rendered at the same moment that no new tf2 information gets processed. Of course, the last rendered laser scan will rarely be at the head of the robots last position, because it gets rendered only very rarely.
  • In other words: I see the same as your screenshot, but I can also see that the laser scan rendered on screen is maybe a second old, but not because of latency but because all updates between then and now failed due to missing transforms.

These issues are related to what type of tf2 information laser_geometry requires and should be fixed by using message filters (might be a second issue, too, but without message filters, it's hard to see).

@Myzhar
Copy link
Author

Myzhar commented Oct 9, 2018

OK, so let's wait for message filters re introduction and let's see if it solves the problem.

@Martin-Idel-SI
Copy link
Contributor

Yes, I believe this will make things much more apparent. But thanks for reporting the issue - maybe it turns out there is another problem.

@wjwwood wjwwood added bug Something isn't working waiting on upstream waiting on a change in an upstream dependency labels Oct 11, 2018
@wjwwood
Copy link
Member

wjwwood commented Oct 11, 2018

We're waiting on tf message filter.

@mjcarroll
Copy link
Member

mjcarroll commented Oct 11, 2018 via email

@wjwwood
Copy link
Member

wjwwood commented Jan 7, 2019

I don't know, I don't have time to do it right now, but if someone did a pr, I might have time to review it. Can't promise when though.

@jacobperron
Copy link
Member

@Myzhar Since #375 has been merged, can you check if you still have this issue?

@Myzhar
Copy link
Author

Myzhar commented Aug 8, 2019

@jacobperron I'm currently on another project and I don't know when I have free time to compile ROS2 from source.
I hope I can test it very soon

@allenh1
Copy link
Contributor

allenh1 commented Aug 9, 2019

@Myzhar I build a daily docker container with ROS 2 from the current master that you could probably use for your tests, should you be interested. It's allenh1/rplidar_ros_demo:latest.

@ymd-stella
Copy link
Contributor

I did some research on this issue.
The summary and my opinions are summarized below.

Summary

The principle of the problem

  • If the output frequency of /tf exceeds 30 Hz, the message will accumulate up to depth(=100) in the subscription queue of /tf.
  • The maximum delay is 100 times the output period of /tf.

About solutions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting on upstream waiting on a change in an upstream dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants