slave_joint_state.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # coding: utf-8
3 
4 import rospy
5 from sensor_msgs.msg import JointState
6 from futaba_serial_servo import RS30X
7 
8 class Slave:
9  def __init__(self):
10  self.rs = RS30X.RS304MD()
11  self.sub = rospy.Subscriber("/raspigibbon/master_joint_state", JointState, self.joint_callback, queue_size=10)
12  for i in range(1,6):
13  self.rs.setTorque(i, True)
14  rospy.sleep(0.01)
15  print "init done"
16 
17  def joint_callback(self, msg):
18  for i in range(1, 6):
19  self.rs.setAngle(i, msg.position[i-1])
20  rospy.sleep(0.01)
21 
22 if __name__ == "__main__":
23  try:
24  while not rospy.is_shutdown():
25  rospy.init_node("slave_joint_state")
26  slave = Slave()
27  rospy.spin()
28  except rospy.ROSInterruptException:
29  pass
30 
def joint_callback(self, msg)


raspigibbon_master_slave
Author(s): Daisuke Sato , Shota Hirama
autogenerated on Mon Jun 10 2019 14:25:22