def initialize(self): """Called before the Command is run for the first time.""" # Get initial position current = self.robot.drivetrain.get_gyro_angle() # Calculate and store target self._target_degrees = current + self._degrees_change return Command.initialize(self)
def initialize(self): """Called before the Command is run for the first time.""" # Get initial position current = self.robot.drivetrain.get_encoder_value() # Calculate and store target self._target_position = current + self._encoder_change return Command.initialize(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" speed = self._speed time_left = self._duration - self._stopwatch.elapsed_time_in_secs() if (time_left < self._ramp_threshold): speed = speed * time_left / self._ramp_threshold self.robot.drivetrain.arcade_drive(speed, 0.0) return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" dpad_y = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.DPADY) if dpad_y != 0.0: self.robot.drivetrain.arcade_drive(self.DPAD_LINEAR_SPEED * dpad_y, 0.0) else: left_track = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.LEFTY) right_track = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.RIGHTY) self.robot.drivetrain.tankDrive(left_track, right_track) return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" current = self.robot.drivetrain.get_gyro_angle() degrees_left = self._target_degrees - current if degrees_left >= 0: direction = 1.0 else: direction = -1.0 turn_speed = self._speed * direction # Set drivetrain using speed and direction self.robot.drivetrain.arcade_drive(0.0, turn_speed, False) return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" # Get encoder count current = self.robot.drivetrain.get_encoder_value() distance_left = self._target_position - current # Determine direction using target and current encoder values if distance_left >= 0: direction = -1.0 else: direction = 1.0 linear_drive_amount = self._speed * direction # Set drivetrain using speed and direction self.robot.drivetrain.arcade_drive(linear_drive_amount, 0.0, False) return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" modifier = self.robot.oi.get_button_state(UserController.DRIVER, JoystickButtons.RIGHTTRIGGER) dpad_y = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.DPADY) if dpad_y != 0.0: self.robot.drivetrain.arcade_drive(self._dpad_scaling * dpad_y, 0.0) else: left_track = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.LEFTY) right_track = self.robot.oi.get_axis(UserController.DRIVER, JoystickAxis.RIGHTY) if modifier: self.robot.drivetrain.tank_drive(self._stick_scaling * left_track, self._stick_scaling * right_track) else: self.robot.drivetrain.tank_drive(left_track, right_track) return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" current = self.robot.drivetrain.get_gyro_angle() degrees_left = self._target_degrees - current if (degrees_left) >= 0: direction = 1.0 else: direction = -1.0 turn_speed = self._speed * direction if degrees_left < self._ramp_threshold: turn_speed = turn_speed * (degrees_left) / self._ramp_threshold # Set drivetrain using speed and direction self.robot.drivetrain.arcade_drive(0.0, turn_speed) return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" # Get encoder count current = self.robot.drivetrain.get_encoder_value() distance_left = self._target_position - current # Determine direction using target and current encoder values if (distance_left) >= 0: direction = 1.0 else: direction = -1.0 linear_drive_amount = self._speed * direction if (distance_left < self._ramp_threshold): linear_drive_amount = linear_drive_amount * (distance_left) / self._ramp_threshold # Set drivetrain using speed and direction self.robot.drivetrain.arcade_drive(linear_drive_amount, 0.0) return Command.execute(self)
def initialize(self): Command.getRobot().intakeOutput.panelPlace( IntakeOutput.PanelPutOrTake.PUT)
def initialize(self): """Called before the Command is run for the first time.""" # Start stopwatch self._stopwatch.start() return Command.initialize(self)
def __init__(self): super().__init__(name=self.__class__, subsystem=Command.getRobot().liftElevator)
def condition(self): return Command.getRobot( ).intakeOutput.mode == IntakeOutput.BallOrHatchMode.BALL
def __init__(self, power): super().__init__(name="Move {}".format(power), subsystem=Command.getRobot().drivetrain) self.power = power
def initialize(self): Command.getRobot().drivetrain.set(ControlMode.PercentOutput, self.power, self.power)
def execute(self): """Called repeatedly when this Command is scheduled to run""" return Command.execute(self)
def execute(self): """Called repeatedly when this Command is scheduled to run""" speed = self._speed self.robot.drivetrain.arcade_drive(speed, 0.0, False) return Command.execute(self)
def __init__(self, position): super().__init__(name="ActivateArms {}".format(position), subsystem=Command.getRobot().intakeOutput) self.position = position
def initialize(self): Command.getRobot().intakeOutput.setPosition(self.position)
def initialize(self): Command.getRobot().intakeOutput.giveOrTakeCargo(self.key)
def __init__(self, key): super().__init__(name="InhaleExhale {}".format(key), subsystem=Command.getRobot().intakeOutput) self.key = key
def __init__(self, mode): super().__init__(name="SetObjectMode", subsystem=Command.getRobot().intakeOutput) self.mode = mode self.logger = logging.getLogger(self.getName())
def initialize(self): """Called before the Command is run for the first time.""" return Command.initialize(self)
def __init__(self): super().__init__(subsystem=Command.getRobot().liftElevator)
def end(self): Command.getRobot().drivetrain.set(ControlMode.PercentOutput, 0.0, 0.0)
def initialize(self): Command.getRobot().liftElevator.setElevatorReference(6.5)
def initialize(self): Command.getRobot().liftElevator.liftDrive(self.power)
def initialize(self): Command.getRobot().liftElevator.resetEncoders()
def end(self): Command.getRobot().liftElevator.liftDrive(0.0)
def __init__(self, power): super().__init__(name="LiftDrive {}".format(power), subsystem=Command.getRobot().liftElevator) self.power = power
def initialize(self): if self.mode == IntakeOutput.IntakeInOutNeutral.NEUTRAL: self.logger.info("NEUTRAL") Command.getRobot().intakeOutput.setArmPower(0.0) Command.getRobot().intakeOutput.setPosition(IntakeOutput.Position.UP) elif self.mode == IntakeOutput.IntakeInOutNeutral.IN: self.logger.info("IN") Command.getRobot().intakeOutput.setArmPower(0.5) Command.getRobot().intakeOutput.setPosition(IntakeOutput.Position.DOWN) elif self.mode == IntakeOutput.IntakeInOutNeutral.OUT: self.logger.info("OUT") Command.getRobot().intakeOutput.setArmPower(-1.0) Command.getRobot().intakeOutput.setPosition(IntakeOutput.Position.DOWN)
def initialize(self): Command.getRobot().intakeOutput.panelPlace( IntakeOutput.PanelPutOrTake.TAKE) Command.getRobot().intakeOutput.mode = self.mode
def __init__(self): super().__init__(subsystem=Command.getRobot().intakeOutput)
def __init__(self): # Create Joysticks self.stick = Joystick(0) self.gamepad = Joystick(1) # Create Buttons self.trigger = JoystickButton(self.stick, 1) self.button2 = JoystickButton(self.stick, 2) self.button3 = JoystickButton(self.stick, 3) self.button4 = JoystickButton(self.stick, 4) self.button5 = JoystickButton(self.stick, 5) self.button6 = JoystickButton(self.stick, 6) self.button7 = JoystickButton(self.stick, 7) self.button8 = JoystickButton(self.stick, 8) self.button9 = JoystickButton(self.stick, 9) self.button10 = JoystickButton(self.stick, 10) self.button11 = JoystickButton(self.stick, 11) self.pad1 = JoystickButton(self.gamepad, 1) self.pad2 = JoystickButton(self.gamepad, 2) self.pad3 = JoystickButton(self.gamepad, 3) self.pad4 = JoystickButton(self.gamepad, 4) self.pad5 = JoystickButton(self.gamepad, 5) self.pad6 = JoystickButton(self.gamepad, 6) self.pad7 = JoystickButton(self.gamepad, 7) self.pad8 = JoystickButton(self.gamepad, 8) self.pad9 = JoystickButton(self.gamepad, 9) self.climb2 = ComboButton(self.pad6, self.button6) self.climb3 = ComboButton(self.pad5, self.button6) # Test buttons self.test = ComboButton(self.pad2, self.button6) # Command hookups self.trigger.whenPressed(Intake()) self.trigger.whenReleased(NeutralIntake()) # self.button2.whileHeld(Align(3.0)) self.button8.whenPressed( type( '', (InstantCommand, ), { 'initialize': lambda: Command.getRobot().liftElevator.resetEncoders() })) self.pad1.whenPressed(SetObjectMode( IntakeOutput.BallOrHatchMode.HATCH)) self.pad1.whenReleased(SetObjectMode( IntakeOutput.BallOrHatchMode.BALL)) Command.getRobot().intakeOutput.mode = IntakeOutput.BallOrHatchMode.HATCH if \ self.pad1.get() else IntakeOutput.BallOrHatchMode.HATCH self.test.whenPressed(TopConditional()) self.pad3.whenPressed(MiddleConditional()) self.pad4.whenPressed(LowConditional()) self.climb2.whenPressed(TwoClimbG()) self.climb3.whenPressed(OneClimbG()) self.pad7.whenPressed(MoveElevator(1)) self.pad8.whenPressed(HighCenter())