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

rviz2 tf message drop #133

Closed
llllIIIIllll opened this issue Aug 8, 2018 · 7 comments · Fixed by ros2/rviz#354
Closed

rviz2 tf message drop #133

llllIIIIllll opened this issue Aug 8, 2018 · 7 comments · Fixed by ros2/rviz#354
Assignees
Labels
bug Something isn't working

Comments

@llllIIIIllll
Copy link

Bug report

Required Info:

  • Operating System:
    • Ubuntu 16.04
  • Installation type:
    • from source
  • Version or commit hash:
    • release-latest/ros2.repos
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Step 1:

terimal 1:

setup ros1 environment(kinetic) and run

source <path-to-ros1>/setup.bash 
roscore

terminal 2:

build rotors_simulator with ros1

cd ~/catkin_ws/src
git clone https://github.com/ethz-asl/mav_comm
git clone https://github.com/ethz-asl/rotors_simulator
touch ~/catkin_ws/src/rotors_simulator/rotors_hil_interface/CATKIN_IGNORE
cd ~/catkin_ws && catkin_make

run the mav_with_joy.launch

source ~/catkin_ws/devel/setup.bash
roslaunch rotors_gazebo mav_with_joy.launch 

it will start gazebo, push the start button at gazebo

Step 2:

terminal 3

make the drone flying

source ~/catkin_ws/devel/setup.bash
rostopic pub /firefly/joy sensor_msgs/Joy "header: 
  seq: 0                                           
  stamp:                                             
    secs: 0
    nsecs: 0
  frame_id: ''
axes:
- 0
buttons:
- 3" 

Step 3:

terminal 4:

run the ros1_bridge

source <path-to-ros1>/setup.bash 
source <path-to-ros2>/local_setup.bash 
export ROS_MASTER_URI=http://localhost:11311
ros2 run ros1_bridge dynamic_bridge

terminal 5:

start rviz and rviz2

source <path-to-ros2>/local_setup.bash 
rviz2

add the tf in rviz2

terminal 6:

source <path-to-ros1>/setup.bash 
rviz

add the tf in rviz

Expected behavior

the tf frame should be same smooth between rviz and rviz2

Actual behavior

rviz2 is obvious lag and these are some tf messages lost

Additional information

If whe add up the Frame rate in rviz2 the display will more smooth

the ros2 run tf2_ros tf2_monitor
information is

All Broadcasters:
Node: <no authority available> 260.361 Hz, Average Delay: 1.53372e+09 Max Delay: 1.53372e+09

mem (7.7 GiB)

cpu (Intel® Core™ i7-8550U CPU @ 1.80GHz × 8 ) information

29750 wbl       20   0 4235388 366848 144508 R 105.3  4.6  30:30.85 gzclient                                                                             
29788 wbl       20   0 3563996 151204  82460 S  37.2  1.9  10:09.64 gzserver                                                                             
 1007 root      20   0  564680  87252  55464 S  11.6  1.1  11:14.80 Xorg                                                                                 
17930 wbl       20   0 1050108  87516  78152 S  11.0  1.1   0:21.32 dynamic_bridge                                                                       
25865 wbl       20   0 2113812 130572  99360 S  11.0  1.6   0:09.23 rviz                                                                                 
16677 wbl       20   0 1408952 132244 102928 S  10.3  1.6   0:21.86 rviz2                                                                                
 1906 wbl       20   0 1598140 149496  57432 S   6.6  1.9   8:05.13 compiz                                                                               
29602 wbl       20   0  881344  88116  34936 S   2.7  1.1   0:43.62 python                                                                               
 2120 wbl       20   0  644320  42284  15164 S   2.3  0.5   2:25.98 gnome-terminal-                                                                      
29503 wbl       20   0  617432  53792   7344 S   2.3  0.7   0:23.69 rosmaster                                                                            
29586 wbl       20   0  462444  14940  13212 S   2.3  0.2   0:36.95 robot_state_pub                                                                      
 1034 root     -51   0       0      0      0 S   1.7  0.0   1:44.17 irq/136-nvidia                                                                       
 1751 wbl       20   0 1316128 657092   8404 S   1.3  8.2  18:50.75 hud-service                                                                          
29568 wbl       20   0  346236  11832  10872 S   1.3  0.1   0:25.30 roll_pitch_yawr                                                                      
29516 wbl       20   0  399680  10108   9204 S   0.7  0.1   0:11.72 rosout                                                                               
29551 wbl       20   0  399736   9832   8932 S   0.7  0.1   0:11.05 joy_node                                                                             
29552 wbl       20   0  408040   9956   9052 S   0.7  0.1   0:11.20 rotors_joy_inte                                                                      
    8 root      20   0       0      0      0 I   0.3  0.0   0:08.23 rcu_sched                                                                            
 1775 wbl       20   0  659660  31372  15064 S   0.3  0.4   0:42.02 unity-panel-ser                                                                      
 2137 wbl       20   0  977208  97308  44136 S   0.3  1.2   0:18.31 fcitx-qimpanel                                                                       
