Main Page
Namespaces
Classes
Files
File List
scripts
raspigibbon_joint_publisher.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
Master
:
10
def
__init__
(self):
11
self.
rs
= RS30X.RS304MD()
12
self.
pub
= rospy.Publisher(
"master_joint_state"
, JointState, queue_size=10)
13
self.
r
= rospy.Rate(30)
14
for
i
in
range(1,6):
15
self.rs.setTorque(i,
False
)
16
rospy.sleep(0.01)
17
rospy.loginfo(
"servo initialized"
)
18
19
def
run
(self):
20
while
not
rospy.is_shutdown():
21
js = JointState()
22
js.name=[
"joint{}"
.format(i)
for
i
in
range(1,6)]
23
js.position = [max(-150,min(150,self.rs.readAngle(i)))
for
i
in
range(1,6)]
24
self.pub.publish(js)
25
self.r.sleep()
26
27
if
__name__ ==
"__main__"
:
28
rospy.init_node(
"master_joint_state"
)
29
master =
Master
()
30
master.run()
raspigibbon_joint_publisher.Master.rs
rs
Definition:
raspigibbon_joint_publisher.py:11
raspigibbon_joint_publisher.Master.pub
pub
Definition:
raspigibbon_joint_publisher.py:12
raspigibbon_joint_publisher.Master.run
def run(self)
Definition:
raspigibbon_joint_publisher.py:19
raspigibbon_joint_publisher.Master
Definition:
raspigibbon_joint_publisher.py:9
raspigibbon_joint_publisher.Master.r
r
Definition:
raspigibbon_joint_publisher.py:13
raspigibbon_joint_publisher.Master.__init__
def __init__(self)
Definition:
raspigibbon_joint_publisher.py:10
raspigibbon_bringup
Author(s): Daisuke Sato
, Shota Hirama
autogenerated on Mon Jun 10 2019 14:27:11