Main Page
Namespaces
Classes
Files
File List
scripts
rviz_joint_publisher.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
RvizMaster
:
10
def
__init__
(self):
11
self.
sub
= rospy.Subscriber(
"/raspigibbon_on_rviz/joint_states"
, JointState, self.
joint_callback
, queue_size=10)
12
self.
pub
= rospy.Publisher(
"master_joint_state"
, JointState, queue_size=10)
13
self.
r
= rospy.Rate(40)
14
15
def
joint_callback
(self, msg):
16
js = JointState();
17
if
len(msg.position) > 0:
18
js.name = [
"joint{}"
.format(i)
for
i
in
range(1, 6)]
19
js.position = [max(-150, min(150, math.degrees(msg.position[i])))
for
i
in
range(0, 5)]
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_publisher"
)
27
rviz =
RvizMaster
()
28
rospy.spin()
29
except
rospy.ROSInterruptException:
30
pass
31
rviz_joint_publisher.RvizMaster.r
r
Definition:
rviz_joint_publisher.py:13
rviz_joint_publisher.RvizMaster.pub
pub
Definition:
rviz_joint_publisher.py:12
rviz_joint_publisher.RvizMaster.joint_callback
def joint_callback(self, msg)
Definition:
rviz_joint_publisher.py:15
rviz_joint_publisher.RvizMaster
Definition:
rviz_joint_publisher.py:9
rviz_joint_publisher.RvizMaster.__init__
def __init__(self)
Definition:
rviz_joint_publisher.py:10
rviz_joint_publisher.RvizMaster.sub
sub
Definition:
rviz_joint_publisher.py:11
raspigibbon_bringup
Author(s): Daisuke Sato
, Shota Hirama
autogenerated on Mon Jun 10 2019 14:27:11