示例#1
0
class MyRobot(wpilib.TimedRobot):
    def robotInit(self):
        """This function is run when the robot is first started up and should be
        used for any initialization code."""

        self.drivetrain = DriveTrain(self)
        self.elevator = Elevator(self)
        self.wrist = Wrist(self)
        self.claw = Claw()
        self.oi = OI(self)

        # instantiate the command used for the autonomous period
        self.autonomousCommand = Autonomous(self)

        # Show what command your subsystem is running on the SmartDashboard
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.elevator)
        wpilib.SmartDashboard.putData(self.wrist)
        wpilib.SmartDashboard.putData(self.claw)

        wpilib.LiveWindow.getInstance().setEnabled(True)

    def autonomousInit(self):
        # schedule the autonomous command (example)
        self.autonomousCommand.start()

    def autonomousPeriodic(self):
        """This function is called periodically during autonomous"""
        Scheduler.getInstance().run()
        self.log()

    def teleopInit(self):
        # This makes sure that the autonomous stops running when
        # teleop starts running. If you want the autonomous to
        # continue until interrupted by another command, remove
        # this line or comment it out.
        self.autonomousCommand.cancel()

    def teleopPeriodic(self):
        """This function is called periodically during operator control"""
        Scheduler.getInstance().run()
        self.log()

    def testPeriodic(self):
        """This function is called periodically during test mode"""
        wpilib.LiveWindow.getInstance().updateValues()

    def log(self):
        """The log method puts interesting information to the SmartDashboard."""
        self.wrist.log()
        self.elevator.log()
        self.drivetrain.log()
        self.claw.log()
示例#2
0
class MyRobot(wpilib.IterativeRobot):
    
    def robotInit(self):
        '''This function is run when the robot is first started up and should be
           used for any initialization code.'''
        
        self.drivetrain = DriveTrain(self)
        self.elevator = Elevator(self)
        self.wrist = Wrist(self)
        self.claw = Claw()
        self.oi = OI(self)
        
        # instantiate the command used for the autonomous period
        self.autonomousCommand = Autonomous(self)
        
        # Show what command your subsystem is running on the SmartDashboard
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.elevator)
        wpilib.SmartDashboard.putData(self.wrist)
        wpilib.SmartDashboard.putData(self.claw)
        
    def autonomousInit(self):
        # schedule the autonomous command (example)
        self.autonomousCommand.start()
        
    def autonomousPeriodic(self):
        '''This function is called periodically during autonomous'''
        Scheduler.getInstance().run()
        self.log()
        
    def teleopInit(self):
        # This makes sure that the autonomous stops running when
        # teleop starts running. If you want the autonomous to 
        # continue until interrupted by another command, remove
        # this line or comment it out.
        self.autonomousCommand.cancel()
    
    def teleopPeriodic(self):
        '''This function is called periodically during operator control'''
        Scheduler.getInstance().run()
        self.log()
        
    def testPeriodic(self):
        '''This function is called periodically during test mode'''
        wpilib.LiveWindow.run()
        
    def log(self):
        '''The log method puts interesting information to the SmartDashboard.'''
        self.wrist.log()
        self.elevator.log()
        self.drivetrain.log()
        self.claw.log()
示例#3
0
    def robotInit(self):
        """This function is run when the robot is first started up and should be
           used for any initialization code."""

        self.drivetrain = DriveTrain(self)
        self.elevator = Elevator(self)
        self.wrist = Wrist(self)
        self.claw = Claw()
        self.oi = OI(self)

        # instantiate the command used for the autonomous period
        self.autonomousCommand = Autonomous(self)

        # Show what command your subsystem is running on the SmartDashboard
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.elevator)
        wpilib.SmartDashboard.putData(self.wrist)
        wpilib.SmartDashboard.putData(self.claw)
示例#4
0
    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")
示例#5
0
 def robotInit(self):
     '''Initialize all subsystems.'''
     self.drivetrain = DriveTrain(self)
     self.puncher = Puncher()
     self.claw = Claw()
     self.arm = Arm()
     self.intake = Intake()
     self.elevator = Elevator()
     self.hatch = Hatch()
     self.intake_winch = IntakeWinch()
     self.oi = OI(self)
示例#6
0
 def robotInit(self):
     '''This function is run when the robot is first started up and should be
        used for any initialization code.'''
     
     self.drivetrain = DriveTrain(self)
     self.elevator = Elevator(self)
     self.wrist = Wrist(self)
     self.claw = Claw()
     self.oi = OI(self)
     
     # instantiate the command used for the autonomous period
     self.autonomousCommand = Autonomous(self)
     
     # Show what command your subsystem is running on the SmartDashboard
     wpilib.SmartDashboard.putData(self.drivetrain)
     wpilib.SmartDashboard.putData(self.elevator)
     wpilib.SmartDashboard.putData(self.wrist)
     wpilib.SmartDashboard.putData(self.claw)
示例#7
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()