35 import roslib; roslib.load_manifest(
'kobuki_testsuite')
38 from kobuki_msgs.msg
import ButtonEvent
39 from kobuki_msgs.msg
import BumperEvent
40 from kobuki_msgs.msg
import WheelDropEvent
41 from kobuki_msgs.msg
import CliffEvent
42 from kobuki_msgs.msg
import PowerSystemEvent
43 from kobuki_msgs.msg
import DigitalInputEvent
46 if ( data.state == ButtonEvent.RELEASED ) :
50 if ( data.button == ButtonEvent.Button0 ) :
52 elif ( data.button == ButtonEvent.Button1 ) :
56 rospy.loginfo(
"Button %s was %s."%(button, state))
59 if ( data.state == BumperEvent.RELEASED ) :
63 if ( data.bumper == BumperEvent.LEFT ) :
65 elif ( data.bumper == BumperEvent.CENTER ) :
69 rospy.loginfo(
"%s bumper is %s."%(bumper, state))
72 if ( data.state == WheelDropEvent.RAISED ) :
76 if ( data.wheel == WheelDropEvent.LEFT ) :
80 rospy.loginfo(
"%s wheel is %s."%(wheel, state))
83 if ( data.state == CliffEvent.FLOOR ) :
84 state =
"on the floor" 86 state =
"on the cliff" 87 if ( data.sensor == CliffEvent.LEFT ) :
89 elif ( data.sensor == CliffEvent.CENTER ) :
93 rospy.loginfo(
"%s side of robot is %s."%(cliff, state))
96 if ( data.event == PowerSystemEvent.UNPLUGGED ) :
97 rospy.loginfo(
"Robot unplugged")
98 elif ( data.event == PowerSystemEvent.PLUGGED_TO_ADAPTER ) :
99 rospy.loginfo(
"Robot plugged to adapter")
100 elif ( data.event == PowerSystemEvent.PLUGGED_TO_DOCKBASE ) :
101 rospy.loginfo(
"Robot plugged to docking base")
102 elif ( data.event == PowerSystemEvent.CHARGE_COMPLETED ) :
103 rospy.loginfo(
"Robot charge completed")
104 elif ( data.event == PowerSystemEvent.BATTERY_LOW ) :
105 rospy.loginfo(
"Robot battery low")
106 elif ( data.event == PowerSystemEvent.BATTERY_CRITICAL ) :
107 rospy.loginfo(
"Robot battery critical")
109 rospy.loginfo(
"WARN: Unexpected power system event: %d"%(data.event))
113 for val
in data.values:
114 val_str =
"%s, %s" % (val_str, str(val))
115 rospy.loginfo(
"Digital input values: [" + val_str[2:] +
"]")
117 rospy.init_node(
"test_events")
118 rospy.Subscriber(
"/mobile_base/events/button",ButtonEvent,ButtonEventCallback)
119 rospy.Subscriber(
"/mobile_base/events/bumper",BumperEvent,BumperEventCallback)
120 rospy.Subscriber(
"/mobile_base/events/wheel_drop",WheelDropEvent,WheelDropEventCallback)
121 rospy.Subscriber(
"/mobile_base/events/cliff",CliffEvent,CliffEventCallback)
122 rospy.Subscriber(
"/mobile_base/events/power_system",PowerSystemEvent,PowerEventCallback)
123 rospy.Subscriber(
"/mobile_base/events/digital_input",DigitalInputEvent,InputEventCallback)
125 print "Try kobuki's hardware components; the following events should be reported:" 128 print " - wheel drops" 130 print " - plug/unplug adapter" 131 print " - dock/undock on base" 132 print " - charge completed" 133 print " - battery low/critical" 134 print " - digital input changes" def ButtonEventCallback(data)
def CliffEventCallback(data)
def BumperEventCallback(data)
def PowerEventCallback(data)
def WheelDropEventCallback(data)
def InputEventCallback(data)