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

Avoid tf race conditions during update cycle of all displays and cameras #1692

Conversation

AndreasR30
Copy link
Contributor

@AndreasR30 AndreasR30 commented Dec 29, 2021

During update cycle of displays and views (cameras) the tf buffer should not be updated. This can be achieved by disabling the separate thread for tf listener.

Otherwise it is possible that displays or cameras, which are updated at a later point in time within the cycle, use a more recent transform. This leads to undesired jittering of visuals. This affects displays, which use the latest available transform with ros::Time(). And all views/cameras as they always use the latest available transform.

The videos below show a axes display and a robot model display, which should be fixed to each other.

Here is a video before:

demo-2021-12-29_18.54.32.mp4

and after:

demo-2021-12-29_18.56.57.mp4

This disables the timeout feature in canTransform or lookupTransform of the tf buffer. But it is not used anywhere in Rviz. I also think that it is not used in any display plugin since these function are blocking then, which is not really desired in update() or in message callback. Furthermore, I don't think that there is too much overhead when the TF messages are processed in main thread.

…ce conditions during update cycle of all displays and cameras

During update cycle of displays and views (cameras) the tf buffer should not be updated. Otherwise it is possible that displays or cameras, which are updated at a later point in time within the cycle, use a more recent transform. This leads to undesired jittering of visuals. This affects displays, which use the latest available transform with ros::Time(). And all views/cameras as they always use the latest available transform.
@rhaschke
Copy link
Contributor

I don't think that there is too much overhead when the TF messages are processed in main thread.

I don't agree with this statement. If you have many TFs published, it will definitely help to process them in a separate thread (on a multi-core machine). See send_lots_of_tf.py for an example.

As I don't see a difference between both videos yet (maybe you can explicitly point me to the jittering you observed), I don't see a particular reason to give up parallel TF processing.

@AndreasR30
Copy link
Contributor Author

AndreasR30 commented Jan 14, 2022

Please have a look at the Axes Display and the chassis of the car. They should be fixed w.r.t. each other.

I understand your point. However, it is also a problem when die Displays and Cameras do not use the same TFs when stamp ros:Time(0) is used. Using another thread, It would be necessary to "freeze" the TF buffer while the update cycle is ongoing. Unfortunately, there seems to be no such function in tf listener.

@rhaschke
Copy link
Contributor

Please have a look at the Axes Display and the chassis of the car.

Thanks. I noticed the tiny glitches now. Still, I have not convinced this warrants such a drastic change.

@simonschmeisser
Copy link
Contributor

Are there other ways to snapshot the tf-data at the beginning of the render cycle? Or fix the timestamp of each render cycle? Both would be more invasive I fear

@rhaschke
Copy link
Contributor

I think, rviz already provides an appropriate mechanism via FrameManager:

  • It supports several syncModes, which role I don't yet understand. They are configured in the Time panel.
  • By default, syncMode is SyncOff, which takes the current time once at the beginning of an update:
    sync_time_ = ros::Time::now();
  • Later calls to getTransform() should adjust the requested time from TF:
    case SyncOff:
    break;

    Maybe using time = sync_time_; here will already solve the problem.

@AndreasR30, do you have resources to experiment with the FrameManager?

@rhaschke
Copy link
Contributor

Fixed via #1698.

@rhaschke rhaschke closed this May 27, 2022
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.

3 participants