예제 #1
0
class OctoBot(wpilib.SampleRobot):

    #Initialise the robot.
    def robotInit(self):
        self.drivetrain = Drivetrain(self)
        self.oi = OI(self)
    
    def autonomous(self):
        while self.isAutonomous() and self.isEnabled():
            Scheduler.getInstance().run()
            self.log()
            wpilib.Timer.delay(.005)

    def operatorControl(self):
        joystick = self.oi.getStick()

        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005)

    def disabled(self):
        """Stuff to do whilst disabled."""

        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005)

    def test(self):
        """No tests"""
        pass

    def log(self):
        """It's big, it's heavy, it's wood."""
        self.drivetrain.log()
class DosPointOh(wpilib.SampleRobot):
    """Fluffy ears to scratch, lost his tail, cute little paws, likes to play fetch."""

    def robotInit(self):
        """Initialise the robot."""

        #Initialise the subsystems and the button mapping:
        self.drivetrain = Drivetrain(self)
        self.oi = OI(self)

        #Timeout value for the macros from the dashboard (default 15 sec).
        self.macroTimeout = self.oi.smart_dashboard.getInt("Macro", 15)
        Settings.num_macro_timeout = self.macroTimeout

    def autonomous(self):
        """Auton code."""

        #Logging loop
        while self.isAutonomous() and self.isEnabled():
            Scheduler.getInstance().run()
            self.log()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def operatorControl(self):
        """Teleop code."""
        #Make the joystick work for driving:
        joystick = self.oi.getStick()

        #Logging loop
        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def disabled(self):
        """Code to run when disabled."""

        #Stop the drivetrain for safety's sake:
        self.drivetrain.driveManual(0,0,0)

        #Logging loop
        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def test(self):
        """Code for testing."""
        pass

    def log(self):
        """I know it doesn't log but if it does eventually it'll go here."""
        #Log the things:
        self.drivetrain.log()
예제 #3
0
class Mantis(wpilib.SampleRobot):
    """Fluffy ears to scratch, lost his tail, cute little paws, likes to play fetch."""

    def robotInit(self):
        """Initialise the robot."""

        #Initialise the subsystems and the button mapping:
        self.drivetrain = Drivetrain(self)
        self.oi = OI(self)
        self.ears = Ears(self)

        #Timeout value for the macros from the dashboard (default 15 sec).
        self.macroTimeout = self.oi.smart_dashboard.getInt("Macro", 15)
        Settings.num_macro_timeout = self.macroTimeout

        #these are all actually really self explanatory. Wonder if they work.
    #    self.camera = wpilib.USBCamera()
    #    self.camera.setExposureManual(50)
    #    self.camera.setBrightness(80)
    #    self.camera.setFPS(30)
    #    self.camera.setSize(320, 240)
    #    self.camera.setWhiteBalanceAuto()
    #    self.camera.updateSettings() #update with the new settings so it actually does what we want it to

    #    server = wpilib.CameraServer.getInstance() #set up the camera server
    #    server.startAutomaticCapture(self.camera) #start the camera server

    def autonomous(self):
        """Auton code."""

        #Logging loop
        while self.isAutonomous() and self.isEnabled():
            Scheduler.getInstance().run()
            self.log()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def operatorControl(self):
        """Teleop code."""
        #Make the joystick work for driving:
        joystick = self.oi.getStick()

        #Logging loop
        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def disabled(self):
        """Code to run when disabled."""

        #Stop the drivetrain for safety's sake:
        self.drivetrain.driveManual(0,0, False, False)

        #Logging loop
        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def test(self):
        """Code for testing."""
        pass

    def log(self):
        """I know it doesn't log but if it does eventually it'll go here."""
        #Log the things:
        self.drivetrain.log()
예제 #4
0
class Mantis(wpilib.SampleRobot):
    """Fluffy ears to scratch, lost his tail, cute little paws, likes to play fetch."""

    def robotInit(self):
        """Initialise the robot."""

        #Initialise the subsystems and the button mapping:
        self.drivetrain = Drivetrain(self)
        self.ears = Ears(self)
        self.hat = Hat(self)
        self.tilt = Tilt(self)
        self.oi = OI(self)

        #Initialise the macro shenanigans (should probably clean this up once I get the dashboard sorted)
        self.macroTimeout = self.oi.smart_dashboard.getInt("Macro", 15)
        self.macroName = self.oi.smart_dashboard.getString("Macro Name", "macro.csv")
        Settings.str_macro_name = self.macroName
        Settings.num_macro_timeout = self.macroTimeout
        macro_string = str(Settings.num_macro_timeout)
        print("Robot initialized with a macro timeout of " + macro_string)
        self.simpleAutonCommand = PlayMacro(self, "macro.csv")
        self.shooterAutonCommand = PlayMacro(self, "macro_launch.csv")

    def autonomous(self):
        """Auton code."""

        print("Autonomous mode activated")
        try:
            if self.oi.smart_dashboard.getBoolean("Play Macro"):
                self.simpleAutonCommand.start()
            elif self.oi.smart_dashboard.getBoolean("Shoot"):
                self.shooterAutonCommand.start()
            else:
                print("No macro selected, waiting for teleop...")

        except KeyError:
                pass

        #Logging loop
        while self.isAutonomous() and self.isEnabled():
            Scheduler.getInstance().run()
            self.log()
            wpilib.Timer.delay(.05) #don't burn up the cpu

    def operatorControl(self):
        """Teleop code."""
        print("Teleop activated")
        self.simpleAutonCommand.cancel()
        self.shooterAutonCommand.cancel()
        #Make the joystick work for driving:
        joystick = self.oi.getStick()

        #Logging loop
        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.05) #don't burn up the cpu

    def disabled(self):
        """Code to run when disabled."""
        print("Robot disabled")

        #Stop the drivetrain for safety's sake:
        self.drivetrain.driveManual(0,0)
        self.hat.manualSet(0)
        self.ears.manualSet(0)
        self.tilt.manualSet(0)

        #Logging loop
        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.05) #don't burn up the cpu

    def test(self):
        """Code for testing."""
        print("Test mode activated")

    def log(self):
        """Log our subsystems."""
        self.drivetrain.log()
        self.ears.log()
        self.hat.log()
        self.tilt.log()
