Ask Your Question
1

how can I record the same number of massages from different topics?

asked 2018-03-11 07:58:22 -0500

khadija gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-03-11 09:32:46 -0500

NEngelhard gravatar image

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.

edit flag offensive delete link more

Comments

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!

khadija gravatar image khadija  ( 2018-03-12 04:06:09 -0500 )edit

The wiki page I linked already contains an example in python. Where exactly is your problem?

NEngelhard gravatar image NEngelhard  ( 2018-03-12 16:34:56 -0500 )edit

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

khadija gravatar image khadija  ( 2018-03-13 01:36:59 -0500 )edit

@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?

khadija gravatar image khadija  ( 2018-04-11 01:57:27 -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: 2018-03-11 07:58:22 -0500

Seen: 254 times

Last updated: Mar 11 '18