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

How best to post-process bagfiles for custom output message?

asked 2016-04-18 18:52:04 -0500

b2256 gravatar image

Using Robot_localization to fuse GPS and accelerometer data and finally seems to run well. My desired output will synchronize with (independent 1Hz) GPS annotated video frame data to produce a text file containing frame,lat, lon, alt, roll, pitch, yaw, timestamp for further processing by another vendor.

I plan to get there by first taking the /odometry/filtered and /gps/filtered messages acquired from bagfiles that eventually serve to fill in the 1Hz gap with gps values for all 15 (Hz) video frames.

Next I hope to put this bag data into python pandas dataframes for easy manipulation and towards combining all gps and odometry data along with that of the gps annotated video into the final txt file.

Problems that I do anticipate include post-processing bag-filtered data into one common message that contains lat,lon,alt,roll,pitch,yaw, and common timestamps.

Once that is accomplished, the next challenge relates to conversion of ros timestamps into gps(utc) time. This will be followed by the process of how to merge the higher frequency data into the 1 Hz data collected by the independent gps/video instance.

This workflow is not ideal and appears fraught with a great amount of inefficient processing and room for human error. Even though my tenacity exceeds my current ability, this project has to be accomplished in order to progress forward.

Any suggestions or advice in process would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-04-19 04:03:15 -0500

Converting rosbag data into pandas dataframes is easy. Rosbag provides a nice python API that you can use to read the messages, something like this:

import rosbag
from sensor_msgs.msg import NavSatFix
from nav_msgs.msg import Odometry

import pandas as pd

with rosbag.Bag('input.bag') as bag:
    for topic, msg, t in bag.read_messages(topics=['/odometry/filtered', '/gps/filtered']):
        if t == '/gps/filtered':
            print msg.header.stamp, msg.latitude, ... # see http://docs.ros.org/api/sensor_msgs/html/msg/NavSatFix.html
            # TODO: write into pandas dataframe

ROS time is unix time (seconds since the epoch, 01-01-1970). Simply google for "unix time to gps time python" or something.

Good luck with your project!

edit flag offensive delete link more

Comments

Thank you Martin, that code looks very encouraging. It appears that I've stumbled onto something that may work. Just now learning python and pandas from the beginning, but I will get there. Thanks again!

b2256 gravatar image b2256  ( 2016-04-19 09:56:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-18 18:52:04 -0500

Seen: 1,110 times

Last updated: Apr 19 '16