예제 #5
0
class Lopez_Jr(wpilib.SampleRobot):
    def robotInit(self):
        """Initialises 'bot w/ all subsystems (winch needs testing) and joysticks"""

        #Subsystem initialisation.  Woo.
        self.drivetrain = Drivetrain(self)
        self.lift = Lift(self)
        self.claw = Claw(self)
        self.mast = Mast(self)
        self.winch = Winch(self)
        self.oi = OI(self)

        #These are self-describing autonomouses. Waaaaaait... Autono-mouse?
        self.ThreeToteAutonomousCommand = ThreeToteAutonomous(self)
        self.CanAutonomousCommand = CanAutonomous(self)
        self.CanNToteAutoCommand = PlayMacro(self, "macro_1.csv")
        self.DriveAutonomousCommand = PlayMacro(self, "macro.csv")
        self.ToteAutonomousCommand = ToteAutonomous(self)
        self.PlayMacroCommand = PlayMacro(self, "autonomous.csv")

    def autonomous(self):
        """Woo, auton code w/ 3 modes. Needs to be tested."""
        #I'll probably change these out to different macro commands.
        self.drivetrain.drive.setSafetyEnabled(False)

        try:
            if self.oi.smart_dashboard.getBoolean("3 Tote Auto"):
                self.ThreeToteAutonomousCommand.start()
                print("3 Tote Auto started")

            elif self.oi.smart_dashboard.getBoolean("Can Auto"):
                self.CanAutonomousCommand.start()
                print("Can Auto started")

            elif self.oi.smart_dashboard.getBoolean("Can/Tote Auto"):
                self.CanNToteAutoCommand.start()
                print("Can and Tote Auto started")

            elif self.oi.smart_dashboard.getBoolean("Tote Auto"):
                self.ToteAutonomousCommand.start()
                print("Tote Auto started")

            elif self.oi.smart_dashboard.getBoolean("Play Macro"):
                self.PlayMacroCommand.start()
                print("Macro replay started")

            elif self.oi.smart_dashboard.getBoolean("Drive Auto"):
                self.DriveAutonomousCommand.start()
                print("Drive Auto started")

            else:
                pass

        except KeyError:
            self.PlayMacroCommand.start()
            #pass

        while self.isAutonomous() and self.isEnabled():
            Scheduler.getInstance().run()
            self.log()
            wpilib.Timer.delay(.005)  # don't burn up the cpu

    def operatorControl(self):
        """Runs the 'bot with the fancy joystick and an awesome gamepad THAT IS AWESOME."""

        #Cancel the autons - that could go badly otherwise.
        self.ThreeToteAutonomousCommand.cancel()
        self.CanAutonomousCommand.cancel()
        self.DriveAutonomousCommand.cancel()
        self.ToteAutonomousCommand.cancel()
        self.PlayMacroCommand.cancel()
        self.CanNToteAutoCommand.cancel()

        #More stuff.
        self.drivetrain.drive.setSafetyEnabled(True)
        joystick = self.oi.getJoystickLeft()

        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005)  # don't burn up the cpu

    def disabled(self):
        """Stuff to do when the 'bot is disabled"""

        #cancel the autons IN THE NAME OF SAFETY
        self.ThreeToteAutonomousCommand.cancel()
        self.CanAutonomousCommand.cancel()
        self.DriveAutonomousCommand.cancel()
        self.ToteAutonomousCommand.cancel()
        self.PlayMacroCommand.cancel()
        self.CanNToteAutoCommand.cancel()

        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005)

    def test(self):
        """There aren't any tests."""
        pass

    def log(self):
        """It's big, it's heavy, it's wood. Needs to be bigger."""
        self.drivetrain.log()
        self.lift.log()
        self.claw.log()
        self.mast.log()
        self.winch.log()