5 imp.find_module(
"geometry_msgs")
7 import roslib; roslib.load_manifest(
'jsk_teleop_joy')
10 from geometry_msgs.msg
import Twist
22 JSKJoyPlugin.__init__(self, name, args)
30 self.
twist_pub = rospy.Publisher(self.
getArg(
'cmd_vel',
'cmd_vel'), Twist, queue_size = 1)
32 def joyCB(self, status, history):
33 if history.length() > 0:
34 latest = history.latest()
35 if status.R3
and status.L2
and status.R2
and not (latest.R3
and latest.L2
and latest.R2):
36 self.followView(
not self.followView())
41 dist = numpy.sqrt(status.left_analog_y * status.left_analog_y + status.left_analog_x * status.left_analog_x)
44 if abs(status.left_analog_y) - abs(status.left_analog_x) > 0.2:
45 x_diff = status.left_analog_y * scale_v
47 elif abs(status.left_analog_y) - abs(status.left_analog_x) < -0.2:
49 y_diff = status.left_analog_x * scale_v
54 x_diff = status.left_analog_y * scale_v
55 y_diff = status.left_analog_x * scale_v
60 cmd_vel.linear.x = x_diff
61 cmd_vel.linear.y = y_diff
62 cmd_vel.linear.z = 0.0
71 cmd_vel.angular.x = 0.0
72 cmd_vel.angular.y = 0.0
73 cmd_vel.angular.z = dyaw
77 now = rospy.Time.from_sec(time.time())
79 if (now - self.
prev_time).to_sec() > 1 / 30.0:
def __init__(self, name, args)
def joyCB(self, status, history)
def getArg(self, key, default=None)