Main Page
Namespaces
Classes
Files
File List
scripts
raspigibbon_joint_subscriber.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
9
class
Slave
:
10
def
__init__
(self):
11
self.
rs
= RS30X.RS304MD()
12
self.
sub
= rospy.Subscriber(
"{0}master_joint_state"
.format(rospy.get_namespace()), JointState, self.
joint_callback
, queue_size=10)
13
self.
r
= rospy.Rate(30)
14
for
i
in
range(1,6):
15
self.rs.setTorque(i,
True
)
16
rospy.sleep(0.01)
17
rospy.loginfo(
"servo initialized"
)
18
19
def
joint_callback
(self, msg):
20
if
len(msg.position) > 0:
21
for
i
in
range(1, 6):
22
self.rs.setAngle(i, msg.position[i-1])
23
self.r.sleep()
24
25
if
__name__ ==
"__main__"
:
26
try
:
27
while
not
rospy.is_shutdown():
28
rospy.init_node(
"slave_joint_state"
)
29
slave =
Slave
()
30
rospy.spin()
31
except
rospy.ROSInterruptException:
32
pass
33
raspigibbon_joint_subscriber.Slave.__init__
def __init__(self)
Definition:
raspigibbon_joint_subscriber.py:10
raspigibbon_joint_subscriber.Slave.r
r
Definition:
raspigibbon_joint_subscriber.py:13
raspigibbon_joint_subscriber.Slave.rs
rs
Definition:
raspigibbon_joint_subscriber.py:11
raspigibbon_joint_subscriber.Slave
Definition:
raspigibbon_joint_subscriber.py:9
raspigibbon_joint_subscriber.Slave.joint_callback
def joint_callback(self, msg)
Definition:
raspigibbon_joint_subscriber.py:19
raspigibbon_joint_subscriber.Slave.sub
sub
Definition:
raspigibbon_joint_subscriber.py:12
raspigibbon_bringup
Author(s): Daisuke Sato
, Shota Hirama
autogenerated on Mon Jun 10 2019 14:27:11