FRC Driver Station Test Program

This is another resource that I’ve created for the Kwarqs FIRST Robotics team this season that I’ve found useful, and hopefully others will find it useful as well.

This particular program is stupidly simple, but really nice to have around in case you think your driver station is being screwy, or you want to verify that your switches work *before* running your actual code on it (not that you would run something without testing it, right? 😉 ). As you can see from the code, it displays the driver station inputs on the LCD panel of the driver station. It uses a modified version of the DriverStationLCD class posted at http://thinktank.wpi.edu/article/144

#include "WPILib.h"
#include "DriverStationLCD.h"

class RobotDemo : public SimpleRobot
{
public:
    RobotDemo(void)
    {
        GetWatchdog().SetExpiration(0.1);
    }

    void OperatorControl(void)
    {
        double tm = GetTime();

        GetWatchdog().SetEnabled(true);
        while (IsOperatorControl())
        {
            GetWatchdog().Feed();

            if (GetTime() - tm > 0.1)
            {
                DriverStationLCD * lcd = DriverStationLCD::GetInstance();

                lcd->PrintfLine(DriverStationLCD::kMain_Line6, "Press select button");

                lcd->PrintfLine(DriverStationLCD::kUser_Line2,
                        "%d %d %d %d %d %d %d %d",
                        (int)m_ds->GetDigitalIn(1),
                        (int)m_ds->GetDigitalIn(2),
                        (int)m_ds->GetDigitalIn(3),
                        (int)m_ds->GetDigitalIn(4),
                        (int)m_ds->GetDigitalIn(5),
                        (int)m_ds->GetDigitalIn(6),
                        (int)m_ds->GetDigitalIn(7),
                        (int)m_ds->GetDigitalIn(8)
                );        

                lcd->PrintfLine(DriverStationLCD::kUser_Line3, "1: %.1f",
                        m_ds->GetAnalogIn(1));
                lcd->PrintfLine(DriverStationLCD::kUser_Line4, "2: %.1f",
                        m_ds->GetAnalogIn(2));
                lcd->PrintfLine(DriverStationLCD::kUser_Line5, "3: %.1f",
                        m_ds->GetAnalogIn(3));
                lcd->PrintfLine(DriverStationLCD::kUser_Line6, "4: %.1f",
                        m_ds->GetAnalogIn(4));

                lcd->UpdateLCD();

                tm = GetTime();
            }
        }
    }
};

START_ROBOT_CLASS(RobotDemo);

Download the full project here

Leave a Reply