Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 from threading import RLock
00034 
00035 import roslib
00036 roslib.load_manifest('zenither')
00037 import zenither_config as zc
00038 import rospy
00039 from hrl_srvs.srv import Float_Int
00040 from hrl_msgs.msg import FloatArray
00041 
00042 
00043 
00044 class ZenitherClient():
00045     def __init__(self, robot):
00046         try:
00047             rospy.init_node('ZenitherClient')
00048             rospy.logout('ZenitherServer: Initialized Node')
00049         except rospy.ROSException:
00050             pass
00051 
00052         if robot not in zc.calib:
00053             raise RuntimeError('unknown robot')
00054         self.calib = zc.calib[robot]
00055 
00056         srv = '/zenither/move_position'
00057         rospy.wait_for_service(srv)
00058         self.move_position = rospy.ServiceProxy(srv, Float_Int)
00059         
00060         srv = '/zenither/stop'
00061         rospy.wait_for_service(srv)
00062         self.stop = rospy.ServiceProxy(srv, Float_Int)
00063         
00064         srv = '/zenither/apply_torque'
00065         rospy.wait_for_service(srv)
00066         self.apply_torque = rospy.ServiceProxy(srv, Float_Int)
00067 
00068         srv = '/zenither/torque_move_position'
00069         rospy.wait_for_service(srv)
00070         self.torque_move_position = rospy.ServiceProxy(srv, Float_Int)
00071 
00072         zenither_pose_topic = 'zenither_pose'
00073         self.h = None
00074         self.lock = RLock()
00075         rospy.Subscriber(zenither_pose_topic, FloatArray, self.pose_cb)
00076         
00077     
00078     def estop(self):
00079         self.stop(0)
00080 
00081     def zenith(self, torque=None):
00082         if torque == None:
00083             torque=self.calib['zenith_torque']
00084         self.apply_torque(torque)
00085 
00086     def nadir(self, torque=None):
00087         if torque == None:
00088             torque=self.calib['nadir_torque']
00089         self.apply_torque(torque)
00090 
00091 
00092     
00093     def pose_cb(self, fa):
00094         self.lock.acquire()
00095         self.h = fa.data[0]
00096         self.lock.release()
00097 
00098     
00099     def height(self):
00100         self.lock.acquire()
00101         h = self.h
00102         self.lock.release()
00103         return h
00104 
00105 
00106 
00107 if __name__ == '__main__':
00108     import time
00109 
00110     cl = ZenitherClient('HRL2')
00111 
00112     cl.zenith()
00113     time.sleep(0.5)
00114     cl.estop()
00115 
00116 
 
zenither
Author(s): Cressel Anderson, Advait Jain, Hai Nguyen, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:54:59