Main Page
Namespaces
Classes
Files
File List
scripts
raspberrypigibbon_gazebo_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
from
std_msgs.msg
import
Float64
8
9
10
class
GazeboJoint
:
11
def
__init__
(self):
12
self.
sub
= rospy.Subscriber(
'/raspigibbon/master_joint_state'
, JointState, self.
joint_callback
, queue_size=10)
13
self.
pub
= {}
14
for
i
in
range(0,6):
15
self.
pub
[i] = rospy.Publisher(
'/raspigibbon_on_gazebo/joint_'
+ str(i + 1) +
'_position_controller/command'
, Float64, queue_size=10)
16
self.
r
= rospy.Rate(10)
17
18
def
joint_callback
(self, msg):
19
if
len(msg.position) > 0:
20
for
i
in
range(0,5):
21
self.
pub
[i].publish(math.radians(msg.position[i]))
22
self.
pub
[5].publish(math.radians(-msg.position[4]))
23
self.r.sleep()
24
25
if
__name__ ==
'__main__'
:
26
try
:
27
while
not
rospy.is_shutdown():
28
rospy.init_node(
'gazebo_joint_subscriber'
)
29
dummy =
GazeboJoint
()
30
rospy.spin()
31
except
rospy.ROSInterruptException:
32
pass
raspberrypigibbon_gazebo_joint_subscriber.GazeboJoint.joint_callback
def joint_callback(self, msg)
Definition:
raspberrypigibbon_gazebo_joint_subscriber.py:18
raspberrypigibbon_gazebo_joint_subscriber.GazeboJoint.pub
pub
Definition:
raspberrypigibbon_gazebo_joint_subscriber.py:13
raspberrypigibbon_gazebo_joint_subscriber.GazeboJoint.__init__
def __init__(self)
Definition:
raspberrypigibbon_gazebo_joint_subscriber.py:11
raspberrypigibbon_gazebo_joint_subscriber.GazeboJoint
Definition:
raspberrypigibbon_gazebo_joint_subscriber.py:10
raspberrypigibbon_gazebo_joint_subscriber.GazeboJoint.r
r
Definition:
raspberrypigibbon_gazebo_joint_subscriber.py:16
raspberrypigibbon_gazebo_joint_subscriber.GazeboJoint.sub
sub
Definition:
raspberrypigibbon_gazebo_joint_subscriber.py:12
raspigibbon_control
Author(s): Daisuke Sato
, Shota Hirama
autogenerated on Mon Jun 10 2019 14:31:55