Created
December 7, 2012 00:16
-
-
Save ptweir/4229634 to your computer and use it in GitHub Desktop.
Script to load strokelitude data from a .bag file
This file contains hidden or 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment