get_joint_states.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import rospy
00003 from sensor_msgs.msg import JointState
00004 from sr_utilities.srv import getJointState
00005 import thread
00006 
00007 RATE = 100
00008 
00009 class GetJointState(object):
00010     def __init__(self):
00011         rospy.init_node('get_joint_state_service', anonymous=True)
00012 
00013         self.subs_1 = rospy.Subscriber("/joint_states", JointState, self.callback1)
00014         self.serv = rospy.Service('/getJointState', getJointState, self.getJointStateCB)
00015 
00016         self.joint_state_msg = JointState()
00017 
00018         self.mutex = thread.allocate_lock()
00019 
00020         r = rospy.Rate(RATE)
00021         while not rospy.is_shutdown():
00022             r.sleep()
00023 
00024     def callback1(self, data):
00025         self.joint_state_msg = data
00026 
00027     def getJointStateCB(self,req):
00028         res = self.joint_state_msg
00029         return res
00030 
00031 if __name__ == '__main__':
00032     service = GetJointState()


sr_utilities
Author(s): Ugo Cupcic
autogenerated on Fri Aug 21 2015 12:24:47