Example #1
0
class Frobo(wpilib.IterativeRobot):
    """Control code for Frobo, the 2013 Competition Robot of FRC Team 2403 (Plasma Robotics)"""
    def robotInit(self):
        """Initialization method for the Frobo class.  Initializes objects needed elsewhere throughout the code."""

        # Initialize Joystick
        self.controller = Joystick(Values.CONTROLLER_ID)

        # Initialize Drive Sub-System
        self.drive = FroboDrive(self, Values.DRIVE_LEFT_MAIN_ID,
                                Values.DRIVE_LEFT_SLAVE_ID,
                                Values.DRIVE_RIGHT_MAIN_ID,
                                Values.DRIVE_RIGHT_SLAVE_ID)

        # Initialize Shooter Sub-System
        self.compressor = wpilib.Compressor()
        self.shooter = Shooter(self, Values.SHOOT_FRONT_ID,
                               Values.SHOOT_BACK_ID,
                               Values.SHOOT_SOLENOID_FORWARD_CHANNEL_ID,
                               Values.SHOOT_SOLENOID_REVERSE_CHANNEL_ID)

    def robotPeriodic(self):
        pass

    # DISABLED MODE

    def disabledInit(self):
        """Method ran when Frobo first enters the *disabled* mode."""
        self.shooter.disable()

    def disabledPeriodic(self):
        """Method that runs while Frobo is in the *disabled* mode."""
        pass

    # AUTONOMOUS MODE

    def autonomousInit(self):
        """Method ran when Frobo first enters the *autonomous* mode."""
        pass

    def autonomousPeriodic(self):
        """Method that runs while Frobo is in the *autonomous* mode."""
        pass

    # TELEOP MODE

    def teleopInit(self):
        """Method ran when Frobo first enters the *teleop* mode."""
        self.shooter.disable()

    def teleopPeriodic(self):
        """Method that runs while Frobo is in the *teleop* mode."""
        self.drive.fps(power_axis=self.controller.LEFTY,
                       turn_axis=self.controller.RIGHTX)
        self.shooter.update(self.controller)

    # TEST MODE

    def testInit(self):
        """Method ran when Frobo first enters the *test* mode."""
        self.shooter.disable()

    def testPeriodic(self):
        """Method that runs while Frobo is in the *test* mode."""
        self.shooter.update(self.controller)