arm_controller.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib; roslib.load_manifest('kobuki_ros_node')
00003 import rospy
00004 
00005 from kobuki_msgs.msg import SensorData
00006 #from standard_comms.msg import Float32ArrayStamped #standard_comms are deprecated!
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         #rospy.loginfo("[" + rospy.get_name() + "] received")
00013         #print data.header_id
00014         #for i in range(len(data.current)):
00015         #       print "data " + repr(i) + ":" + repr(ord(data.current[i]))
00016 
00017         button_pressed = data.data # Test
00018         #button_pressed = data.remote # Actual
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         #msg = Float32ArrayStamped()
00035         #msg.header = data.header
00036         #msg.data.append(25 * float(ord(data.current[0])))
00037         #msg.data.append(25 * float(ord(data.current[1])))
00038         pub.publish(msg)
00039 
00040 def relay():
00041         rospy.init_node('kobukibot_arm_control')
00042         rospy.Subscriber('button_data_in', UInt8, callback)  # For Test
00043         #rospy.Subscriber('button_data_in', SensorData, callback) # Actual Topic
00044         rospy.spin()
00045 
00046 if __name__ == '__main__':
00047         try:
00048                 relay()
00049         except rospy.ROSInterruptException: pass
00050 


kobuki_arm
Author(s): Daniel Stonier
autogenerated on Mon Oct 6 2014 01:31:32