Ask Your Question
0

Synch problem with rosbag and rqt_plot

asked 2014-05-15 00:41:25 -0500

mark_vision gravatar image

updated 2014-05-19 06:03:19 -0500

Hi All, I'm building a pose estimator and to assess it i'm using a ground truth from a vicon system. Both systems publish a PoseStamped message. When I rosbag play a dataset and I try to visualize it wit rqt_plot it seems like the two signals have different velocities. At the beginning they are synchronized but since one of the two is "faster" than the other, the effect is that it seems stretching with respect to the other. The two sources publish with a different frequency (vicon is 100 Hz, the other is like 200 Hz) but I thought that ROS was taking care of the synch between messages. Furthermore there are absolute timestamps! Any ideas?

I'm running Hydro with Ubuntu 12.04. I tried different graphic backends but nothing changes.

EDIT: even using simulation time with rosparam set /use_sim_time true seems to work (actually the plot wit PyQtGraph has a line that restart from the beginning so maybe the sim time param is not effective

EDIT 2: we found some synchronization problems inside one of the two computers. We corrected them using Chrony, but the stretching problem still remains. What we actually discovered is that during the real execution the to topics are perfectly synchronized (we checked during the execution with side by side terminals rostopic echo for both topics. Instead, when we do a rosbag play the timestamps are different!!! And one of the two has a time that flows SLOWER!!!

I use, as suggested rosbag play --clock -l mybag.bag with use_sim_time set as true

Thanks in advance.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-05-26 23:27:59 -0500

mark_vision gravatar image

Guys, I got that. It was a problem caused by RT task running. See http://answers.ros.org/question/16740...

edit flag offensive delete link more
1

answered 2014-05-15 01:12:51 -0500

updated 2014-05-15 01:17:00 -0500

This normally happens when one (or more) of the displayed messages do not have timestamp information (for example geometry_msgs/Twist). AFAIK, when playing back timestamped messages, things should work synchronized. What you describe sounds either like a bug in rqt_plot or not correctly specified timestamps in your messages.

/edit: Good point with sim time. Be sure to properly set use_sim_time: Start a core:

roscore

Set use_sim_time:

rosparam set use_sim_time true

Start whatever nodes you need and play bagfile using --clock:

rosbag play YOUR_BAG_FILE --clock

Note you should not start nodes before the use_sim_time parameter is set, because those would then use normal ROS time, which results in all sorts of weird behavior.

edit flag offensive delete link more

Comments

that is exactly what I did. This is strange because both messages are of subtype "Stamped". Furthermore, inside the code they use ros::Time::now() when they're published so they should synchronized. unfortunately I cannot post images because I don't have enough karma

mark_vision gravatar image mark_vision  ( 2014-05-15 05:24:44 -0500 )edit
1

answered 2014-05-19 06:15:02 -0500

ahendrix gravatar image

It sounds like the clocks on your computers aren't running at the same for some reason; perhaps because they're drifting, or perhaps because NTP/chrony is slewing one of the clocks to try to match it up with the NTP server. When running multi-computer networks with ROS, it's usually good practice to run an NTP server on one machine, and configure the NTP clients on the rest of the machines to use that machine as their NTP server. This way, the clocks for your network will stay in sync with each other even if you don't have an internet connection.

If you inspect the system while it's running, are messages from both computers received at the same time? Do messages that are received at the same time have the same timestamps? This should be able to give you an idea of if the clocks on both computers are running at the same rate or not.

Since rosbag records both the received timestamp and the header timestamps, it's possible to compare them and correct one based on the other; either rosbag->header or header->rosbag. There are some examples in the rosbag cookbook that may be useful for this.

edit flag offensive delete link more

Comments

As mentioned in Edit 2, yes there were some sync errors that were corrected using Chrony. While the node was running I was actually able to see that the timestamps of the two topics were synchronized. I didn't know about the fact that rosbag use both received and header timestamps. Probably the problem will be related to that. I will check.

mark_vision gravatar image mark_vision  ( 2014-05-19 07:56:38 -0500 )edit

I tried the python script in the cookbook and now times are synchronized. Unfortunately the result is not what I expected. Now the two signals run together...but they are still stretched one with respect to the other...and one of the two just finish before the end of the bag! I will try to plot in real time to see if it is different. Is it the problem related to the fact that one of the signals is 160Hz and the other 100Hz? It shouldn't be...

mark_vision gravatar image mark_vision  ( 2014-05-19 22:03:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-05-15 00:41:25 -0500

Seen: 1,401 times

Last updated: May 26 '14