rviz_joint_subscriber.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # coding: utf-8
3 
4 import rospy
5 import math
6 from sensor_msgs.msg import JointState
7 
8 
9 class RvizSlave:
10  def __init__(self):
11  self.sub = rospy.Subscriber("/raspigibbon/master_joint_state", JointState, self.joint_callback, queue_size=10)
12  self.pub = rospy.Publisher("joint_states_source", JointState, queue_size=10)
13  self.r = rospy.Rate(30)
14 
15  def joint_callback(self, msg):
16  js = JointState();
17  for i in range(1, 6):
18  js.name.append("joint"+str(i))
19  js.position.append(math.radians(msg.position[i-1]))
20  self.pub.publish(js)
21  self.r.sleep()
22 
23 if __name__ == "__main__":
24  try:
25  while not rospy.is_shutdown():
26  rospy.init_node("rviz_joint_state_subscriber")
27  rviz = RvizSlave()
28  rospy.spin()
29  except rospy.ROSInterruptException:
30  pass
31 


raspigibbon_bringup
Author(s): Daisuke Sato , Shota Hirama
autogenerated on Mon Jun 10 2019 14:27:11