LibDS
Qt-based library for controlling FRC robots
|
Exposes the functionality of the LibDS to the application. More...
#include <DriverStation.h>
Public Types | |
enum | ProtocolType { kFRC2016 = 0, kFRC2015 = 1, kFRC2014 = 2 } |
enum | TeamStation { kRed1 = 0, kRed2 = 1, kRed3 = 2, kBlue1 = 3, kBlue2 = 4, kBlue3 = 5 } |
Public Types inherited from DS | |
enum | ControlMode { kControlTest, kControlAutonomous, kControlTeleoperated } |
Represents the available control modes of the robot. More... | |
enum | Alliance { kAllianceRed, kAllianceBlue } |
Represents the team alliance. More... | |
enum | Position { kPosition1, kPosition2, kPosition3 } |
Represents the different team positions for each alliance. More... | |
enum | CommStatus { kCommsWorking, kCommsFailing } |
Represents the communication status between the client and a target. More... | |
enum | CodeStatus { kCodeRunning, kCodeFailing } |
Represents the status of the robot code. More... | |
enum | EnableStatus { kEnabled, kDisabled } |
Represents the enabled state of the robot. More... | |
enum | OperationStatus { kNormal, kEmergencyStop } |
Represents the operation status of the robot. More... | |
enum | VoltageStatus { kVoltageNormal, kVoltageBrownout } |
Represents the status of the robot power supply. When the battery level is low or there are too many power spikes, the robot may report a voltage brownout. More... | |
enum | SocketType { kSocketTypeUDP, kSocketTypeTCP } |
Represents the socket types that can be used by the DS modules. More... | |
Signals | |
void | resetted () |
void | initialized () |
void | logFileChanged () |
void | protocolChanged () |
void | joystickCountChanged (int count) |
void | newMessage (const QString &message) |
Signals inherited from DS_Base | |
void | elapsedTimeChanged (int msecs) |
void | elapsedTimeChanged (const QString &string) |
void | statusChanged (const QString &status) |
void | simulatedChanged (const bool isSimulation) |
void | enabledChanged (const EnableStatus status) |
void | allianceChanged (const Alliance alliance) |
void | positionChanged (const Position position) |
void | codeStatusChanged (const CodeStatus statusChanged) |
void | controlModeChanged (const ControlMode mode) |
void | robotAddressChanged (const QString &address) |
void | radioAddressChanged (const QString &address) |
void | fmsCommStatusChanged (const CommStatus statusChanged) |
void | robotCommStatusChanged (const CommStatus statusChanged) |
void | radioCommStatusChanged (const CommStatus statusChanged) |
void | voltageStatusChanged (const VoltageStatus statusChanged) |
void | operationStatusChanged (const OperationStatus statusChanged) |
void | pdpVersionChanged (const QString &version) |
void | pcmVersionChanged (const QString &version) |
void | libVersionChanged (const QString &version) |
void | voltageChanged (const qreal voltage) |
void | voltageChanged (const QString &voltageString) |
void | teamChanged (const int team) |
void | cpuUsageChanged (const int usage) |
void | ramUsageChanged (const int usage) |
void | diskUsageChanged (const int usage) |
Public Member Functions | |
Q_INVOKABLE bool | canBeEnabled () |
Q_INVOKABLE bool | running () const |
Q_INVOKABLE bool | isInTest () const |
Q_INVOKABLE bool | isEnabled () const |
Q_INVOKABLE bool | isSimulated () const |
Q_INVOKABLE bool | isInAutonomous () const |
Q_INVOKABLE bool | isInTeleoperated () const |
Q_INVOKABLE bool | isConnectedToFMS () const |
Q_INVOKABLE bool | isVoltageBrownout () const |
Q_INVOKABLE bool | isEmergencyStopped () const |
Q_INVOKABLE bool | isConnectedToRobot () const |
Q_INVOKABLE bool | isConnectedToRadio () const |
Q_INVOKABLE bool | isRobotCodeRunning () const |
Q_INVOKABLE QString | logsPath () const |
Q_INVOKABLE QVariant | logVariant () const |
Q_INVOKABLE QStringList | availableLogs () const |
Q_INVOKABLE QJsonDocument | logDocument () const |
Q_INVOKABLE qreal | maxBatteryVoltage () const |
Q_INVOKABLE qreal | currentBatteryVoltage () const |
Q_INVOKABLE qreal | nominalBatteryAmperage () const |
Q_INVOKABLE int | team () const |
Q_INVOKABLE int | cpuUsage () const |
Q_INVOKABLE int | ramUsage () const |
Q_INVOKABLE int | diskUsage () const |
Q_INVOKABLE int | packetLoss () const |
Q_INVOKABLE int | maxPOVCount () const |
Q_INVOKABLE int | maxAxisCount () const |
Q_INVOKABLE int | maxButtonCount () const |
Q_INVOKABLE int | maxJoystickCount () const |
Q_INVOKABLE int | getNumAxes (int joystick) |
Q_INVOKABLE int | getNumPOVs (int joystick) |
Q_INVOKABLE int | getNumButtons (int joystick) |
Q_INVOKABLE int | getRealNumAxes (int joystick) |
Q_INVOKABLE int | getRealNumPOVs (int joystick) |
Q_INVOKABLE int | getRealNumButtons (int joystick) |
Q_INVOKABLE int | joystickCount () |
Q_INVOKABLE DS_Joysticks * | joysticks () |
Q_INVOKABLE Alliance | alliance () const |
Q_INVOKABLE Position | position () const |
Q_INVOKABLE ControlMode | controlMode () const |
Q_INVOKABLE CommStatus | fmsCommStatus () const |
Q_INVOKABLE EnableStatus | enableStatus () const |
Q_INVOKABLE CommStatus | radioCommStatus () const |
Q_INVOKABLE CommStatus | robotCommStatus () const |
Q_INVOKABLE CodeStatus | robotCodeStatus () const |
Q_INVOKABLE VoltageStatus | voltageStatus () const |
Q_INVOKABLE QString | fmsAddress () const |
Q_INVOKABLE QString | radioAddress () const |
Q_INVOKABLE QString | robotAddress () const |
Q_INVOKABLE QString | generalStatus () const |
Q_INVOKABLE QString | customFMSAddress () const |
Q_INVOKABLE QString | customRadioAddress () const |
Q_INVOKABLE QString | customRobotAddress () const |
Q_INVOKABLE QString | defaultFMSAddress () const |
Q_INVOKABLE QString | defaultRadioAddress () const |
Q_INVOKABLE QString | defaultRobotAddress () const |
Q_INVOKABLE OperationStatus | operationStatus () const |
Q_INVOKABLE QStringList | protocols () const |
Q_INVOKABLE QStringList | teamStations () const |
Q_INVOKABLE bool | registerJoystick (int axes, int buttons, int povs) |
Static Public Member Functions | |
static DriverStation * | getInstance () |
static void | logger (QtMsgType type, const QMessageLogContext &context, const QString &data) |
Static Public Member Functions inherited from DS | |
static QString | getStaticIP (int net, int team, int host) |
Returns a calculated IP address based on the team address. More... | |
static QString | timezone () |
Returns the current timezone as a string. | |
static QByteArray | readSocket (QUdpSocket *socket) |
Reads the datagrams received by the given UDP socket. | |
static QByteArray | readSocket (QTcpSocket *socket) |
Reads the data received by the given TCP socket. | |
Private Slots | |
void | stop () |
void | start () |
void | resetFMS () |
void | resetRadio () |
void | resetRobot () |
void | finishInit () |
void | sendFMSPacket () |
void | updateAddresses () |
void | sendRadioPacket () |
void | sendRobotPacket () |
void | updatePacketLoss () |
void | updateAddresses (int unused) |
void | updateLogs (const QString &file) |
void | readFMSPacket (const QByteArray &data) |
void | readRadioPacket (const QByteArray &data) |
void | readRobotPacket (const QByteArray &data) |
Private Member Functions | |
DS_Config * | config () const |
Protocol * | protocol () const |
Private Attributes | |
bool | m_init |
bool | m_running |
int | m_packetLoss |
int | m_fmsInterval |
int | m_radioInterval |
int | m_robotInterval |
QString | m_logDocumentPath |
DS_Joysticks | m_joysticks |
QString | m_customFMSAddress |
QJsonDocument | m_logDocument |
QString | m_customRadioAddress |
QString | m_customRobotAddress |
Sockets * | m_sockets |
Protocol * | m_protocol |
NetConsole * | m_console |
Watchdog * | m_fmsWatchdog |
Watchdog * | m_radioWatchdog |
Watchdog * | m_robotWatchdog |
Exposes the functionality of the LibDS to the application.
The DriverStation
class exposes the LibDS
library to the application, and implements functions that allow the safe operation of robots, protocol switching/lodaing and joystick management.
The DriverStation
class provides several reduntant functions in order to be more user-friendly and giving application developers more flexibility regarding the use of LibDS types.
DS::Alliance DriverStation::alliance | ( | ) | const |
Returns the current alliance (red or blue) of the robot.
References DS_Config::alliance(), and config().
Referenced by FRC_2014::getAlliance(), and FRC_2014::interpretFMSPacket().
QStringList DriverStation::availableLogs | ( | ) | const |
Returns a list with all the robot logs saved to the logs path
References Logger::availableLogs(), config(), and DS_Config::logger().
|
slot |
Shows an open file dialog and lets the user select a DS log file to load...
References config(), Logger::extension(), DS_Config::logger(), logsPath(), and openLog().
bool DriverStation::canBeEnabled | ( | ) |
Returns true
if we have communications with the robot controller and the robot code is running.
false
if the robot is emergency stopped. References isConnectedToRobot(), isEmergencyStopped(), and isRobotCodeRunning().
|
private |
Returns a pointer to the DS_Config
class, which is shared by the DriverStation
and the protocol.
The point of having a config class is to allow the protocol to change the status of the DriverStation
and the LibDS system without increasing the complexity of the Protocol
and DriverStation
classes, whilst ensuring that values are the same throughout the LibDS and that signals are only fired when necessary.
References DS_Config::getInstance().
Referenced by alliance(), availableLogs(), browseLogs(), controlMode(), cpuUsage(), currentBatteryVoltage(), diskUsage(), enableStatus(), fmsCommStatus(), init(), isSimulated(), logsPath(), openLog(), operationStatus(), position(), radioCommStatus(), ramUsage(), resetFMS(), resetRadio(), resetRobot(), robotCodeStatus(), robotCommStatus(), setAlliance(), setControlMode(), setEnabled(), setOperationStatus(), setPosition(), setTeam(), team(), updatePacketLoss(), and voltageStatus().
DS::ControlMode DriverStation::controlMode | ( | ) | const |
Returns the current control mode (test, auto or teleop) of the robot.
References config(), and DS_Config::controlMode().
Referenced by generalStatus(), FRC_2014::getOperationCode(), isInAutonomous(), isInTeleoperated(), and isInTest().
int DriverStation::cpuUsage | ( | ) | const |
Returns the current CPU usage of the robot. Value range is from 0 to 100.
References config(), and DS_Config::cpuUsage().
qreal DriverStation::currentBatteryVoltage | ( | ) | const |
Returns the current battery voltage of the robot
References config(), and DS_Config::voltage().
QString DriverStation::customFMSAddress | ( | ) | const |
Returns the user-set FMS address
Referenced by fmsAddress().
QString DriverStation::customRadioAddress | ( | ) | const |
Returns the user-set radio address
Referenced by radioAddress().
QString DriverStation::customRobotAddress | ( | ) | const |
Returns the user-set robot address
Referenced by robotAddress().
QString DriverStation::defaultFMSAddress | ( | ) | const |
Returns the protocol-set robot address.
References Protocol::fmsAddress(), and protocol().
Referenced by fmsAddress().
QString DriverStation::defaultRadioAddress | ( | ) | const |
Returns the protocol-set radio address.
References protocol(), and Protocol::radioAddress().
Referenced by radioAddress().
QString DriverStation::defaultRobotAddress | ( | ) | const |
Returns the protocol-set robot address.
References protocol(), and Protocol::robotAddress().
Referenced by robotAddress().
|
slot |
Disables the robot directly
References DS::kDisabled, and setEnabled().
int DriverStation::diskUsage | ( | ) | const |
Returns the current disk usage of the robot. Value range is from 0 to 100.
References config(), and DS_Config::diskUsage().
|
slot |
Enables the robot directly
References DS::kEnabled, and setEnabled().
DS::EnableStatus DriverStation::enableStatus | ( | ) | const |
Returns the current enable status of the robot.
References config(), and DS_Config::enableStatus().
Referenced by generalStatus(), and isEnabled().
|
privateslot |
Notifies the UI that the DS has been initialized
References generalStatus(), and DS_Base::statusChanged().
Referenced by init().
QString DriverStation::fmsAddress | ( | ) | const |
Returns the applied FMS address (be it DS-set or user-set)
References customFMSAddress(), and defaultFMSAddress().
Referenced by Sockets::onFMSLookupFinished(), Sockets::performLookups(), setCustomFMSAddress(), and updateAddresses().
DS::CommStatus DriverStation::fmsCommStatus | ( | ) | const |
Returns the current client/FMS communication status.
References config(), and DS_Config::fmsCommStatus().
Referenced by isConnectedToFMS().
QString DriverStation::generalStatus | ( | ) | const |
Returns the current status of the Driver Station. This string is used in the large label below the status lights of the DS.
References controlMode(), enableStatus(), isConnectedToRobot(), isEmergencyStopped(), isRobotCodeRunning(), isVoltageBrownout(), DS::kControlAutonomous, DS::kControlTeleoperated, DS::kControlTest, DS::kDisabled, and DS::kEnabled.
Referenced by finishInit(), and resetRobot().
|
static |
Returns the one and only instance of the DriverStation
class. The DriverStation
class must be singleton to ensure the safe operation of the robot and also to ensure availability to the input and output sockets used by each protocol.
Referenced by Protocol::joysticks(), Sockets::performLookups(), DS_Config::updateControlMode(), DS_Config::updateEnabled(), DS_Config::updateFMSCommStatus(), DS_Config::updateOperationStatus(), DS_Config::updateRobotCodeStatus(), DS_Config::updateRobotCommStatus(), DS_Config::updateVoltage(), and DS_Config::updateVoltageStatus().
int DriverStation::getNumAxes | ( | int | joystick | ) |
Returns the number of axes registered with the given joystick.
getRealNumAxes()
function References joysticks().
int DriverStation::getNumButtons | ( | int | joystick | ) |
Returns the number of buttons registered with the given joystick.
getRealNumButtons()
function References joysticks().
int DriverStation::getNumPOVs | ( | int | joystick | ) |
Returns the number of POVs registered with the given joystick.
getRealNumPOVs()
function References joysticks().
int DriverStation::getRealNumAxes | ( | int | joystick | ) |
Returns the number of axes registered with the given joystick, this value can be greater than what the protocol supports. If you are interested in getting only the number of axes used by the DS, use the getNumAxes()
function.
References joysticks().
int DriverStation::getRealNumButtons | ( | int | joystick | ) |
Returns the number of buttons registered with the given joystick, this value can be greater than what the protocol supports. If you are interested in getting only the number of buttons used by the DS, use the getNumButtons()
function.
References joysticks().
int DriverStation::getRealNumPOVs | ( | int | joystick | ) |
Returns the number of POVs registered with the given joystick, this value can be greater than what the protocol supports. If you are interested in getting only the number of POVs used by the DS, use the getNumPOVs()
function.
References joysticks().
|
slot |
This function must be called in order to start DS operations. It is recommended to call this function AFTER your UI has been initialized, so that the UI can react to the signals sent by the DriverStation
.
References config(), finishInit(), DS_Config::logger(), Logger::registerInitialEvents(), resetFMS(), resetRadio(), resetRobot(), sendFMSPacket(), sendRadioPacket(), sendRobotPacket(), and updatePacketLoss().
bool DriverStation::isConnectedToFMS | ( | ) | const |
Returns true
if the Driver Station has established communications with the FMS.
References fmsCommStatus(), and DS::kCommsWorking.
Referenced by Sockets::performLookups(), removeJoystick(), resetJoysticks(), and sendFMSPacket().
bool DriverStation::isConnectedToRadio | ( | ) | const |
Returns true
if the Driver Station has established communications with the radio.
References DS::kCommsWorking, and radioCommStatus().
Referenced by Sockets::performLookups().
bool DriverStation::isConnectedToRobot | ( | ) | const |
Returns true
if the Driver Station has established communications with the robot.
References DS::kCommsWorking, and robotCommStatus().
Referenced by canBeEnabled(), generalStatus(), Sockets::performLookups(), and updatePacketLoss().
bool DriverStation::isEmergencyStopped | ( | ) | const |
Returns true
if the robot is emergency stopped
References DS::kEmergencyStop, and operationStatus().
Referenced by canBeEnabled(), generalStatus(), and FRC_2014::getOperationCode().
bool DriverStation::isEnabled | ( | ) | const |
Returns true
if the robot is currently enabled
References enableStatus(), and DS::kEnabled.
bool DriverStation::isInAutonomous | ( | ) | const |
Returns true
if the robot is currently in autonomous mode
References controlMode(), and DS::kControlAutonomous.
bool DriverStation::isInTeleoperated | ( | ) | const |
Returns true
if the robot is currently in teleop mode
References controlMode(), and DS::kControlTeleoperated.
bool DriverStation::isInTest | ( | ) | const |
Returns true
if the robot is currently in test mode
References controlMode(), and DS::kControlTest.
bool DriverStation::isRobotCodeRunning | ( | ) | const |
Returns true
if the robot code is running
References DS::kCodeRunning, and robotCodeStatus().
Referenced by canBeEnabled(), and generalStatus().
bool DriverStation::isSimulated | ( | ) | const |
Returns true
if the robot is a simulated robot
References config(), and DS_Config::isSimulated().
bool DriverStation::isVoltageBrownout | ( | ) | const |
Returns true
if the robot is experiencing a brownout (ouch!)
References DS::kVoltageBrownout, and voltageStatus().
Referenced by generalStatus().
int DriverStation::joystickCount | ( | ) |
Returns the current number of joysticks registered with the DS.
References joysticks().
Referenced by registerJoystick(), removeJoystick(), and resetJoysticks().
DS_Joysticks * DriverStation::joysticks | ( | ) |
Returns the actual joysticks and their properties
Referenced by getNumAxes(), getNumButtons(), getNumPOVs(), getRealNumAxes(), getRealNumButtons(), getRealNumPOVs(), joystickCount(), Protocol::joysticks(), registerJoystick(), removeJoystick(), resetJoysticks(), updateAxis(), updateButton(), and updatePOV().
QJsonDocument DriverStation::logDocument | ( | ) | const |
Returns the current JSON log document
Referenced by logVariant().
|
static |
Calls the custom Qt message handler of the LibDS
References DS_Config::getInstance(), DS_Config::logger(), and Logger::messageHandler().
QString DriverStation::logsPath | ( | ) | const |
Returns the path in which application log files are stored
References config(), DS_Config::logger(), and Logger::logsPath().
Referenced by browseLogs(), and openLogsPath().
QVariant DriverStation::logVariant | ( | ) | const |
Returns the current JSON document as a variant list
References logDocument().
int DriverStation::maxAxisCount | ( | ) | const |
Returns the maximum number of axes that a joystick can have
References Protocol::maxAxisCount(), and protocol().
Referenced by reconfigureJoysticks(), and registerJoystick().
qreal DriverStation::maxBatteryVoltage | ( | ) | const |
Returns the nominal battery voltage of the robot. This value, along with the currentBatteryVoltage()
function, can be used to draw graphs or do other cool stuff.
References Protocol::nominalBatteryVOltage(), and protocol().
Referenced by DS_Config::updateVoltage().
int DriverStation::maxButtonCount | ( | ) | const |
Returns the maximum number of buttons that a joystick can have
References Protocol::maxButtonCount(), and protocol().
Referenced by reconfigureJoysticks(), and registerJoystick().
int DriverStation::maxJoystickCount | ( | ) | const |
Returns the maximum number of joysticks that the protocol can handle
References Protocol::maxJoystickCount(), and protocol().
Referenced by reconfigureJoysticks(), and registerJoystick().
int DriverStation::maxPOVCount | ( | ) | const |
Returns the maximum number of POVs that a joystick can have
References Protocol::maxPOVCount(), and protocol().
Referenced by reconfigureJoysticks(), and registerJoystick().
qreal DriverStation::nominalBatteryAmperage | ( | ) | const |
Returns the nominal battery amperage of the robot. This value, along with the currentBatteryVoltage()
function, can be used to calculate the power (in watts) used by the robot.
You could do some cool stuff with this function, such as making a dashboard similar to Tesla's car dashboard.
References Protocol::nominalBatteryAmperage(), and protocol().
|
slot |
Opens the given log file file and parses it as a JSON document
References config(), DS_Config::logger(), and Logger::openLog().
Referenced by browseLogs(), and updateLogs().
|
slot |
Opens the application logs in an explorer window
References logsPath().
DS::OperationStatus DriverStation::operationStatus | ( | ) | const |
Returns the current operation status of the robot (normal or e-stop).
References config(), and DS_Config::operationStatus().
Referenced by isEmergencyStopped().
int DriverStation::packetLoss | ( | ) | const |
Returns the current packet loss percentage (from 0 to 100).
DS::Position DriverStation::position | ( | ) | const |
Returns the current position (1, 2 or 3) of the robot.
References config(), and DS_Config::position().
Referenced by FRC_2014::getPosition(), and FRC_2014::interpretFMSPacket().
|
private |
Returns a pointer to the current loaded protocol.
NULL
before using it! Referenced by defaultFMSAddress(), defaultRadioAddress(), defaultRobotAddress(), maxAxisCount(), maxBatteryVoltage(), maxButtonCount(), maxJoystickCount(), maxPOVCount(), nominalBatteryAmperage(), readFMSPacket(), readRadioPacket(), readRobotPacket(), rebootRobot(), reconfigureJoysticks(), resetFMS(), resetRadio(), resetRobot(), restartRobotCode(), sendFMSPacket(), sendRadioPacket(), sendRobotPacket(), setProtocol(), and updatePacketLoss().
QStringList DriverStation::protocols | ( | ) | const |
Returns a list with the included protocols of the library. This function is meant to be used to generate your UI elements and seamessly use them with the setProtocolType()
function.
QString DriverStation::radioAddress | ( | ) | const |
Returns the applied radio address (be it DS-set or user-set)
References customRadioAddress(), and defaultRadioAddress().
Referenced by Sockets::onRadioLookupFinished(), Sockets::performLookups(), setCustomRadioAddress(), and updateAddresses().
DS::CommStatus DriverStation::radioCommStatus | ( | ) | const |
Returns the current radio/FMS communication status.
References config(), and DS_Config::radioCommStatus().
Referenced by isConnectedToRadio().
int DriverStation::ramUsage | ( | ) | const |
Returns the current RAM usage of the robot. Value range is from 0 to 100.
References config(), and DS_Config::ramUsage().
|
privateslot |
Instructs the current protocol to interpret the given data, which was sent by the FMS.
References protocol(), Watchdog::reset(), and running().
|
privateslot |
Instructs the current protocol to interpret the given data, which was sent by the robot radio.
References protocol(), Watchdog::reset(), and running().
|
privateslot |
Instructs the current protocol to interpret the given data, which was sent by the robot controller.
References protocol(), Watchdog::reset(), and running().
|
slot |
Reboots the robot controller (if a protocol is loaded)
References protocol(), and Protocol::rebootRobot().
|
slot |
Re-registers all joysticks based on the criteria specified by the new protocol.
DriverStation
will register only the ammount of buttons supported by the protocol. The same process takes place for axes and POVs. References maxAxisCount(), maxButtonCount(), maxJoystickCount(), maxPOVCount(), Protocol::name(), protocol(), DS::Joystick::realNumAxes, DS::Joystick::realNumButtons, DS::Joystick::realNumPOVs, registerJoystick(), and resetJoysticks().
Referenced by setProtocol().
bool DriverStation::registerJoystick | ( | int | axes, |
int | buttons, | ||
int | povs | ||
) |
Registers a new joystick with the given number of axes, buttons & POVs hats.
false
. References DS::Joystick::axes, DS::Joystick::buttons, joystickCount(), joysticks(), maxAxisCount(), maxButtonCount(), maxJoystickCount(), maxPOVCount(), DS::Joystick::numAxes, DS::Joystick::numButtons, DS::Joystick::numPOVs, DS::Joystick::povs, DS::Joystick::realNumAxes, DS::Joystick::realNumButtons, and DS::Joystick::realNumPOVs.
Referenced by reconfigureJoysticks().
|
slot |
Removes the joystick at the given id
References isConnectedToFMS(), joystickCount(), joysticks(), and setEnabled().
|
privateslot |
Called when the FMS watchdog expires
References config(), DS::kCommsFailing, Protocol::onFMSWatchdogExpired(), protocol(), and DS_Config::updateFMSCommStatus().
Referenced by init(), and setProtocol().
|
slot |
Removes all the registered joysticks
References isConnectedToFMS(), joystickCount(), joysticks(), and setEnabled().
Referenced by reconfigureJoysticks().
|
privateslot |
Called when the radio watchdog expires
References config(), DS::kCommsFailing, Protocol::onRadioWatchdogExpired(), protocol(), and DS_Config::updateRadioCommStatus().
Referenced by init(), and setProtocol().
|
privateslot |
Called when the robot watchdog expires
References config(), generalStatus(), DS::kCodeFailing, DS::kCommsFailing, DS::kDisabled, DS::kNormal, DS::kVoltageNormal, Protocol::onRobotWatchdogExpired(), protocol(), Protocol::resetLossCounter(), DS_Base::statusChanged(), DS_Config::updateEnabled(), DS_Config::updateOperationStatus(), DS_Config::updateRobotCodeStatus(), DS_Config::updateRobotCommStatus(), DS_Config::updateSimulated(), DS_Config::updateVoltage(), and DS_Config::updateVoltageStatus().
Referenced by init(), and setProtocol().
|
slot |
Restarts the robot code (if a protocol is loaded)
References protocol(), and Protocol::restartRobotCode().
QString DriverStation::robotAddress | ( | ) | const |
Returns the applied robot address (be it DS-set or user-set)
References customRobotAddress(), and defaultRobotAddress().
Referenced by Sockets::onRobotLookupFinished(), Sockets::performLookups(), setCustomRobotAddress(), and updateAddresses().
DS::CodeStatus DriverStation::robotCodeStatus | ( | ) | const |
Returns the current status of the robot code
References config(), and DS_Config::robotCodeStatus().
Referenced by isRobotCodeRunning().
DS::CommStatus DriverStation::robotCommStatus | ( | ) | const |
Returns the current robot/FMS communication status.
References config(), and DS_Config::robotCommStatus().
Referenced by isConnectedToRobot().
bool DriverStation::running | ( | ) | const |
Returns true
if the DS is currently allowed to send and receive data. This function is called whenever we send a packet or when we receive a packet.
false
, then the DS will ignore all incoming packets and inhibit packet sending Referenced by readFMSPacket(), readRadioPacket(), readRobotPacket(), sendFMSPacket(), sendRadioPacket(), and sendRobotPacket().
|
privateslot |
Generates and sends a new FMS packet only if we are already connected to the FMS
References isConnectedToFMS(), protocol(), running(), and Sockets::sendToFMS().
Referenced by init().
|
privateslot |
Generates and sends a new radio packet
References protocol(), running(), and Sockets::sendToRadio().
Referenced by init().
|
privateslot |
Generates and sends a new robot packet
References protocol(), running(), and Sockets::sendToRobot().
Referenced by init().
|
slot |
Updates the team alliance.
References config(), and DS_Config::updateAlliance().
Referenced by setTeamStation().
|
slot |
Changes the control mode of the robot.
References config(), and DS_Config::updateControlMode().
Referenced by switchToAutonomous(), switchToTeleoperated(), and switchToTestMode().
|
slot |
Forces the system to look for the FMS at the given address instead of using the default FMS address specified by the current protocol.
References fmsAddress(), and Sockets::setFMSAddress().
|
slot |
Forces the system to look for the robot radio at the given address instead of using the default radio address specified by the current protocol.
References radioAddress(), and Sockets::setRadioAddress().
|
slot |
Forces the system to use the given address. This can be useful when you already know the IP address of the robot, or you are simulating your robot program with a specific virtual IP address.
Using this function is discouraged, the LibDS is fast enough to remove the need of defining the IP address of the robot by yourself.
References robotAddress(), and Sockets::setRobotAddress().
|
slot |
Changes the enabled status of the robot.
References DS::kDisabled, and DS::kEnabled.
Referenced by disableRobot(), enableRobot(), removeJoystick(), resetJoysticks(), switchToAutonomous(), switchToTeleoperated(), switchToTestMode(), and triggerEmergencyStop().
|
slot |
Changes the enabled status of the robot.
References config(), and DS_Config::updateEnabled().
|
slot |
Changes the operation status
of the robot. Possible values are:
kDisconnected
kNormal
kEmergencyStop
If you are writting your own Driver Station client, we strongly encourage you to implement the hability to e-stop the robot in your custom client.
References config(), and DS_Config::updateOperationStatus().
Referenced by triggerEmergencyStop().
|
slot |
Updates the team position
References config(), and DS_Config::updatePosition().
Referenced by setTeamStation().
|
slot |
Loads and configures the given protocol with the LibDS system.
References Protocol::fmsFrequency(), Protocol::fmsInputPort(), Protocol::fmsOutputPort(), Protocol::fmsSocketType(), Protocol::name(), Protocol::netconsoleInputPort(), Protocol::netconsoleOutputPort(), protocol(), Protocol::radioFrequency(), Protocol::radioInputPort(), Protocol::radioOutputPort(), Protocol::radioSocketType(), reconfigureJoysticks(), resetFMS(), resetRadio(), resetRobot(), Protocol::robotFrequency(), Protocol::robotInputPort(), Protocol::robotOutputPort(), Protocol::robotSocketType(), Watchdog::setExpirationTime(), Sockets::setFMSInputPort(), Sockets::setFMSOutputPort(), Sockets::setFMSSocketType(), NetConsole::setInputPort(), NetConsole::setOutputPort(), Sockets::setRadioInputPort(), Sockets::setRadioOutputPort(), Sockets::setRadioSocketType(), Sockets::setRobotInputPort(), Sockets::setRobotOutputPort(), Sockets::setRobotSocketType(), start(), stop(), and updateAddresses().
Referenced by setProtocolType().
|
slot |
Given the protocol
, this function will initialize, load and configure the defined protocol.
This function is meant to be used in co-junction of the list outputted by the protocols()
function.
References setProtocol().
|
slot |
Changes the team number to the given team.
References config(), and DS_Config::updateTeam().
|
slot |
If you are lazy enough to not wanting to use two function calls to change the alliance & position of the robot, we've got you covered!
Actually, this function is available so that the UI elements (such as a combobox with team stations) can interact directly with the DriverStation
References DS::kAllianceBlue, DS::kAllianceRed, DS::kPosition1, DS::kPosition2, DS::kPosition3, setAlliance(), and setPosition().
|
privateslot |
Allows the DS to send and receive packets
Referenced by setProtocol().
|
privateslot |
Inhibits the DS to send and receive packets
Referenced by setProtocol().
|
slot |
Disables the robot and changes the control mode to kControlAutonomous
References DS::kControlAutonomous, DS::kDisabled, setControlMode(), and setEnabled().
|
slot |
Disables the robot and changes the control mode to kControlTeleoperated
References DS::kControlTeleoperated, DS::kDisabled, setControlMode(), and setEnabled().
|
slot |
Disables the robot and changes the control mode to kControlTest
References DS::kControlTest, DS::kDisabled, setControlMode(), and setEnabled().
int DriverStation::team | ( | ) | const |
Returns the current team number, which can be used by the client application.
References config(), and DS_Config::team().
Referenced by FRC_2014::radioAddress(), and FRC_2014::robotAddress().
QStringList DriverStation::teamStations | ( | ) | const |
Returns a list with the possible alliances and positions. This function is meant to be used to generate your UI elements and seamessly use them with the setAllianceAndPosition()
function.
|
slot |
Disables the robot and triggers an emergency stop on the robot
References DS::kDisabled, DS::kEmergencyStop, setEnabled(), and setOperationStatus().
|
privateslot |
Ensures that the IP addresses are updated when the application changes the team number.
References fmsAddress(), radioAddress(), robotAddress(), Sockets::setFMSAddress(), Sockets::setRadioAddress(), and Sockets::setRobotAddress().
Referenced by setProtocol(), and updateAddresses().
|
privateslot |
This overloaded function is called when the team number is changed (hence the int
in the argument).
As its name suggests, the input value is unused, this function was implemented to avoid possible errors in the Qt signal/slot system, while maintaining the functionality of the original updateAddresses()
function
References updateAddresses().
|
slot |
Updates the value of the given axis of the joystick with the specified id
References joysticks().
|
slot |
Updates the pressed state of the given button of the joystick with the specified id
References joysticks().
|
privateslot |
Used to ensure that the log feed of the UI is constantly updated
References openLog().
|
privateslot |
Calculates the current packet loss as a percent
References config(), isConnectedToRobot(), DS_Config::logger(), protocol(), Protocol::recvRobotPacketsSinceConnect(), Logger::registerPacketLoss(), and Protocol::sentRobotPacketsSinceConnect().
Referenced by init().
|
slot |
Updates the angle of the given pov of the joystick with the specified id
References joysticks().
DS::VoltageStatus DriverStation::voltageStatus | ( | ) | const |
Returns the current voltage status (normal or brownout) of the robot.
References config(), and DS_Config::voltageStatus().
Referenced by isVoltageBrownout().