Main Page
Namespaces
Classes
Files
File List
scripts
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
rviz_joint_subscriber.RvizSlave.__init__
def __init__(self)
Definition:
rviz_joint_subscriber.py:10
rviz_joint_subscriber.RvizSlave.pub
pub
Definition:
rviz_joint_subscriber.py:12
rviz_joint_subscriber.RvizSlave.r
r
Definition:
rviz_joint_subscriber.py:13
rviz_joint_subscriber.RvizSlave.joint_callback
def joint_callback(self, msg)
Definition:
rviz_joint_subscriber.py:15
rviz_joint_subscriber.RvizSlave
Definition:
rviz_joint_subscriber.py:9
rviz_joint_subscriber.RvizSlave.sub
sub
Definition:
rviz_joint_subscriber.py:11
raspigibbon_bringup
Author(s): Daisuke Sato
, Shota Hirama
autogenerated on Mon Jun 10 2019 14:27:11