read bag messages as numpy in python [closed]

asked 2012-10-29 13:05:36 -0500

Eruditass gravatar image

updated 2014-01-28 17:14:06 -0500

ngrennan gravatar image

I see how to subscribe to a message to get arrays as numpy arrays, but is there a way to read from a bag file and get numpy arrays?

This does not work:

import rosbag
bag = rosbag.Bag('bag.bag')
from rospy.numpy_msg import numpy_msg

msgs = bag.read_messages(topics=['blah'])
msg = numpy_msg(msgs.next())

TypeError: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-09-18 18:45:05.816621

Comments

1

Why is this question closed? @tfoote. I have this problem, and would like a solution

eric-wieser gravatar image eric-wieser  ( 2016-03-16 15:49:29 -0500 )edit
1

for topic, msg_raw, t in bag.read_messages(raw=True):

         msg_type = msg_raw[4]
         msg = msg_type()
         msg.deserialize_numpy(msg_raw[1], numpy)`
afakih gravatar image afakih  ( 2017-02-07 14:58:54 -0500 )edit

Hey @afakih, your comment was somewhat hint for me. thnx

Braad gravatar image Braad  ( 2017-12-27 05:50:35 -0500 )edit