23480 wbl       20   0   49568   3792   3064 R   0.3  0.0   0:00.16 top                                                                                  
    1 root      20   0  185704   4492   3168 S   0.0  0.1   0:01.98 systemd                                                                              
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd                                                                             
    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H                                                                         
    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq                                                                         
    7 root      20   0       0      0      0 S   0.0  0.0   0:00.85 ksoftirqd/0                                                                          
    9 root      20   0       0      0      0 I   0.0  0.0   0:00.00 rcu_bh                                                                               
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/0                                                                          
   11 root      rt   0       0      0      0 S   0.0  0.0   0:00.02 watchdog/0                                                                           
   12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/0                                                                              
   13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/1                                                                              
   14 root      rt   0       0      0      0 S   0.0  0.0   0:00.02 watchdog/1                                                                           
   15 root      rt   0       0      0      0 S   0.0  0.0   0:00.08 migration/1                                                                          
   16 root      20   0       0      0      0 S   0.0  0.0   0:00.88 ksoftirqd/1                                                                          
   18 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/1:0H                                                                         
   19 root      20   0       0      0      0 S   0.0  0.0   0:00.00 cpuhp/2 

Feature request

Feature description

Implementation considerations

@calvertdw
Copy link

Have you compared the performance to OpenSplice? (RMW_IMPLEMENTATION=rmw_opensplice_cpp)

Are you using BEST_EFFORT or RELIABLE QoS settings for the tf in rviz2?

Since you are building from source, you might have to rebuild to use OpenSplice, following instructions at https://github.com/ros2/ros2/wiki/Linux-Development-Setup#install-more-dds-implementations-optional

@llllIIIIllll
Copy link
Author

I use the default Qos settings in rviz2 RMW_QOS_POLICY_RELIABILITY_RELIABLE, I have tried change it, but the problem still exist.
I also try the opensplice, it has the same problem.

@sloretz sloretz self-assigned this Aug 10, 2018
@sloretz
Copy link
Contributor

sloretz commented Sep 14, 2018

I can reproduce what looks like a lag in tf frames sent from ros1 to ros 2 when using latest ros2 sources on xenial. I built both ros1_bridge and ros2 using -DCMAKE_BUILD_TYPE=RelWithDebInfo.

Here's a smaller example that doesn't require rotors or gazebo.

Save this file as pub_tf_transforms.py
#!/usr/bin/env python  
import math
import rospy

import tf_conversions
import tf2_ros
import geometry_msgs.msg


def circle_transform(child_frame, radius, angle):
    t = geometry_msgs.msg.TransformStamped()
    t.header.stamp = rospy.Time.now()
    t.header.frame_id = "map"
    t.child_frame_id = child_frame

    t.transform.translation.x = radius * math.sin(angle)
    t.transform.translation.y = radius * math.cos(angle)
    t.transform.translation.z = 0.0
    q = tf_conversions.transformations.quaternion_from_euler(0, 0, angle)
    t.transform.rotation.x = q[0]
    t.transform.rotation.y = q[1]
    t.transform.rotation.z = q[2]
    t.transform.rotation.w = q[3]

    return t


if __name__ == '__main__':
    rospy.init_node('pub_tf_transforms')
    br = tf2_ros.TransformBroadcaster()

    freq = 100.0
    r = rospy.Rate(freq)
    angle = 0.0
    while not rospy.is_shutdown():
        radius = 2.0 * math.sin(2.0 * angle)

        t = circle_transform("base_link", radius, angle)
        br.sendTransform(t)

        angle += 2.0 * math.pi / freq / 5.0
        if angle >= 2.0 * math.pi:
            angle -= 2.0 * math.pi
        r.sleep()
Open a bunch of terminals

Roscore

. /opt/ros/kinetic/setup.bash
roscore

RViz 1

. /opt/ros/kinetic/setup.bash
rviz

Add TF display, and check Show Names

RViz 2

. ros2_ws/install/setup.bash
ros2 run rviz2 rviz2

Add TF display and check Show Names

ROS 1 Bridge

. /opt/ros/kinetic/setup.bash
. ros1_bridge_ws/install/setup.bash
ros2 run ros1_bridge dynamic_bridge

TF publisher

. /opt/ros/kinetic/setup.bash
./pub_tf_transforms.py

It looks like what RViz2 and RViz display is out of sync. Visually it looks like RViz2 is displaying data about 1 second after RViz is. However, the movement of the link frame in both looks smooth to me.

