예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
 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)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 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)
예제 #11
0
 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)
예제 #12
0
 def initialize(self):
     Command.getRobot().intakeOutput.panelPlace(
         IntakeOutput.PanelPutOrTake.PUT)
예제 #13
0
 def initialize(self):
     """Called before the Command is run for the first time."""
     # Start stopwatch
     self._stopwatch.start()
     return Command.initialize(self)
예제 #14
0
 def __init__(self):
     super().__init__(name=self.__class__,
                      subsystem=Command.getRobot().liftElevator)
예제 #15
0
 def condition(self):
     return Command.getRobot(
     ).intakeOutput.mode == IntakeOutput.BallOrHatchMode.BALL
예제 #16
0
 def __init__(self, power):
     super().__init__(name="Move {}".format(power),
                      subsystem=Command.getRobot().drivetrain)
     self.power = power
예제 #17
0
 def initialize(self):
     Command.getRobot().drivetrain.set(ControlMode.PercentOutput,
                                       self.power, self.power)
예제 #18
0
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     return Command.execute(self)
예제 #19
0
 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)
예제 #20
0
 def initialize(self):
     """Called before the Command is run for the first time."""
     # Start stopwatch
     self._stopwatch.start()
     return Command.initialize(self)
예제 #21
0
 def __init__(self, position):
     super().__init__(name="ActivateArms {}".format(position),
                      subsystem=Command.getRobot().intakeOutput)
     self.position = position
예제 #22
0
 def initialize(self):
     Command.getRobot().intakeOutput.setPosition(self.position)
예제 #23
0
 def initialize(self):
     Command.getRobot().intakeOutput.giveOrTakeCargo(self.key)
예제 #24
0
 def __init__(self, key):
     super().__init__(name="InhaleExhale {}".format(key),
                      subsystem=Command.getRobot().intakeOutput)
     self.key = key
예제 #25
0
 def __init__(self, mode):
     super().__init__(name="SetObjectMode",
                      subsystem=Command.getRobot().intakeOutput)
     self.mode = mode
     self.logger = logging.getLogger(self.getName())
예제 #26
0
 def initialize(self):
     """Called before the Command is run for the first time."""
     return Command.initialize(self)
예제 #27
0
 def __init__(self):
     super().__init__(subsystem=Command.getRobot().liftElevator)
예제 #28
0
 def end(self):
     Command.getRobot().drivetrain.set(ControlMode.PercentOutput, 0.0, 0.0)
예제 #29
0
 def initialize(self):
     Command.getRobot().liftElevator.setElevatorReference(6.5)
예제 #30
0
 def execute(self):
     """Called repeatedly when this Command is scheduled to run"""
     return Command.execute(self)
예제 #31
0
 def initialize(self):
     Command.getRobot().liftElevator.liftDrive(self.power)
예제 #32
0
 def initialize(self):
     Command.getRobot().liftElevator.resetEncoders()
예제 #33
0
 def end(self):
     Command.getRobot().liftElevator.liftDrive(0.0)
예제 #34
0
 def initialize(self):
     """Called before the Command is run for the first time."""
     return Command.initialize(self)
예제 #35
0
 def __init__(self, power):
     super().__init__(name="LiftDrive {}".format(power),
                      subsystem=Command.getRobot().liftElevator)
     self.power = power
예제 #36
0
 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)
예제 #37
0
 def initialize(self):
     Command.getRobot().intakeOutput.panelPlace(
         IntakeOutput.PanelPutOrTake.TAKE)
     Command.getRobot().intakeOutput.mode = self.mode
예제 #38
0
 def __init__(self):
     super().__init__(subsystem=Command.getRobot().intakeOutput)
예제 #39
0
파일: oi.py 프로젝트: bullbots/DeepSpacePy
    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())