Skip to content

Fix delay in displaying TF frames#354

Merged
sloretz merged 1 commit intoros2from
rviz2_tf_lag
Sep 17, 2018
Merged

Fix delay in displaying TF frames#354
sloretz merged 1 commit intoros2from
rviz2_tf_lag

Conversation

@sloretz
Copy link
Copy Markdown
Contributor

@sloretz sloretz commented Sep 15, 2018

This fixes ros2/ros1_bridge#133 . Displayed tf data was delayed because rviz wasn't able to call callbacks fast enough to service the transform listener subscription. This resulted in tf2 always having out of date transforms (see ros2/geometry2#71), and gave the mistaken impression that rviz2 was receiving data slower than rviz over the bridge.

To fix this executors now have a parameter max_duration on spin_some(). This prevents spin_some() from blocking the gui update while allowing callbacks to be executed faster than the gui updates.

rviz left, rviz2 right

Before this PR
peek 2018-09-14 11-14_tf_lag

With this PR
peek 2018-09-14 17-54_rviz_tf_fix

To reproduce the gifs see ros2/ros1_bridge#133 (comment)

spin_once() limits the number of callbacks that can be called based on how
quickly the gui updates.
This results in lag when displaying tf frames.
Use spin_some(max_duration) to execute all of the work available.
@sloretz sloretz added bug Something isn't working in review Waiting for review (Kanban column) labels Sep 15, 2018
@sloretz sloretz self-assigned this Sep 15, 2018
@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Sep 15, 2018

CI for this plus ros2/rclcpp#558 and ros2/system_tests#299

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@wjwwood
Copy link
Copy Markdown
Member

wjwwood commented Sep 15, 2018

Wow, nice!

Copy link
Copy Markdown
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is a great improvement!

Long term I think I need to consider a different threading model for rviz, but the issue is that I believe some code that is run in ROS callbacks assumes that it is run in the main GUI thread (i.e. not while Qt is updating it's run loop) to avoid issues with thread-safety and accessing UI elements.

@sloretz sloretz merged commit d7ebc8d into ros2 Sep 17, 2018
@sloretz sloretz deleted the rviz2_tf_lag branch September 17, 2018 22:52
@sloretz sloretz removed the in review Waiting for review (Kanban column) label Sep 17, 2018
@Myzhar
Copy link
Copy Markdown

Myzhar commented Oct 8, 2018

I continue to have the same issue even using the last patched version.

You can replicate it running the dummy robot example:

  • 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

@sloretz
Copy link
Copy Markdown
Contributor Author

sloretz commented Oct 8, 2018

@Myzhar would you mind making your comment a new issue on this repo? Once a pull request is merged it no longer appears on our waffle board, so comments on merged PRs tend to be forgotten.

@Myzhar
Copy link
Copy Markdown

Myzhar commented Oct 9, 2018

@sloretz sure 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rviz2 tf message drop

3 participants