def execute(self): if "l" in self.modifiers or "left" in self.modifiers: self.pid = BasicMotion.closeLeftHand() elif "r" in self.modifiers or "right" in self.modifiers: self.pid = BasicMotion.closeRightHand() else: raise ParseError, "right/left expected"
def execute(self): if "l" in self.command: self.pid = BasicMotion.openLeftHand() elif "r" in self.command: self.pid = BasicMotion.openRightHand() else: raise ParseError, "right/left expected"
def execute(self): modifiers = self.command[len(Util.StringTokenizer(self.command).nextToken()):] if "l" in modifiers: self.pid = BasicMotion.unflexLeftArm() elif "r" in modifiers: self.pid = BasicMotion.unflexRightArm() else: raise ParseError, "right/left expected"
def execute(self): # TODO: Fix. if len(self.modifiers) < 1: raise ParseError, "distance expected" distance = float(self.modifiers[0]) if len(self.modifiers) == 1: self.pid = BasicMotion.slowStraightWalk(distance) else: gait = self.modifiers[1] if gait in ["slow", "slowly", "s"]: self.pid = BasicMotion.slowStraightWalk(distance) elif gait in ["fast", "f", "quick", "quickly", "q"]: self.pid = BasicMotion.fastStraightWalk(distance) else: print "Unsupport gait. Choose either slow, fast, or leave empty to default to slow."
def trigger(clazz, joystickStatus): global robotStatus if robotStatus == "turning left": BasicMotion.addTurn(1.0) else: if "walking" in robotStatus or "turning" in robotStatus: BasicMotion.stopWalking() BasicMotion.turn(1.0) robotStatus = "turning left"
def trigger(clazz, joystickStatus): global robotStatus if robotStatus == "walking backwards": BasicMotion.addWalkStraight(-0.1, 60) else: if "walking" in robotStatus or "turning" in robotStatus: BasicMotion.stopWalking() BasicMotion.slowStraightWalk(-1.0) robotStatus = "walking backwards"
def execute(self): if len(self.modifiers) == 0: BasicMotion.getUp() elif self.modifiers[0] == "front": BasicMotion.getUpFromFront() elif self.modifiers[0] == "back": BasicMotion.getUpFromBack() else: raise ParseError, self.command + " accepts the following modifiers: front/back."
def execute(self): self.pid = BasicMotion.initPosition()
def execute(self): if len(self.modifiers) < 1: raise ParseError, "how much should I turn?" self.pid = BasicMotion.turn(self.modifiers[0])
def wait(self): BasicMotion.wait(self.pid)
def execute(self): BasicMotion.stopWalking()
def execute(self): BasicMotion.killAllTasks()
def trigger(clazz, joystickStatus): global robotStatus # BasicMotion.clearPendingTasks() BasicMotion.getUp() robotStatus = "getting up"
def execute(self): self.pid = BasicMotion.setStiffness(0.0)
def trigger(clazz, joystickStatus): global robotStatus if "walking" in robotStatus or "turning" in robotStatus: BasicMotion.stopWalking() robotStatus = "at rest"
def execute(self): if len(self.modifiers) < 2: raise ParseError, "coordinates expected" x = self.modifiers[0] y = self.modifiers[1] self.pid = BasicMotion.moveHead(x, y)
def execute(self): self.pid = BasicMotion.zeroPosition()
from burst import burst_exceptions from burst.burst_exceptions import * #import Util # TODO: If running on the robot, user 127.0.0.1 as the address? 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."
def trigger(clazz, joystickStatus): global robotStatus if "walking" in robotStatus or "turning" in robotStatus: BasicMotion.stopWalking() robotStatus = "exiting" raise QuitException