LibDS
Qt-based library for controlling FRC robots
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
FRC_2014 Class Reference

Implements the FRC 2009-2010 communication protocol. More...

#include <FRC_2014.h>

Inheritance diagram for FRC_2014:
Protocol

Public Member Functions

 FRC_2014 ()
 
virtual QString name ()
 
virtual int fmsFrequency ()
 
virtual int robotFrequency ()
 
virtual int fmsInputPort ()
 
virtual int fmsOutputPort ()
 
virtual int robotInputPort ()
 
virtual int robotOutputPort ()
 
virtual int maxPOVCount ()
 
virtual int maxAxisCount ()
 
virtual int maxButtonCount ()
 
virtual int maxJoystickCount ()
 
virtual void rebootRobot ()
 
virtual void restartRobotCode ()
 
virtual void onRobotWatchdogExpired ()
 
virtual qreal nominalBatteryVoltage ()
 
virtual qreal nominalBatteryAmperage ()
 
virtual DS::SocketType fmsSocketType ()
 
virtual DS::SocketType robotSocketType ()
 
virtual QString radioAddress ()
 
virtual QString robotAddress ()
 
virtual QByteArray getFMSPacket ()
 
virtual QByteArray getRobotPacket ()
 
virtual bool interpretFMSPacket (const QByteArray &data)
 
virtual bool interpretRobotPacket (const QByteArray &data)
 
- Public Member Functions inherited from Protocol
virtual int radioFrequency ()
 
virtual int radioInputPort ()
 
virtual int radioOutputPort ()
 
virtual int netconsoleInputPort ()
 
virtual int netconsoleOutputPort ()
 
virtual qreal nominalBatteryVOltage ()
 
virtual void onFMSWatchdogExpired ()
 
virtual void onRadioWatchdogExpired ()
 
virtual DS::SocketType radioSocketType ()
 
virtual QString fmsAddress ()
 
QByteArray generateFMSPacket ()
 
QByteArray generateRadioPacket ()
 
QByteArray generateRobotPacket ()
 
bool readFMSPacket (const QByteArray &data)
 
bool readRadioPacket (const QByteArray &data)
 
bool readRobotPacket (const QByteArray &data)
 
void resetLossCounter ()
 
int sentFMSPackets ()
 
int sentRadioPackets ()
 
int sentRobotPackets ()
 
int receivedFMSPackets ()
 
int receivedRadioPackets ()
 
int receivedRobotPackets ()
 
int recvRobotPacketsSinceConnect ()
 
int sentRobotPacketsSinceConnect ()
 

Protected Member Functions

virtual DS_UByte getAlliance ()
 
virtual DS_UByte getPosition ()
 
virtual DS_UByte getDigitalInput ()
 
virtual DS_UByte getOperationCode ()
 
virtual QByteArray getJoystickData ()
 
virtual DS::Alliance getAlliance (DS_UByte byte)
 
virtual DS::Position getPosition (DS_UByte byte)
 
- Protected Member Functions inherited from Protocol
DS_Configconfig ()
 
DS_Joysticks * joysticks ()
 
virtual QByteArray getRadioPacket ()
 
virtual bool interpretRadioPacket (const QByteArray &data)
 

Private Attributes

bool m_resync
 
bool m_restartCode
 
bool m_rebootRobot
 
CRC32 m_crc32
 

Detailed Description

Implements the FRC 2009-2010 communication protocol.

Constructor & Destructor Documentation

FRC_2014::FRC_2014 ( )
explicit

Implements the 2009-2014 FRC communication protocol

Member Function Documentation

int FRC_2014::fmsFrequency ( )
virtual

Send 10 FMS packets per second

Reimplemented from Protocol.

int FRC_2014::fmsInputPort ( )
virtual

We receive data from FMS at local port 1120

Reimplemented from Protocol.

int FRC_2014::fmsOutputPort ( )
virtual

We send data to the FMS to remote port 1160

Reimplemented from Protocol.

DS::SocketType FRC_2014::fmsSocketType ( )
virtual

FMS communications work with UDP datagrams

Reimplemented from Protocol.

References DS::kSocketTypeUDP.

DS_UByte FRC_2014::getAlliance ( )
protectedvirtual

Returns the code that represents the current alliance color

References DriverStation::alliance(), Protocol::config(), and DS::kAllianceBlue.

Referenced by getRobotPacket(), and interpretFMSPacket().

DS::Alliance FRC_2014::getAlliance ( DS_UByte  byte)
protectedvirtual

Gets the alliance from the received byte

References DS::kAllianceBlue, and DS::kAllianceRed.

DS_UByte FRC_2014::getDigitalInput ( )
protectedvirtual

Referenced by getRobotPacket().

QByteArray FRC_2014::getFMSPacket ( )
virtual

Reimplemented from Protocol.

