This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os | |
import numpy as np | |
import roslib | |
roslib.load_manifest('rosbag') | |
import rosbag | |
def loadBag(inFileName): | |
""" | |
Script to import strokelitude bag file | |
usage: outDict = loadBag(inFileName) | |
PTW 02/04/12 | |
""" | |
if inFileName[-4:] != '.bag': | |
inFileName = inFileName + '.bag' | |
bag = rosbag.Bag(inFileName) | |
timeSec = list() | |
leftWingRad = list() | |
rightWingRad = list() | |
for topic, msg, t in bag.read_messages(): | |
if topic == '/strokelitude' or topic == 'strokelitude': | |
timeSec.append(msg.header.stamp.secs + msg.header.stamp.nsecs*float(1e-9)) | |
leftWingRad.append(msg.left_wing_angle_radians) | |
rightWingRad.append(msg.right_wing_angle_radians) | |
timeSec = np.array(timeSec) | |
leftWingRad=np.array(leftWingRad) | |
rightWingRad = np.array(rightWingRad) | |
outDict = {'timeSec':timeSec, 'leftWingRad':leftWingRad, 'rightWingRad':rightWingRad} | |
return outDict |
No comments:
Post a Comment