The DriverStationDisplay is a program we wrote and a protocol we invented to provide a means for us to create custom GUIs on a Driver Station dashboard while making it extremely easy to support multiple FRC robots at once.
If one is building on Windows, we recommend using the MSYS2 compiler. The following libraries are required as dependencies and should be installed using either your package manager of choice or MSYS2's pacman:
- GCC 7 or newer for some C++17 features
- Qt 5
For MSYS2, use the MINGW64 terminal for building and install the following packages:
- mingw-w64-x86_64-gcc
- mingw-w64-x86_64-qt5
To build the project, first run qmake dir
within a terminal from the desired build directory, where "dir" is the relative location of the DriverStationDisplay.pro file. This will generate three makefiles. If a debug build is desired, run make -f Makefile.Debug
. The default behavior when simply running make
is to perform a release build.
To cross-compile from Linux to Windows:
- Install the MinGW-w64 toolchain (
mingw-w64-gcc
) - Install a MinGW-w64 build of Qt 5 (
mingw-w64-qt5-base
) - Run
publish-linux2win32.sh
to create a .zip of the application binary and necessary files
To compile natively on windows:
- Open MSYS64 terminal provided by MSYS2
- Install
mingw-w64-x86_64-gcc
,mingw-w64-x86_64-qt5
, andzip
- Run
publish-msys2win32.sh
to create a .zip of the application binary and necessary files
To use this program with a new robot, copy the DSDisplay folder in the host folder into the source tree and #include DSDisplay.hpp.
A GUISettings.txt file should be placed in /home/lvuser
on the roboRIO. Its contents inform the DriverStationDisplay what GUI elements it should create. The format of this file will be described later.
Since this project was designed to link to libstdc++ and libgcc statically, DriverStationDisplay.exe and IPSettings.txt are the only required files on the Driver Station.
The required entries in IPSettings.txt are as follows:
IP address of the MJPEG stream to display in the DriverStationDisplay
Port from which the MJPEG stream is served
Path to the MJPEG stream at the given IP address
Note: If any one of these settings is incorrect, no MJPEG stream will be displayed, but the rest of the DriverStationDisplay will work.
Port to which to send ALF commands, such as "reboot" or "reload"
Port on which the DriverStationDisplay receives data from the robot
Robot's IP address
Port to which to send connection packets and autonomous mode selections
streamHost = 10.35.12.11
streamPort = 80
streamRequestPath = /mjpg/video.mjpg
alfCmdPort = 3512
#the DS binds to this
dsDataPort = 1130
#the DS sends to this
robotIP = 10.35.12.2
robotDataPort = 1130
- Call DriverStationDisplay::GetInstance() to create an instance of this class
- The argument to GetInstance() should be the port specified as "dsDataPort" in IPSettings.txt
- Call Clear() to empty the internal packet
- If Clear() isn't called first, undefined behavior may result. (The header "display\r\n" isn't inserted when the packet isn't empty.)
- Call AddData() as many times as necessary to add HUD data.
- Call SendToDS() to send the data to the DriverStationDisplay.
- It doesn't matter in which order the data is packed before sending the data.
- The packets are always sent to 10.35.12.42 for testing purposes.
- Besides the test IP, only one client can be connected to the host at a time.
The DriverStationDisplay supports selection of an autonomous mode without needing to rebuild code or reboot the roboRIO. To leverage this functionality, the appropriate autonomous functions must be made available to the DriverStationDisplay.
Add the appropriate autonomous functions to the list available on the DriverStationDisplay
Erases the current list of autonomous functions stored
Executes the currently selected autonomous routine
- Call this in the Autonomous() function of the Simple Robot Template
`[Element name] [ID string 1],[ID string 2] [Column] ["Start text"] ["Update text"]`
This represents the name of the GUI element to create on the display. The possible types at this time are:
- TEXT
- STATUSLIGHT
- PBAR
Every GUI element declaration must have at least one ID string. This may be any combination of characters that doesn't contain a newline (\n), a carriage return (\r), or a space.
GUI elements may have more than one ID string to represent parts of the element which may be manipulated. PBAR is an example of one.
This may be one of two values: "left" or "right" (no quotes). It determines which side on which to place the GUI element in the DriverStationDisplay's window.
Note: The first element in the column will be placed at the top of the window with the rest placed below it in descending order of declaration. The DriverStationDisplay handles vertical spacing between the different elements automatically as they stack up.
This will be the text intially used by the GUI element from its creation until it receives new data, at which point the "Replacement Text" will be used instead.
After new data has arrived for the GUI element, this string will be used to update the element's text. When updating, all instances of %s
will be replaced with the received data as a string. All other instances of %
are ignored.
The start text and replacement text both support Unicode character insertions while still only transferring an ASCII text file. If one puts a "\uXXXX" in either "Start Text" or "Replacement Text", where XXXX is the UTF-16 identifier of the character, it will be converted to its Unicode equivalent before being displayed. It's especially useful for displaying symbols like the degrees sign and others which would otherwise be unavailable.
Gyro: 0\u00b0
becomes
Gyro: 0º
Warning: The identifiers must belong to UTF-16 because Windows wide strings use UTF-16.
This element displays a line of text.
This element displays a line of text next to an indicator light. The indicator will be green, yellow, or red depending on the value sent in association with "ID String".
Green 0
Yellow 1
Red 2
Warning: "Replacement Text" isn't used with this type.
This element displays a progress bar with a line of text below it.
- [Value ID] refers to the value which replaces %s in "Initial Text" and "Replacement Text"
- [Bar Fill ID] refers to the value which determines the percentage from 0 to 100
GUISettings.txt from https://github.com/Team3512/Robot-2013
TEXT MODE left "Mode: Unknown" "Mode: %s"
TEXT GYRO_VAL left "Gyro: 0\u00b0" "Gyro: %s\u00b0"
STATUSLIGHT GYRO_ON left "Gyro Enabled" "Gyro Enabled"
STATUSLIGHT ROTATE left "Slow Rotation" "Slow Rotation"
PBAR RPM_MAN_DISP,RPM_MAN right "Manual: 0%" "Manual: %s%"
PBAR RPM_SET_DISP,RPM_SET right "RPM \u2192 0" "RPM \u2192 %s"
PBAR RPM_REAL_DISP,RPM_REAL right "RPM: 0" "RPM: %s"
STATUSLIGHT SHOOT_READY right "Shooter Ready" "Shooter Ready"
STATUSLIGHT SHOOT_ON right "Shooter On" "Shooter On"
STATUSLIGHT SHOOT_MAN right "Shooter Manual" "Shooter Manual"
STATUSLIGHT ARMS_DOWN right "Arms Down" "Arms Down"