Ask Your Question
1

Convert carmen log file into rosbag with rosbag api problem

asked 2013-10-13 04:49:48 -0500

loppo gravatar image

updated 2014-01-28 17:18:13 -0500

ngrennan gravatar image

Hi, i'm trying to convert a carmen log file in a rosbag file. for the moment i just tried to port the odometry information with are defined in the carmen file as: ODOM x y theta tv rv accel

the problem is that when i try to write on the bag file it gives me this error:

Traceback (most recent call last):
  File "con.py", line 31, in <module>
    bag.write("tf",mes)
  File "/opt/ros/groovy/lib/python2.7/dist-packages/rosbag/bag.py", line 375, in write
    msg.serialize(self._buffer)
  File "/opt/ros/groovy/lib/python2.7/dist-packages/geometry_msgs/msg/_TransformStamped.py", line 126, in serialize
    except struct.error as se: self._check_types(se)
  File "/opt/ros/groovy/lib/python2.7/dist-packages/genpy/message.py", line 313, in _check_types
    raise SerializationError(str(exc))
genpy.message.SerializationError: required argument is not a float

i think my message is well formatted according to api message format.

this is the script that i'm using

import rosbag,rospy
from std_msgs.msg import Int32, String,Header,Float64,Time,UInt8
from geometry_msgs.msg import TransformStamped,Transform,Vector3,Quaternion

rospy.init_node("time")

def odomlist(l,od_id):
    header = Header()
    #header.seq = od_id
    header.frame_id = "od"
    header.stamp = rospy.get_rostime()
    vector=Vector3(Float64(l[1]),Float64(l[2]),Float64(0.0))
    quat=Quaternion(Float64(l[3]),Float64(l[4]),Float64(l[5]),Float64(l[6]))
    tr=Transform(vector,quat)
    return (TransformStamped(header,"las",tr))


od_id=UInt8()
od_id.data=0
inp=open("carmen.clf","r")
inp=inp.readlines()
bag = rosbag.Bag('bag.bag','w')

for lines in inp:
    l=lines.split(" ")
    if l[0]=="ODOM":
        print (l)
        od_id.data+=1
        mes=odomlist(l,od_id)
        print str(mes)
        bag.write("tf",mes)

bag.close()

can someone explain me why it gives me that error ? i'm not sure if this conversion can work or if there is a better way to do this so if someone have a better idea just tell me or point me to some tutoriol.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-27 07:40:54 -0500

loppo gravatar image

updated 2013-10-27 07:47:36 -0500

the problem was that i was using the Float64,UInt8 types from the std_msgs.msg library, using normal float and int types solve the problem. (still the script above need modifications to create a working bag)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-10-13 04:49:48 -0500

Seen: 849 times

Last updated: Oct 13 '13