Exemplo n.º 1
0
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """

        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.collector = Collector(self)
        self.shooter = Shooter(self)
        self.pneumatics = Pneumatics(self)
        self.pivot = Pivot(self)
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.collector)
        wpilib.SmartDashboard.putData(self.shooter)
        wpilib.SmartDashboard.putData(self.pneumatics)
        wpilib.SmartDashboard.putData(self.pivot)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        #instantiate the command used for the autonomous period
        self.autoChooser = wpilib.SendableChooser()
        self.autoChooser.addDefault("Drive and Shoot", DriveAndShootAutonomous(self))
        self.autoChooser.addObject("Drive Forward", DriveForward(self))
        wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser)
        
        self.autonomousCommand = None

        # Pressurize the pneumatics
        self.pneumatics.start()
Exemplo n.º 2
0
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """
        # make this true to ignore joystick errors
        self.debug = False

        self.enabled_time = 0
        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.navigation = Navigation(self)
        self.pneumatics = Pneumatics(self)
        self.peripherals = Peripherals(self)
        #wpilib.SmartDashboard.putData(self.drivetrain)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        wpilib.SmartDashboard.putData(Scheduler.getInstance())
        # instantiate the command used for the autonomous period
        self.autonomousCommand = None
Exemplo n.º 3
0
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """

        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.collector = Collector(self)
        self.shooter = Shooter(self)
        self.pneumatics = Pneumatics(self)
        self.pivot = Pivot(self)
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.collector)
        wpilib.SmartDashboard.putData(self.shooter)
        wpilib.SmartDashboard.putData(self.pneumatics)
        wpilib.SmartDashboard.putData(self.pivot)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        #instantiate the command used for the autonomous period
        self.autoChooser = wpilib.SendableChooser()
        self.autoChooser.addDefault("Drive and Shoot",
                                    DriveAndShootAutonomous(self))
        self.autoChooser.addObject("Drive Forward", DriveForward(self))
        wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser)

        self.autonomousCommand = None

        # Pressurize the pneumatics
        self.pneumatics.start()
Exemplo n.º 4
0
    def __init__(self):
        self.timer = Timer()
        self.driver_station = DriverStation(controller=XboxController(0))

        # self.gyroscope = AHRS.create_i2c()

        # self.left_encoder = Encoder()
        # self.right_encoder = Encoder()

        self.drivetrain = TankDrivetrain(timer=self.timer, left_motors=[TalonSRX(10), TalonSRX(6)],
                                         right_motors=[TalonSRX(12), TalonSRX(18)])

        self.pneumatics = Pneumatics(compressor=Compressor(0), start_compressor=True, timer=self.timer)

        self.beak = BeakMechanism(beak_solenoid=DoubleSolenoid(0, 4, 5), diag_solenoid=DoubleSolenoid(0, 0, 1),
                                  driver_station=self.driver_station, timer=self.timer, cooldown=0.5)

        # self.odometry = EncoderOdometry(left_encoder=self.left_encoder, right_encoder=self.right_encoder, gyro=self.gyroscope)

        '''
Exemplo n.º 5
0
class Robot(wpilib.IterativeRobot):
    """This is the main class for running the PacGoat code."""
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """

        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.collector = Collector(self)
        self.shooter = Shooter(self)
        self.pneumatics = Pneumatics(self)
        self.pivot = Pivot(self)
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.collector)
        wpilib.SmartDashboard.putData(self.shooter)
        wpilib.SmartDashboard.putData(self.pneumatics)
        wpilib.SmartDashboard.putData(self.pivot)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        #instantiate the command used for the autonomous period
        self.autoChooser = wpilib.SendableChooser()
        self.autoChooser.addDefault("Drive and Shoot",
                                    DriveAndShootAutonomous(self))
        self.autoChooser.addObject("Drive Forward", DriveForward(self))
        wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser)

        self.autonomousCommand = None

        # Pressurize the pneumatics
        self.pneumatics.start()

    def autonomousInit(self):
        self.autonomousCommand = self.autoChooser.getSelected()
        self.autonomousCommand.start()

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

    def teleopInit(self):
        """This function is called at the beginning of operator control."""
        #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.
        if self.autonomousCommand is not None:
            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 disabledInit(self):
        self.shooter.unlatch()

    def disabledPeriodic(self):
        """This function is called periodically while disabled."""
        self.log()

    def log(self):
        self.pneumatics.writePressure()
        wpilib.SmartDashboard.putNumber("Pivot Pot Value",
                                        self.pivot.getAngle())
        wpilib.SmartDashboard.putNumber(
            "Left Distance",
            self.drivetrain.getLeftEncoder().getDistance())
        wpilib.SmartDashboard.putNumber(
            "Right Distance",
            self.drivetrain.getRightEncoder().getDistance())
Exemplo n.º 6
0
class Robot(wpilib.IterativeRobot):
    """This is the main class for running the PacGoat code."""
    
    def robotInit(self):
        """
        This function is run when the robot is first started up and should be
        used for any initialization code.
        """

        # Initialize the subsystems
        self.drivetrain = DriveTrain(self)
        self.collector = Collector(self)
        self.shooter = Shooter(self)
        self.pneumatics = Pneumatics(self)
        self.pivot = Pivot(self)
        wpilib.SmartDashboard.putData(self.drivetrain)
        wpilib.SmartDashboard.putData(self.collector)
        wpilib.SmartDashboard.putData(self.shooter)
        wpilib.SmartDashboard.putData(self.pneumatics)
        wpilib.SmartDashboard.putData(self.pivot)

        # This MUST be here. If the OI creates Commands (which it very likely
        # will), constructing it during the construction of CommandBase (from
        # which commands extend), subsystems are not guaranteed to be
        # yet. Thus, their requires() statements may grab null pointers. Bad
        # news. Don't move it.
        self.oi = OI(self)

        #instantiate the command used for the autonomous period
        self.autoChooser = wpilib.SendableChooser()
        self.autoChooser.addDefault("Drive and Shoot", DriveAndShootAutonomous(self))
        self.autoChooser.addObject("Drive Forward", DriveForward(self))
        wpilib.SmartDashboard.putData("Auto Mode", self.autoChooser)
        
        self.autonomousCommand = None

        # Pressurize the pneumatics
        self.pneumatics.start()

    def autonomousInit(self):
        self.autonomousCommand = self.autoChooser.getSelected()
        self.autonomousCommand.start()

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

    def teleopInit(self):
        """This function is called at the beginning of operator control."""
        #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.
        if self.autonomousCommand is not None:
            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 disabledInit(self):
        self.shooter.unlatch()

    def disabledPeriodic(self):
        """This function is called periodically while disabled."""
        self.log()

    def log(self):
        self.pneumatics.writePressure()
        wpilib.SmartDashboard.putNumber("Pivot Pot Value", self.pivot.getAngle())
        wpilib.SmartDashboard.putNumber("Left Distance", self.drivetrain.getLeftEncoder().getDistance())
        wpilib.SmartDashboard.putNumber("Right Distance", self.drivetrain.getRightEncoder().getDistance())
Exemplo n.º 7
0
    def __init__(self):
        Command.__init__(self, "SolenoidControl")

        self.pneumatic_subsystem = Pneumatics()
        self.piston = self.pneumatic_subsystem.dsolenoid
        self.sol_value = wpilib.DoubleSolenoid.Value