0
$\begingroup$

Rosanswers logo

I want to build a database that takes each image with its joy and IMU (angles) data, so I need to receive the same number of messages for each topic to have a synchronized data.
I run the below command in order to record RGB images, depth images, joystick commands, and IMU data.

$> rosbag record -O subset /camera/depth/image_raw /camera/rgb/image_raw /joy /mobile_base/sensors/imu_data_raw

then

 $> rosbag info subset.bag

which show me the information about my recorded bag file

path:        subset.bag
version:     2.0
duration:    21.9s
start:       Mar 11 2018 16:31:17.29 (1520771477.29)
end:         Mar 11 2018 16:31:39.20 (1520771499.20)
size:        857.5 MB
messages:    3113
compression: none [605/605 chunks]
types:       sensor_msgs/Image [060021388200f6f0f447d0fcd9c64743]
             sensor_msgs/Imu   [6a62c6daae103f4ff57a132d6f95cec2]
             sensor_msgs/Joy   [5a9ea5f83505693b71e785041e67a8bb]
topics:      /camera/depth/image_raw             652 msgs    : sensor_msgs/Image
             /camera/rgb/image_raw               540 msgs    : sensor_msgs/Image
             /joy                                991 msgs    : sensor_msgs/Joy  
             /mobile_base/sensors/imu_data_raw   930 msgs    : sensor_msgs/Imu

as you see there are a diffrente number of messegas for each topic. So, how can I receive the same number of it?
and one more thing

any help please?
Thanks in advance


Originally posted by khadija on ROS Answers with karma: 25 on 2018-03-11

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Have a look at the documentation in the ros wiki: rosbag:

-l NUM, --limit=NUM
     Only record NUM messages on each topic.

This is however not(!) what you really want to use as you will most likely not record the imu-message that belongs to the image-data as the imu (probably) will have a much higher frequency. A Time Synchronizer is a better choice.


Originally posted by NEngelhard with karma: 3519 on 2018-03-11

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by khadija on 2018-03-12:
First of all, thank you for your replay. Your first suggestion is works but it doesn't adequate because I don't know how many messages I need to accomplish the desired task. could you help me please how can I use the time synchronizer in my case, cuz I'm new with both ROS and python!

Comment by NEngelhard on 2018-03-12:
The wiki page I linked already contains an example in python. Where exactly is your problem?

Comment by khadija on 2018-03-13:
I saw the link but actually, I could not understand how should I use it. I run the python file but nothing is happening! I wonder if this file records my data or not? or what should I change on it? sorry if this show a stupid question but I just started with ROS&Python as well.any help is appreciate

Comment by khadija on 2018-04-11:
@NEngelhard hello again! could you tell me please what should I put on callback function? should I record my data within callback function section? or I should read a previous recording bag file inside the callback function?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.