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

Can't read bagfile containing custom messages

asked 2014-06-10 04:18:08 -0500

Ketill gravatar image

I have a bag file with video and imu data defined with custom messages that I want to read (especially topics /capture and /imu_raw). I know from documentation what the structure of the custom messages is. How can I read the data?

Doing rosbag info on the file shows:

types:    
libks/ImageSet             [b3ef08c9cff052c83f5039d098add069] 
pximu/AttitudeData         [bc609da5ddac9016c096c67da33d8b9c] 
pximu/RawIMUData           [0380911195329d307d8f033bc714dbbf] 
[...]

topics:  
/attitude                2174 msgs    : pximu/AttitudeData 
/capture                 3282 msgs    : libks/ImageSet  
/imu_raw                 10873 msgs   : pximu/RawIMUData
[...]

I cannot play the file with 'rosbag play', probably because rosbag doesn't know the message definitions. Therefore, I thought I needed to use migration(see http_wiki_ros_org/rosbag_migration) and provide custom message definitions (see http_wiki_ros_org/msg) and use them in a rule file. I made a new package 'bag_analyser", and added the custom messages to the 'msg' folder and compiled. E.g. for ImageSet I made a file ImageSet.msg:

Header header
sensor_msgs/Image[] images

This seems to work, e.g. for ' rosmsg show bag_analyser/ImageSet' I get:

std_msgs/Header header
uint32 seq
time stamp
string frame_id
sensor_msgs/Image[] images
std_msgs/Header header
uint32 seq
time stamp
string frame_id
uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data


I also made messages for RawIMUData and AttitudeData. Then I generated a rules file (rules.bmr, see full output at end), adjusted the rules that needed to be adjusted and executed:

rosbag fix original_bag.bag converted_bag.bag rules.bmr

which told me "bag migrated successfully". Doing rosbag info on the converted file gives me:

types:       bag_analyser/AttitudeData       [bc609da5ddac9016c096c67da33d8b9c]
             bag_analyser/ImageSet           [b3ef08c9cff052c83f5039d098add069]
             bag_analyser/RawIMUData         [0380911195329d307d8f033bc714dbbf]
[...]
topics:      /attitude                     2174 msgs    : bag_analyser/AttitudeData      
             /capture                      3282 msgs    : bag_analyser/ImageSet          
             /imu_raw                     10873 msgs    : bag_analyser/RawIMUData

My problem is that I still cannot read the file. I tried using 'rosbag play' but it simply gives me:

[ INFO] [1402332944.127314834]: Opening converted_bag.bag
[FATAL] [1402332944.127848761]: Error opening file: converted_bag.bag

I also tried reading in the file using the rosbag API, which also fails opening the file (code in image_converter.cpp below). I changed the bagfile's permissions and set it to allow read/write/execute just to make sure it wasn't that. What am I doing wrong? How can I read the data from the file? I am fairly new to ROS, so any help or tips are greatly appreciated!


File listings:

folder bag/analyser/msg

ImageSet.msg

Header header    
sensor_msgs/Image[] images

RawIMUData.msg

Header header
# Measured accelerations (in x, y, z)
Vector3f acc

# Measured angular speeds (around x, y, z)
Vector3f gyro

# Measured magnetic field (around x , y, z)
Vector3f mag

Vector3f.msg

float32 x
float32 y
float32 z

AttitudeData.msg

Header header

# roll angle [rad]
float32 roll

# pitch angle [rad]
float32 pitch

# yaw angle [rad]
float32 yaw

# roll angular speed [rad/s]
float32 rollspeed

# pitch angular speed [rad/s]
float32 pitchspeed

# yaw angular speed [rad/s]
float32 yawspeed

bag_analyser/image_converter.cpp ( includes message definition for ImageSet.h and tries to use rosbag API to read file):

#include <ros/ros.h>
#include <rosbag/bag.h>
#include ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-06-21 02:01:57 -0500

Ketill gravatar image

The trick is to make empty packages with the same name as the packages of the message that you need, and then add the custom message definition to these packages. So in my case I made a package 'pximu' and added the custom message definition for AttitudeData and RawIMUData to it. Then I made a 'libks' package and added the custom message definition for ImageSet to it. After compiling I could read those messages with 'rosbag play'.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-06-10 04:18:08 -0500

Seen: 2,342 times

Last updated: Jun 21 '14