QByteArray FRC_2014::getJoystickData ( )
protectedvirtual

Generates the joystick data. The FRC protocol defines joystick values for all joysticks, regardless if all joysticks are connected or not.

In the case that a joystick is not connected, the protocol will send a netrual value (e.g. 0 for each axis and false for each button).

References Protocol::joysticks(), maxAxisCount(), and maxJoystickCount().

Referenced by getRobotPacket().

DS_UByte FRC_2014::getOperationCode ( )
protectedvirtual

Returns the code used to identify the enable status, control mode, operation mode and operation flags.

References Protocol::config(), DriverStation::controlMode(), DriverStation::isEmergencyStopped(), DS_Config::isEnabled(), DS::kControlAutonomous, DS::kControlTeleoperated, and DS::kControlTest.

Referenced by getRobotPacket().

DS_UByte FRC_2014::getPosition ( )
protectedvirtual

Returns the code that represents the current team position

References Protocol::config(), DS::kPosition1, DS::kPosition2, DS::kPosition3, and DriverStation::position().

Referenced by getRobotPacket(), and interpretFMSPacket().

DS::Position FRC_2014::getPosition ( DS_UByte  byte)
protectedvirtual

Gets the position from the received byte

References DS::kPosition1, DS::kPosition2, and DS::kPosition3.

QByteArray FRC_2014::getRobotPacket ( )
virtual
bool FRC_2014::interpretFMSPacket ( const QByteArray &  data)
virtual
bool FRC_2014::interpretRobotPacket ( const QByteArray &  data)
virtual

Reads the input data and extracts the robot voltage, the robot code status and the emergency stop status.

If the packet is read successfully, the function returns true.

Note
If both voltage values are equal to 0x37, it means that the robot code is not running

Reimplemented from Protocol.

References Protocol::config(), DS_Config::isEmergencyStopped(), DS::kEmergencyStop, name(), Protocol::receivedRobotPackets(), DS_Config::setRobotCode(), DS_Config::updateOperationStatus(), DS_Config::updateSimulated(), and DS_Config::updateVoltage().

int FRC_2014::maxAxisCount ( )
virtual

FRC 2014 protocol supports a maximum of 6 axes. Remaining axes will be ignored.

Reimplemented from Protocol.

Referenced by getJoystickData().

int FRC_2014::maxButtonCount ( )
virtual

FRC 2014 protocol supports a maximum of 12 buttons. Remaining buttons will be ignored.

Reimplemented from Protocol.

int FRC_2014::maxJoystickCount ( )
virtual

FRC 2014 Protocol supports a maximum of 4 joysticks. Remaining joysticks will be ignored.

Reimplemented from Protocol.

Referenced by getJoystickData().

int FRC_2014::maxPOVCount ( )
virtual

FRC 2014 protocol does not use POVs

Reimplemented from Protocol.

QString FRC_2014::name ( )
virtual

Returns the display name of the protocol

Reimplemented from Protocol.

Referenced by interpretFMSPacket(), and interpretRobotPacket().

qreal FRC_2014::nominalBatteryAmperage ( )
virtual

Returns the nominal amperage given by the robot battery

Reimplemented from Protocol.

qreal FRC_2014::nominalBatteryVoltage ( )
virtual

Returns the nominal/maximum voltage given by the robot battery.

void FRC_2014::onRobotWatchdogExpired ( )
virtual

Be sure that we do not reboot the robot or restart its code when we re-establish communications with it.

Reimplemented from Protocol.

QString FRC_2014::radioAddress ( )
virtual

Radio is located at 10.TE.AM.1

Reimplemented from Protocol.

References Protocol::config(), DS::getStaticIP(), and DriverStation::team().

void FRC_2014::rebootRobot ( )
virtual

Configures the protocol to reboot the robot with the next sent packet.

Reimplemented from Protocol.

void FRC_2014::restartRobotCode ( )
virtual

Configures the protocol to restart the robot code with the next sent packet (not really, it does not work for the moment).

Reimplemented from Protocol.

QString FRC_2014::robotAddress ( )
virtual

Robot is located at 10.TE.AM.2

Reimplemented from Protocol.

References Protocol::config(), DS::getStaticIP(), and DriverStation::team().

int FRC_2014::robotFrequency ( )
virtual

Send 50 robot packets per second

Reimplemented from Protocol.

int FRC_2014::robotInputPort ( )
virtual

We receive data from the robot at local port 1150

Reimplemented from Protocol.

int FRC_2014::robotOutputPort ( )
virtual

We send data to the robot at remote port 1110

Reimplemented from Protocol.

DS::SocketType FRC_2014::robotSocketType ( )
virtual

Robot communications work with UDP datagrams

Reimplemented from Protocol.

References DS::kSocketTypeUDP.


The documentation for this class was generated from the following files: