How do you know the rate a rosbag has been recorded?

asked 2021-03-23 01:19:27 -0500

Kansai gravatar image

I have a rosbag that contains some (already processed)compressed images among other published topics.

I also have the original video that got converted into processed image (not in the rosbag)

If I want to publish anything (for example an image) you initiate a node, create a publisher and then use

rate = rospy.Rate(1)

where you put the rate.

I am going to play the rosbag while executing this program and I want the topics to be synchronized.

How can I know the rate which the rosbag had been recorded?

or in more general terms, how can I play the rosbag, run the script where I receive the rosbag topics while reading the bag?

edit retag flag offensive close merge delete

Comments

Just a comment:

How can I know the rate which the rosbag had been recorded?

this is a bit of an odd thing to ask in an event based system such as a ROS application.

The pattern you describe (using a Rate) is not as universal as you make it out to be.

It's perfectly possible to nodes to not implement a periodic loop, but instead implementing reactive behaviour only via callbacks on subscriptions, service calls and action goals.

If you think about it: what would "rate" mean in those cases?

gvdhoorn gravatar image gvdhoorn  ( 2021-03-23 02:59:01 -0500 )edit

yes, I would implement a callback if I am receiving a topic (which eventually I will be since the rosbag is played) but at the same time I will also read a video and publish its images , so how can I synchronize both?

Kansai gravatar image Kansai  ( 2021-03-23 03:31:14 -0500 )edit