Go to the documentation of this file.00001
00002
00003 import roslib; roslib.load_manifest('rosserial_adk_demo')
00004 import rospy
00005
00006 from geometry_msgs.msg import Twist
00007 from sensor_msgs.msg import Joy
00008
00009 def deadband(val, dead_band):
00010 if ( val < dead_band) and (val > -dead_band):
00011 val = 0
00012 if (val > 1):
00013 val = 1
00014 if (val < -1):
00015 val = -1
00016 return val
00017
00018 if __name__ == '__main__':
00019 rospy.init_node('adk_joystick')
00020
00021 pub = rospy.Publisher("cmd_vel", Twist)
00022 x, t = 0, 0
00023 def joy_cb(msg):
00024 x += deadband(msg.axes[0], 0.25)
00025 t += deadband(msg.axes[1], 0.25)*0.5;
00026 x /=2
00027 t /=2
00028 cmd.linear.x = x
00029 cmd.angular.z = t;
00030 pub.publish(cmd)
00031
00032 sub = rospy.Subscriber("joy", Joy, joy_cb);
00033
00034 rospy.spin()
00035
00036