def __init__(self): self.button = OneShotButton(BUTTON_PIN, False, 0) if self.button.isPressed(): self.initialRun = "motionDemo" print("Running Motion Demo") else: self.initialRun = "walking" print("Running Walking") self.logger = Logger('logfile.txt') self.controller = BioloidController() self.setupServos() self.ikEngine = IKEngine() self.ikEngine.setController(self.controller) self.ikEngine.setLogger(self.logger) self.setupHeadPosition() self.ikEngine.setTransitionTime(TRANSITION_TIME) self.ikEngine.setupForWalk() self.debug = False self.frontRangeFinder = RangeFinder(FRONT_RANGE_PIN, RANGE_MAX) self.leftRangeFinder = RangeFinder(LEFT_RANGE_PIN, RANGE_MAX) self.rightRangeFinder = RangeFinder(RIGHT_RANGE_PIN, RANGE_MAX) self.readSensors() self.shutdown = False self.watchdogServoId = 1 self.heartbeat = HeartbeatLED(RED_LED) self.waitingForButtonState = State("waitingForButton", self.enterWaitingForButtonState, self.handleWaitingForButtonState, None) self.waitingForNoButtonState = State( "waitingForNoButton", self.enterWaitingForNoButtonState, self.handleWaitingForNoButtonState, None) self.walkingState = State("walking", self.enterWalkingState, self.handleWalkingState, None) self.obstacleAvoidanceState = State("obstacleAvoidance", self.enterObstacleAvoidanceState, self.handleObstacleAvoidanceState, None) self.obstacleAvoidanceScanState = State( "obstacleAvoidanceScan", self.enterObstacleAvoidanceScanState, self.handleObstacleAvoidanceScanState, None) self.obstacleAvoidanceContinueState = State( "obstacleAvoidanceContinue", self.enterObstacleAvoidanceContinueState, self.handleObstacleAvoidanceContinueState, None) self.motionDemoState = State("motionDemo", self.enterMotionDemoState, self.handleMotionDemoState, None) self.motionDemoXYState = State("motionXYDemo", self.enterMotionDemoXYState, self.handleMotionDemoXYState, None) self.shutdownState = State("shutdown", self.enterShutdownState, None, None) self.mainStateMachine = FiniteStateMachine(self.waitingForButtonState) self.watchdogState = State("watchdog", None, self.handleWatchdogState, None) self.watchdogWaitState = State("watchdog-wait", None, self.handleWatchdogWaitState, None) self.watchdogStateMachine = FiniteStateMachine(self.watchdogState)
def __init__(self, useLogger = False): self.id = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] self.pose = [512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512] self.nextPose = [512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512] self.speed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.interpolating = False self.playing = False self.servoCount = 12 self.lastFrame = pyb.millis() self.bus = UART_Bus(1, 1000000, show_packets=False) if useLogger: self.logger = Logger('sync_log.txt') else: self.logger = None
def __init__(self, useLogger=False): self.id = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] self.pose = [ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 ] self.nextPose = [ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512 ] self.speed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.interpolating = False self.playing = False self.servoCount = 12 self.lastFrame = pyb.millis() self.port = UART_Port(1, 1000000) self.bus = Bus(self.port, show=Bus.SHOW_PACKETS) # Bus.SHOW_NONE # Bus.SHOW_COMMANDS # Bus.SHOW_PACKETS if useLogger: self.logger = Logger('sync_log.txt') else: self.logger = None