RViz left, RViz2 right
peek 2018-09-14 11-14_tf_lag

I have a lot of stuff running on the machine but the CPU and RAM usage isn't all that high.
Tasks: 329 total,   1 running, 327 sleeping,   0 stopped,   1 zombie
%Cpu(s):  2.3 us,  0.8 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 32872912 total,  8103708 free,  6789292 used, 17979912 buff/cache
KiB Swap: 16702460 total, 16687400 free,    15060 used. 24509028 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
 6184 sloretz   20   0 2305628 706152  83660 S   8.0  2.1 135:31.67 compiz      
 6454 sloretz   20   0  695044  72472  13184 S   4.3  0.2   0:29.94 python      
24457 sloretz   20   0 1666712 116076  78164 S   4.3  0.4   2:17.53 rviz        
 1211 root      20   0 1396648 909896 340608 S   4.0  2.8 440:46.41 Xorg        
31915 sloretz   20   0 2688032 966724 272868 S   3.7  2.9 114:49.08 Web Content 
31733 sloretz   20   0 3691204 999680 493096 S   2.7  3.0  69:22.07 firefox     
 6378 sloretz   20   0  979296  33392  25756 S   2.3  0.1   0:16.98 dynamic_br+ 
23884 sloretz   20   0  935696 101116  68900 S   2.0  0.3   0:55.71 rviz2       
 6122 sloretz    9 -11  509392  13796  10184 S   0.7  0.0  10:03.47 pulseaudio  
31797 sloretz   20   0 2709896 781004 237460 S   0.7  2.4  18:12.58 Web Content 
32062 sloretz   20   0 2335028 378924 157740 S   0.7  1.2  10:33.94 Web Content 
 5075 root      20   0 1534028  79600  39172 S   0.3  0.2   8:25.50 dockerd     
15582 sloretz   20   0  327320   8356   6960 S   0.3  0.0   0:04.20 sd_espeak   
15870 sloretz   20   0   41932   3816   3144 R   0.3  0.0   0:00.01 top         
20014 sloretz   20   0  534776  53260   7348 S   0.3  0.2   0:06.52 rosmaster   
20027 sloretz   20   0  334088  10176   9284 S   0.3  0.0   0:03.02 rosout      
31956 sloretz   20   0 2427884 595732 187096 S   0.3  1.8 213:15.74 Web Content 
    1 root      20   0  185612   6232   4008 S   0.0  0.0   0:02.75 systemd     
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.02 kthreadd    
    3 root      20   0       0      0      0 S   0.0  0.0   0:02.09 ksoftirqd/0 
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+ 
    7 root      20   0       0      0      0 S   0.0  0.0   2:19.48 rcu_sched   
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh      
    9 root      rt   0       0      0      0 S   0.0  0.0   0:00.20 migration/0 
   10 root      rt   0       0      0      0 S   0.0  0.0   0:00.66 watchdog/0 

@sloretz sloretz added the bug Something isn't working label Sep 14, 2018
@sloretz
Copy link
Contributor

sloretz commented Sep 14, 2018

This looks like it is an issue higher level than the bridge, possible tf2 or RViz2.

When I run ros2 topic echo /tf tf2_msgs/TFMessage and rostopic echo /tf in side-by-side terminals the timestamps appear to be the same. If I kill and restart the transform publisher the last transform displayed by each is usually the same message (there is a delay of about 0.5 seconds between starting the ros 1 tf publisher and receiving a message on the ROS 2 side). Further tf2_monitor shows very little delay

$ ros2 run tf2_ros  tf2_monitor 



RESULTS: for all Frames

Frames:
Frame: base_link, published by <no authority available>, Average Delay: 0.00051274, Max Delay: 0.00609875

All Broadcasters:
Node: <no authority available> 100.101 Hz, Average Delay: 0.00051274 Max Delay: 0.00609875

@sloretz sloretz added in progress Actively being worked on (Kanban column) in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Sep 15, 2018
@sloretz sloretz removed the in review Waiting for review (Kanban column) label Sep 17, 2018
@sloretz
Copy link
Contributor

sloretz commented Sep 17, 2018

@llllIIIIllll I believe the issue is resolved by the referenced PRs. Would you mind checking using your setup with the latest code?

@llllIIIIllll
Copy link
Author

I have tried in my project, it works. Thank you!

@Myzhar
Copy link

Myzhar commented Sep 20, 2018

I'm having the same problem... but not only in Rviz.

There is an open question on ROS answer if someone can help me:
https://answers.ros.org/question/303377/ros2-tf2-broadcasting-very-slow/

Thank you

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 a pull request may close this issue.

4 participants