quick_data.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 import numpy as np, math
00003 import scipy.io as spio
00004 import roslib; roslib.load_manifest('hrl_object_fetching')
00005 import rospy
00006 import hrl_lib.util as hrl_util
00007 from std_msgs.msg import Float64MultiArray, Bool
00008 from pr2_msgs.msg import AccelerometerState, PressureState
00009 from sensor_msgs.msg import JointState
00010 from pr2_controllers_msgs.msg import JointTrajectoryControllerState
00011 
00012 r_jt_idx_lis = [17, 18, 16, 20, 19, 21, 22]
00013 l_jt_idx_lis = [29, 30, 28, 32, 31, 33, 34]
00014 n_samples = 100 * 20
00015 class Listener:
00016     def __init__(self):
00017         self.q = np.zeros(( n_samples, 7))
00018         self.t = np.zeros((n_samples, 1))
00019         self.tind = 0
00020         self.ind = 0
00021 
00022     def callback(self,msg):
00023         if self.ind % 10 == 0:
00024             print self.tind, self.ind
00025         for i,idx in enumerate(r_jt_idx_lis):
00026             self.q[self.ind, i] = msg.position[idx]
00027             print self.q[self.ind, i],
00028         print ""
00029         self.t[self.ind] = msg.header.stamp.to_sec()
00030         self.ind += 1
00031         
00032 
00033 rospy.init_node('quick_data')
00034 lis = Listener()
00035 sub = rospy.Subscriber('/joint_states', JointState, lis.callback)
00036 #sub_started = rospy.Subscriber('/grasper/grasp_executing', Bool, lis.grasp_executing)
00037 rospy.spin()
00038 hrl_util.save_pickle([lis.q[0:lis.ind,:], lis.t[0:lis.ind,:]], 'untuck_traj_6.pickle')
00039 i = 0
00040 while lis.q[i,4] != 0:
00041     print lis.q[i-1,3] - lis.q[i,3],
00042     i += 1
00043 #c = 10
00044 #data = {'q%d'%c:lis.q, 'des%d'%c:lis.des, 't%d'%c:lis.t}
00045 #data = {'q':lis.q, 'des':lis.des, 't':lis.t}
00046 #spio.savemat('grasp_err_all_1.mat', data)
00047 


hrl_object_fetching
Author(s): Kelsey Hawkins. Advisor: Prof. Charlie Kemp. Healthcare Robotics Lab, Georgia Tech
autogenerated on Wed Nov 27 2013 11:33:13