ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Creating a rosbag from images and imu data using bag.write

asked 2021-09-20 13:10:49 -0500

quantum guy 123 gravatar image

I have seen some examples of how to make a rosbag from images (https://answers.ros.org/question/1153...), but I don't know how to do this with imu data (or any other type of data). I don't want to use the rosbag record feature, I want to create the rosbag using data already on my computer and the bag.write method. Can someone please show me how to do this for imu data? I don't know what format the rosbag wants the imu data in. The documentation for rosbag is very limited.

I prefer using python, but if someone could show how to do it for both python and C++ that would be extra helpful.

Thank you so much in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-21 18:58:05 -0500

janindu gravatar image

All you need to do is to create a message instance with data, a topic name and a time stamp for bag, and write it to the bag.

Eg Python :

from sensor_msgs.msg import Imu
import rosbag as bag

# get your imu data here (I assume N data points)
# open rosbag to write here
for i in range(N):
    imuMsg = Imu()
    imuMsg.header.stamp = # your time
    imuMsg.orientation = # your data
    # fill your other data
    bag.write("/imu", msg, msg.header.stamp)

bag.close()

C++ example can be found here

edit flag offensive delete link more

Comments

Thanks. How do I know what format the rosbag wants the imu data in?

Also, can you see my other question here: https://answers.ros.org/question/3872...

quantum guy 123 gravatar image quantum guy 123  ( 2021-09-23 17:05:08 -0500 )edit

is there any documentation for rospy that shows which fields are available to populate on the Imu() object?... And what format they are supposed to be in?...

quantum guy 123 gravatar image quantum guy 123  ( 2021-09-23 17:06:08 -0500 )edit

The imu data is inside a sensor_msgs.msg.Imuobject, which is imported on this script in the first line. The data structure definition can be found here : http://docs.ros.org/en/noetic/api/sen...

janindu gravatar image janindu  ( 2021-09-23 18:36:21 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-09-20 13:07:31 -0500

Seen: 1,027 times

Last updated: Sep 21 '21