pressure_writer.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib
00003 roslib.load_manifest('pr2_playpen')
00004 import rospy
00005 import hrl_pr2_lib.pressure_listener as pl
00006 import cPickle
00007 
00008 class PressureWriter:
00009 
00010     def __init__(self):
00011         rospy.init_node('pressure_writer')
00012         self.r_grip_press = pl.PressureListener(topic='/pressure/r_gripper_motor')
00013         self.l_grip_press = pl.PressureListener(topic='/pressure/l_gripper_motor')
00014         self.r_grip_data = []
00015         self.l_grip_data = []
00016         self.status = None
00017 
00018     def zero(self):
00019         self.r_grip_press.rezero()
00020         self.l_grip_press.rezero()
00021 
00022     def record_pressures(self, file_name, arm, time = 10:)
00023         file_handle = open(file_name, 'w')
00024         self.zero()
00025         start = rospy.get_time()
00026         #might be better to do some condition, like gripper not moving or when arm is moved to side
00027         #while rospy.get_time()-start < time:
00028         while not self.status == 'moving somewhere again':
00029             print "saving data now ..."
00030             self.r_grip_data.append(self.r_grip_press.get_pressure_readings())
00031             self.l_grip_data.append(self.l_grip_press.get_pressure_readings())
00032             rospy.sleep(0.05)
00033         cPickle.dump(data, file_handle)
00034         file_handle.close()
00035 
00036     def print_pressures(self):
00037         self.r_grip_press.rezero()
00038         right_tuple = self.r_grip_press.get_pressure_readings()
00039 #        print "here's the right gripper :\n", right_tuple
00040 #        print "here's the raw values : \n", self.r_grip_press.rmat_raw
00041 
00042     def status_callback(self, data):
00043         print "here is the status :", data
00044 #        self.status = data.feedback.state
00045         self.status = data
00046         
00047 if __name__ == '__main__':
00048     pw = PressureWriter()
00049     rospy.Subscriber('OverheadServer/actionlib/feedback/feedback/state', String, pw.status_callback)
00050 
00051     while not rospy.is_shutdown():
00052         if pw.status == 'closing gripper':
00053             pw.record_pressures('test_file', 0)
00054         rospy.sleep(0.02)
00055 


pr2_playpen
Author(s): Marc Killpack / mkillpack3@gatech.edu, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 12:18:32