Ejemplo n.º 1
0
        protected override void Main()
        {
            while (true)
            {
                DriveTrain.TankDrive(-DriveStick_Left.GetRawAxis(1), -DriveStick_Right.GetRawAxis(1));

                if ((DriveStick_Left.GetRawAxis(1) < -0.1 || DriveStick_Right.GetRawAxis(1) < -0.1) && !Custom_Board.GetRawButton(4))
                {
                    Intake1.Set(-1);
                    Intake2.Set(-1);
                }

                else
                {
                    Intake1.Set(0);
                    Intake2.Set(0);
                }

                if (Custom_Board.GetRawButton(4))
                {
                    Shooter.Set(.9);
                    Agitator.Set(1);
                }

                else
                {
                    Shooter.Set(0);
                    Agitator.Set(0);
                }

                if (DriveStick_Left.GetRawButton(1) || DriveStick_Right.GetRawButton(1))
                {
                    if (flag)
                    {
                        Shifters.Set(!Shifters.Get());

                        flag = false;
                    }
                }

                else
                {
                    flag = true;
                }
                if (DriveStick_Left.GetRawAxis(2) > 0.1)
                {
                    PTO.Set(true);
                }

                else
                {
                    PTO.Set(false);
                }

                Shooter_Pivot.Set(.5 * Custom_Board.GetRawAxis(4));

                Snooze(10);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs the auto handler.
        /// </summary>
        protected override void Main()
        {
            Right1.SetEncoderPostition(0); // Reset the encoder position to 0.
            Left1.SetEncoderPostition(0);  // Reset the eoncoder position to 0.
            // Runs the selected autonomous.
            //AutoHandler.RunAuto(Handler.AutoPosition.Disabled);
            // Both down. 0b00
            if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5)
            {
                SmartConsole.PrintInfo("Currently running disabled autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                AutoHandler.RunAuto(Handler.AutoPosition.Disabled);
            }
            // Left stick down, right stick up. 0b01
            else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5)
            {
                SmartConsole.PrintInfo("Currently running position 1 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                AutoHandler.RunAuto(Handler.AutoPosition.Position1);
            }
            // Left stick up, right stick down. 0b10
            else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5)
            {
                SmartConsole.PrintInfo("Currently running position 2 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                AutoHandler.RunAuto(Handler.AutoPosition.Position2);

                /*DriveTrain.Move(.65, .70);
                 *
                 * Snooze(2500);
                 *
                 * DriveTrain.StopMotor();
                 *
                 * GearSlot.Set(true);
                 *
                 * while (true) Snooze(1);*/
            }
            // Left stick up, right stick up. 0b11
            else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5)
            {
                SmartConsole.PrintInfo("Currently running position 3 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                AutoHandler.RunAuto(Handler.AutoPosition.Position3);
            }
        }
Ejemplo n.º 3
0
        protected override void Main()
        {
#if DEBUG
            SmartConsole.PrintWarning("Robot running in debug mode.");
#endif

            Handler.AutoPosition position = Handler.AutoPosition.Disabled;

            while (true)
            {
                // Both down. 0b00
                if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5)
                {
                    if (!a0)
                    {
                        SmartConsole.PrintInfo("Currently running disabled autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                        position = Handler.AutoPosition.Disabled;
                        //AutoHandler.RunAuto(Handler.AutoPosition.Disabled);
                        a0 = true;
                        a1 = false;
                        a2 = false;
                        a3 = false;
                    }
                }
                // Left stick down, right stick up. 0b01
                else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5)
                {
                    if (!a1)
                    {
                        SmartConsole.PrintInfo("Currently running side gear (positon 1) autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                        position = Handler.AutoPosition.Position1;
                        //AutoHandler.RunAuto(Handler.AutoPosition.Position1);
                        a0 = false;
                        a1 = true;
                        a2 = false;
                        a3 = false;
                    }
                }
                // Left stick up, right stick down. 0b10
                else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5)
                {
                    if (!a2)
                    {
                        SmartConsole.PrintInfo("Currently running center gear (positon 2) autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                        position = Handler.AutoPosition.Position2;
                        //AutoHandler.RunAuto(Handler.AutoPosition.Position2);
                        a0 = false;
                        a1 = false;
                        a2 = true;
                        a3 = false;
                    }
                }
                // Left stick up, right stick up. 0b11
                else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && position != Handler.AutoPosition.Position3)
                {
                    if (!a3)
                    {
                        SmartConsole.PrintInfo("Currently running position 3 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance.");
                        position = Handler.AutoPosition.Position3;
                        //AutoHandler.RunAuto(Handler.AutoPosition.Position3);
                        a0 = false;
                        a1 = false;
                        a2 = false;
                        a3 = true;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected override void Main()
        {
            while (true)
            {
                if (Custom_Board.GetRawAxis(2) > 0.1)
                {
                    Intake1.Set(-1);
                    Intake2.Set(1);
                }

                else if (DriveStick_Right.GetRawButton(3) || Custom_Board.GetRawAxis(3) > 0.1)
                {
                    Intake1.Set(1);
                    Intake2.Set(-1);
                }

                else
                {
                    Intake1.Set(0);
                    Intake2.Set(0);
                }

                if (Custom_Board.GetRawButton(3))
                {
                    if (started)
                    {
                        if ((Environment.TickCount - time) > 1000)
                        {
                            Agitator.Set(1);
                            IntakeSecondStage.Set(-1);
                        }
                    }

                    else
                    {
                        time    = Environment.TickCount;
                        started = true;
                        Shooter.Set(.95);
                    }
                }

                else if (Custom_Board.GetRawButton(2))
                {
                    if (started)
                    {
                        if ((Environment.TickCount - time) > 1000)
                        {
                            Agitator.Set(-1);
                            IntakeSecondStage.Set(-1);
                        }
                    }

                    else
                    {
                        time    = Environment.TickCount;
                        started = true;
                        Shooter.Set(.95);
                    }
                }

                else
                {
                    Shooter.Set(0);
                    Agitator.Set(0);
                    IntakeSecondStage.Set(0);
                    started = false;
                }

                if (DriveStick_Left.GetRawButton(1) || DriveStick_Right.GetRawButton(1))
                {
                    if (toggleshift)
                    {
                        Shifters.Set(!Shifters.Get());

                        toggleshift = false;
                    }
                }

                else
                {
                    toggleshift = true;
                }

                if (DriveStick_Left.GetRawButton(6) && DriveStick_Right.GetRawButton(11))
                {
                    if (togglepto)
                    {
                        PTO.Set(!PTO.Get());

                        togglepto = false;
                    }
                }

                else
                {
                    togglepto = true;
                }

                if (PTO.Get())
                {
                    if (DriveStick_Right.GetRawAxis(1) >= 0)
                    {
                        DriveTrain.StopMotor();
                    }
                    else
                    {
                        DriveTrain.Move(DriveStick_Right.GetRawAxis(1), DriveStick_Right.GetRawAxis(1));
                    }
                }
                else
                {
                    DriveTrain.Move(-DriveStick_Left.GetRawAxis(1), -DriveStick_Right.GetRawAxis(1));
                }

                if (Custom_Board.GetRawButton(4))
                {
                    GearSlot.Set(true);
                }
                else
                {
                    GearSlot.Set(false);
                }

                //if (DriveStick_Left.GetRawAxis(2) > 0.1) PTO.Set(true);
                //else PTO.Set(false);

                // Set the shooter pivot to a specific point based on the joysticks.
                //TurntableController.Controller.Setpoint = ((encoderTicks + Custom_Board.GetRawAxis(4)) / 2);
                Shooter_Pivot.Set(.5 * Custom_Board.GetRawAxis(4));

                Snooze(10);
            }
        }