Exemple #1
0
        // This autonomous (along with the sendable chooser above) shows how to select between
        // different autonomous modes using the dashboard. The senable chooser code works with
        // the Java SmartDashboard. If you prefer the LabVIEW Dashboard, remove all the chooser
        // code an uncomment the GetString code to get the uto name from the text box below
        // the gyro.
        //You can add additional auto modes by adding additional comparisons to the switch
        // structure below with additional strings. If using the SendableChooser
        // be sure to add them to the chooser code above as well.
        public override void AutonomousInit()
        {
            autoSelected = (string)chooser.GetSelected();
            autoSelected = SmartDashboard.GetString("Auto Selector", defaultAuto);
            Console.WriteLine("Auto selected: " + autoSelected);
            time           = new System.Timers.Timer(50);
            time.AutoReset = true;
            elapsed        = false;
            time.Elapsed  += TimeAlert;
            time.Start();

            /* WPILib.Buttons.InternalButton button = new WPILib.Buttons.InternalButton();
             * if (button.Get())
             * {
             *   char AutoMode = 'a';
             *   //a = left
             *   //b = mid
             *   //c = right;
             * } */
        }
Exemple #2
0
        /// <summary>
        /// This function is called periodically during test mode
        /// </summary>
        public override void TestPeriodic()
        {
            time.Stop();
            elapsedTimes = 0;
            if (elapsed)
            {
                if (stick.GetRawButton(1))
                {
                    SmartDashboard.PutString("DB/String 3", SmartDashboard.GetString("DB/String 3", "") + char.ToString('a'));
                    //Console.WriteLine('a');
                    testTime.Stop();
                    testTime.Start();
                    flag = 'a';
                    drive.TankDrive(-.6, -.6);
                }
                else if (stick.GetRawButton(2))
                {
                    SmartDashboard.PutString("DB/String 3", SmartDashboard.GetString("DB/String 3", "") + char.ToString('b'));
                    //Console.WriteLine('b');
                    testTime.Stop();
                    testTime.Start();
                    flag = 'b';
                    drive.TankDrive(.6, .6);
                }
                else if (stick.GetRawButton(3))
                {
                    SmartDashboard.PutString("DB/String 3", SmartDashboard.GetString("DB/String 3", "") + char.ToString('x'));
                    //Console.WriteLine('x');
                    testTime.Stop();
                    testTime.Start();
                    flag = 'x';
                    drive.TankDrive(.6, -.6);
                }
                else if (stick.GetRawButton(4))
                {
                    SmartDashboard.PutString("DB/String 3", SmartDashboard.GetString("DB/String 3", "") + char.ToString('y'));
                    //Console.WriteLine('y');
                    testTime.Stop();
                    testTime.Start();
                    flag = 'y';
                    drive.TankDrive(-.6, .6);
                }
                else
                {
                    drive.TankDrive(0f, 0f);
                }
            }

            else
            {
                if (flag == 'a')
                {
                    drive.TankDrive(-.6, -.6);
                }
                else if (flag == 'b')
                {
                    drive.TankDrive(.6, .6);
                }

                else if (flag == 'x')
                {
                    drive.TankDrive(.6, -.6);
                }
                else if (flag == 'y')
                {
                    drive.TankDrive(-.6, .6);
                }
            }
        }