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

Implements the FRC 2015-2019 communication protocol. More...

#include <FRC_2015.h>

Inheritance diagram for FRC_2015:
Protocol FRC_2016

Public Member Functions

 FRC_2015 ()
 
virtual QString name ()
 
virtual int fmsFrequency ()
 
virtual int robotFrequency ()
 
virtual int fmsInputPort ()
 
virtual int fmsOutputPort ()
 
virtual int robotInputPort ()
 
virtual int robotOutputPort ()
 
virtual int netconsoleInputPort ()
 
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 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 QByteArray getTimezoneData ()
 
virtual QByteArray getJoystickData ()
 
virtual DS::Alliance getAlliance (DS_UByte station)
 
virtual DS::Position getPosition (DS_UByte station)
 
virtual void readExtended (const QByteArray &data)
 
virtual DS_UByte getControlCode ()
 
virtual DS_UByte getRequestCode ()
 
virtual DS_UByte getFMSControlCode ()
 
virtual DS_UByte getTeamStationCode ()
 
virtual DS_UByte getJoystickSize (const DS::Joystick &joystick)
 
- Protected Member Functions inherited from Protocol
DS_Configconfig ()
 
DS_Joysticks * joysticks ()
 
virtual QByteArray getRadioPacket ()
 
virtual bool interpretRadioPacket (const QByteArray &data)
 

Private Attributes

bool m_restartCode
 
bool m_rebootRobot
 
bool m_sendDateTime
 

Detailed Description

Implements the FRC 2015-2019 communication protocol.

Constructor & Destructor Documentation

FRC_2015::FRC_2015 ( )
explicit

Implements the 2015 FRC Communication protocol

Member Function Documentation

int FRC_2015::fmsFrequency ( )
virtual

Send 2 FMS packets every second

Reimplemented from Protocol.

int FRC_2015::fmsInputPort ( )
virtual

We receive data from FMS at local port 1120

Reimplemented from Protocol.

int FRC_2015::fmsOutputPort ( )
virtual

We send data to the FMS to remote port 1160

Reimplemented from Protocol.

DS::SocketType FRC_2015::fmsSocketType ( )
virtual

FMS communications work with UDP datagrams

Reimplemented from Protocol.

References DS::kSocketTypeUDP.

DS::Alliance FRC_2015::getAlliance ( DS_UByte  station)
protectedvirtual

This function returns the alliance color referenced by the given station code. This function is used to follow the instructions outlined by the FMS packets.

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

DS_UByte FRC_2015::getControlCode ( )
protectedvirtual

Returns the control code sent to the robot. This code contains the following information:

  • The control mode of the robot (teleop, autonomous, test)
  • The enabled state of the robot
  • The FMS attached keyword
  • The operation state (e-stop, normal)

References DS::kControlAutonomous, DS::kControlTeleoperated, and DS::kControlTest.

DS_UByte FRC_2015::getFMSControlCode ( )
protectedvirtual

Returns the control code sent to the FMS. This code is very similar to the control code sent to the robot, however, it contains addional information regarding the robot radio.

This code contains the following information:

  • The control mode of the robot (teleop, autonomous, test)
  • The enabled state of the robot
  • The FMS attached keyword
  • Robot radio connected?
  • The operation state (e-stop, normal)

References DS::kControlAutonomous, DS::kControlTeleoperated, and DS::kControlTest.

QByteArray FRC_2015::getFMSPacket ( )
virtual

Generates a packet that the DS will send to the FMS

Reimplemented from Protocol.

QByteArray FRC_2015::getJoystickData ( )
protectedvirtual

Constructs a joystick information structure for every attached joystick. Unlike the 2014 protocol, the 2015 protocol only generates joystick data for the attached joysticks.

This information is separated with a joystick header code (specified at the top of this file).

DS_UByte FRC_2015::getJoystickSize ( const DS::Joystick joystick)
protectedvirtual

Returns the size of the given joystick. This function is used to generate joystick data (which is sent to the robot).

This information will help the robot decide where a information starts and ends for each attached joystick.

References DS::Joystick::numAxes, DS::Joystick::numButtons, and DS::Joystick::numPOVs.

