def run(): global robotStatus robotStatus = "at rest" joystick = JoystickWrapper(0,1) burst.init() while True: joystickStatus = joystick.getStatus() try: for command in Registrat.registered: if command.isTriggeredBy(joystickStatus, robotStatus): command.trigger(joystickStatus) break except QuitException: break time.sleep(0.001) # In either case, go to sleep for a while, so it's not THAT bad of a busy-wait. burst.shutdown()
burst.init() print "Controlling the robot at " + burst.ip + ":" + str(burst.port) import BasicMotion # Let the user choose an action, perform that action, repeat. import Commands from Commands import * BasicMotion.headStiffnessOff() try: while True: selection = raw_input("> ") try: x = Commands.CommandParser.parse(selection) x.execute() except UnsupportedCommand, e: print "Error: Unsupported command (" + str(e) + ")." except ParseError, e: print "Error: Could not parse the command (" + str(e) + ")." except NotLyingDownException, e: print "Not lying down." except UnsafeToGetUpException, e: print "It's not safe to get up - the robot is probably lying on its side." except TerminateSignal: pass burst.shutdown()