get_joint_states.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import rospy
3 from sensor_msgs.msg import JointState
4 from sr_utilities.srv import getJointState
5 import thread
6 
7 RATE = 100
8 
9 
10 class GetJointState(object):
11  def __init__(self):
12  rospy.init_node('get_joint_state_service', anonymous=True)
13 
14  self.subs_1 = rospy.Subscriber("/joint_states", JointState, self.callback1)
15  self.serv = rospy.Service('/getJointState', getJointState, self.getJointStateCB)
16 
17  self.joint_state_msg = JointState()
18 
19  self.mutex = thread.allocate_lock()
20 
21  r = rospy.Rate(RATE)
22  while not rospy.is_shutdown():
23  r.sleep()
24 
25  def callback1(self, data):
26  self.joint_state_msg = data
27 
28  def getJointStateCB(self, req):
29  res = self.joint_state_msg
30  return res
31 
32 if __name__ == '__main__':
33  service = GetJointState()


sr_utilities
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:55:49