def on_enter(self): self.send_packet(packets.ServoControl(*ARM_OPEN)) move = MoveLineTo(RED_START_X, MAMMOTH_HUNT_Y) yield move self.send_packet(packets.ServoControl(*ARM_CLOSE)) if move.exit_reason == TRAJECTORY_DESTINATION_REACHED: yield HuntTheMammoth() self.robot.goal_manager.update_goal_status("HuntTheMammoth", GOAL_DONE) yield None
def on_enter(self): for cmd in self.commands: actuator_typed_id = cmd[self.TYPED_ID] actuator_type = actuator_typed_id[self.TYPE] actuator_id = actuator_typed_id[self.ID] if actuator_type in [ ACTUATOR_TYPE_SERVO_AX, ACTUATOR_TYPE_SERVO_RX ]: servo_value = cmd[self.SERVO_VALUE] timeout_value = cmd[self.SERVO_TIMEOUT] logger.log("Trigger: set servo {} value: {} (tm: {})".format( SERVOS_IDS.lookup_by_value[actuator_typed_id], ALL_SERVO_COMMANDS[actuator_typed_id].get( servo_value, servo_value), timeout_value)) self.send_packet(packets.ServoControl(*cmd)) elif actuator_type == ACTUATOR_TYPE_OUTPUT: self.send_packet( packets.OutputControl(id=actuator_id, action=cmd[self.OUTPUT_ACTION])) elif actuator_type == ACTUATOR_TYPE_PWM: self.send_packet( packets.PwmControl(id=actuator_id, value=cmd[self.PWM_VALUE])) else: self.log_error( "Unknown actuator type in command: {}".format(cmd)) yield from self.cleanup(actuator_id)
def on_start(self, packet): self.event_loop.is_match_started = True self.yield_at(90000, EndOfMatch()) logger.log("Starting ...") #yield FirstHurryToTheOtherMammoth() self.send_packet(packets.ServoControl(*ARM_OPEN)) yield MoveLineTo(RED_START_X, 1.25) while True: yield ExecuteGoals() yield Timer(1000)
def on_enter(self): for cmd in self.commands: actuator_type = cmd[self.TYPE] if actuator_type in [ ACTUATOR_TYPE_SERVO_AX, ACTUATOR_TYPE_SERVO_RX ]: self.send_packet(packets.ServoControl(*cmd)) elif actuator_type == ACTUATOR_TYPE_RELAY: self.send_packet( packets.RelayToggle( id=cmd[self.ID], action=cmd[self.RELAY_ACTION], toggle_count=cmd[self.RELAY_TOGGLE_COUNT])) elif actuator_type == ACTUATOR_TYPE_PWM: self.send_packet( packets.PwmControl(id=cmd[self.ID], value=cmd[self.PWM_VALUE])) else: self.log("Unknown actuator type in command: {}".format(cmd))
def on_waypoint_reached(self, packet): cmd = self.commands.popleft() if cmd is not None: # Don't use Trigger as we won't wait for the confirmation self.send_packet(packets.ServoControl(*cmd)) self.handle_tree()
def on_enter(self): cmd = makeServoReadCommand((self.servo_id, 0)) self.send_packet(packets.ServoControl(*cmd))