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 import roslib; roslib.load_manifest('force_torque')
00034 import rospy
00035 from hrl_msgs.msg import FloatArray
00036
00037
00038 import AMTIForce2 as af
00039
00040 import threading
00041 import time
00042
00043
00044
00045 class AMTIForceServer(threading.Thread):
00046 def __init__(self, device_path, str_id):
00047 threading.Thread.__init__(self)
00048 try:
00049 rospy.init_node('AMTIForceServer')
00050 print 'AMTIForceServer: ros is up!'
00051 except rospy.ROSException:
00052 pass
00053 print 'AMTIForceServer: connecting to', device_path
00054 self.force_plate = af.AMTI_force(device_path)
00055
00056 name = 'force_torque_' + str_id
00057 print 'AMTIForceServer: publishing', name, 'with type FloatArray'
00058 self.channel = rospy.Publisher(name, FloatArray, tcp_nodelay=True)
00059
00060 def broadcast(self):
00061 print 'AMTIForceServer: started!'
00062 while not rospy.is_shutdown():
00063 time.sleep(1/5000.0)
00064 self.channel.publish(FloatArray(None, self.force_plate.read().T.tolist()[0]))
00065
00066
00067
00068
00069
00070
00071
00072 if __name__ == '__main__':
00073 import optparse
00074 p = optparse.OptionParser()
00075 p.add_option('--path', action='store', default='/dev/robot/force_plate0', type = 'string',
00076 dest='path', help='path to force torque device in (linux)')
00077 p.add_option('--name', action='store', default='ft1', type='string',
00078 dest='name', help='name given to FTSensor')
00079 opt, args = p.parse_args()
00080
00081 server = AMTIForceServer(opt.path, opt.name)
00082 server.broadcast()
00083
00084
force_torque
Author(s): Advait Jain, Cressel Anderson, Hai Nguyen, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:58:12