Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('kobuki_ros_node')
00003 import rospy
00004
00005 from kobuki_msgs.msg import SensorData
00006
00007 from std_msgs.msg import Float64
00008 from std_msgs.msg import UInt8
00009
00010 def callback(data):
00011 pub = rospy.Publisher('arm_control_out', Float64)
00012
00013
00014
00015
00016
00017 button_pressed = data.data
00018
00019 processed = False
00020 if button_pressed & 1 :
00021 print "button 1 pressed."
00022 processed = True
00023 if button_pressed & 2 :
00024 print "button 2 pressed."
00025 processed = True
00026 if button_pressed & 4 :
00027 print "button 3 pressed."
00028 processed = True
00029 if processed == False:
00030 print "none."
00031
00032 msg = Float64()
00033 msg.data = 2*float(button_pressed)
00034
00035
00036
00037
00038 pub.publish(msg)
00039
00040 def relay():
00041 rospy.init_node('kobukibot_arm_control')
00042 rospy.Subscriber('button_data_in', UInt8, callback)
00043
00044 rospy.spin()
00045
00046 if __name__ == '__main__':
00047 try:
00048 relay()
00049 except rospy.ROSInterruptException: pass
00050