37 import roslib; roslib.load_manifest(
'kobuki_testsuite')
39 import sys, select, termios, tty
41 from datetime
import datetime
43 from kobuki_msgs.msg
import DigitalOutput, Led, Sound
47 tty.setraw(sys.stdin.fileno())
48 rlist, _, _ = select.select([sys.stdin], [], [], 0.1)
50 key = sys.stdin.read(1)
58 sys.stdout.write(
'\r ')
59 for idx
in range(0,4):
61 sys.stdout.write(
'[ \033[1mOn\033[0m] ')
63 sys.stdout.write(
'[Off] ')
64 sys.stdout.write(
'| [\033[1m'+textBindings[leds[0].value]+
'\033[0m] ')
65 sys.stdout.write(
'[\033[1m'+textBindings[leds[1].value]+
'\033[0m] | ')
67 for idx
in range(0,4):
69 sys.stdout.write(
'[ \033[1mOn\033[0m] ')
71 sys.stdout.write(
'[Off] ')
73 sys.stdout.write(
'\r')
101 'x':Sound.CLEANINGSTART,
102 'c':Sound.CLEANINGEND,
106 Led.GREEN:Led.ORANGE,
120 settings = termios.tcgetattr(sys.stdin)
123 sys.stdout.write(
'\n\r')
125 termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
128 rospy.init_node(
"test_output")
129 rospy.on_shutdown(clearing)
130 rate = rospy.Rate(10)
132 pub_ext_pwr = rospy.Publisher(
'/mobile_base/commands/external_power',DigitalOutput)
133 pub_dgt_out = rospy.Publisher(
'/mobile_base/commands/digital_output',DigitalOutput)
135 pub.append(rospy.Publisher(
'/mobile_base/commands/led1',Led))
136 pub.append(rospy.Publisher(
'/mobile_base/commands/led2',Led))
137 pub_sounds = rospy.Publisher(
'/mobile_base/commands/sound',Sound)
140 external_power = DigitalOutput()
141 external_power.values = [
True,
True,
True,
True ]
142 external_power.mask = [
True,
True,
True,
True ]
144 digital_output = DigitalOutput()
145 digital_output.values = [
True,
True,
True,
True ]
146 digital_output.mask = [
True,
True,
True,
True ]
151 leds[0].value = Led.GREEN
152 leds[1].value = Led.GREEN
155 while not pub_ext_pwr.get_num_connections():
157 pub_ext_pwr.publish(external_power)
159 while not pub_dgt_out.get_num_connections():
161 pub_dgt_out.publish(digital_output)
163 while not pub[0].get_num_connections():
167 while not pub[1].get_num_connections():
173 print "Control Every Output of Kobuki" 174 print "------------------------------" 175 print "1: Toggle the state of 3.3V" 176 print "2: Toggle the state of 5V" 177 print "3: Toggle the state of 12V5A(arm)" 178 print "4: Toggle the state of 12V1A(kinect)" 180 print "5: Control Led #1" 181 print "6: Control Led #2" 183 print "7~0: Toggle the state of DigitalOut_0~3" 187 print "a: On s: Off d: Recharge f: Button z: Error x: CleaningStart c: CleaningEnd" 192 print " 3.3V 5.0V 12V5A 12V1A | Led #1 Led #2 | DO_0 DO_1 DO_2 DO_3" 195 while not rospy.is_shutdown():
196 printStatus(external_power.values, digital_output.values, leds)
198 if key ==
'':
continue 199 if key ==
'q' or key ==
'Q':
200 rospy.signal_shutdown(
'user reuest')
202 elif key
in keyBindings1.keys():
203 external_power.values[keyBindings1[key]] ^=
True 204 printStatus(external_power.values, digital_output.values, leds)
205 pub_ext_pwr.publish(external_power)
207 elif key
in keyBindings3.keys():
208 digital_output.values[keyBindings3[key]] ^=
True 209 printStatus(external_power.values, digital_output.values, leds)
210 pub_dgt_out.publish(digital_output)
212 elif key
in keyBindings2.keys():
213 leds[keyBindings2[key]].value = colorBindings[ leds[keyBindings2[key]].value ]
214 printStatus(external_power.values, digital_output.values, leds)
215 pub[keyBindings2[key]].
publish(leds[keyBindings2[key]])
216 elif key
in keyBindings4.keys():
217 pub_sounds.publish(keyBindings4[key])
def printStatus(ext_values, dgt_values, leds)