DS::Position FRC_2015::getPosition ( DS_UByte  station)
protectedvirtual

This function returns the position referenced by the given station code. This function is used to follow the instructions outlined by the FMS packets.

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

DS_UByte FRC_2015::getRequestCode ( )
protectedvirtual

Generates the request code sent to the robot, which may instruct it to:

  • Operate normally
  • Reboot the RIO
  • Restart the robot code
QByteArray FRC_2015::getRobotPacket ( )
virtual

Generates a packet that the DS will send to the robot

Reimplemented from Protocol.

DS_UByte FRC_2015::getTeamStationCode ( )
protectedvirtual

Returns the team station code sent to the robot. This value may be used by the robot program to use specialized autonomous modes or adjust sensor input.

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

QByteArray FRC_2015::getTimezoneData ( )
protectedvirtual

Returns information regarding the current date and time and the timezone of the client computer.

The robot may ask for this information in some cases (e.g. when initializing the robot code).

References DS::timezone().

bool FRC_2015::interpretFMSPacket ( const QByteArray &  data)
virtual

Interprets the packet and follows the instructions sent by the FMS. Possible instructions are:

  • Change robot control mode
  • Change robot enabled status
  • Change team alliance
  • Change team position

Reimplemented from Protocol.

References DS::kControlAutonomous, DS::kControlTeleoperated, and DS::kControlTest.

bool FRC_2015::interpretRobotPacket ( const QByteArray &  data)
virtual

Interprets the received data and updates DS values as needed. From the received information, we can extract:

  • The robot voltage
  • Code state of the robot
  • Control mode of the robot
  • If the robot is emergency stopped
  • If the robot is experiencing a voltage brownout

Reimplemented from Protocol.

int FRC_2015::maxAxisCount ( )
virtual

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

Reimplemented from Protocol.

int FRC_2015::maxButtonCount ( )
virtual

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

Reimplemented from Protocol.

int FRC_2015::maxJoystickCount ( )
virtual

FRC 2015 Protocol supports a maximum of 6 joysticks. Remaining joysticks will be ignored.

Reimplemented from Protocol.

int FRC_2015::maxPOVCount ( )
virtual

FRC 2015 protocol supports only 1 POV. Remaining POVs will be ignored.

Reimplemented from Protocol.

QString FRC_2015::name ( )
virtual

Returns the display name of the protocol

Reimplemented from Protocol.

Reimplemented in FRC_2016.

int FRC_2015::netconsoleInputPort ( )
virtual

We received broadcasted messages from the robot in port 6666

Reimplemented from Protocol.

qreal FRC_2015::nominalBatteryAmperage ( )
virtual

Returns the nominal amperage given by the robot battery

Reimplemented from Protocol.

qreal FRC_2015::nominalBatteryVoltage ( )
virtual

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

void FRC_2015::onRobotWatchdogExpired ( )
virtual

Do not reboot robot or restart code when we re-establish communications with the robot.

Reimplemented from Protocol.

QString FRC_2015::radioAddress ( )
virtual

Default radio address is 10.TE.AM.1

Reimplemented from Protocol.

References DS::getStaticIP().

void FRC_2015::readExtended ( const QByteArray &  data)
protectedvirtual

Sometimes, the roboRIO will send us additional information, such as CPU usage and CAN metrics. This function is in charge of extracting this information from the packet and updating DS values accordingly.

void FRC_2015::rebootRobot ( )
virtual

Reboots the robot in the next packet cycle

Reimplemented from Protocol.

void FRC_2015::restartRobotCode ( )
virtual

Restarts the robot code in the next packet cycle

Reimplemented from Protocol.

QString FRC_2015::robotAddress ( )
virtual

Default robot address is roboRIO-TEAM.local

Reimplemented from Protocol.

Reimplemented in FRC_2016.

int FRC_2015::robotFrequency ( )
virtual

Send 50 robot packets every second

Reimplemented from Protocol.

int FRC_2015::robotInputPort ( )
virtual

We receive data from the robot at local port 1150

Reimplemented from Protocol.

int FRC_2015::robotOutputPort ( )
virtual

We send data to the robot at remote port 1110

Reimplemented from Protocol.

DS::SocketType FRC_2015::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: