Class RefSerial

Inheritance Relationships

Base Types

Class Documentation

class RefSerial : public tap::communication::serial::DJISerial, public tap::communication::serial::RefSerialData

A class designed to communicate with the 2021 version of the RoboMaster referee system. Supports decoding various referee serial message types. Also supports sending custom UI messages to the referee serial and sending custom robot to robot communication.

For information about the protocol that this serial parser/decoder uses, view RoboMaster’s ref serial website: https://www.robomaster.com/en-US/products/components/referee (in the Document Download tab).

Receive information from the referee serial by continuously calling messageReceiveCallback. Access data sent by the referee serial by calling getRobotData or getGameData.

Note

use the instance stored in the Drivers to interact with this class (you shouldn’t be declaring your own RefSerial object).

Public Types

enum MessageType

RX message type defines, referred to as “Command ID”s in the RoboMaster Ref System Protocol Appendix. Ignored message types commented out because they are not handled by this parser yet. They are values that are used in message headers to indicate the type of message we have received.

Current Ref Serial Version: 1.6.1 Updated April 2024.

Values:

enumerator REF_MESSAGE_TYPE_GAME_STATUS
enumerator REF_MESSAGE_TYPE_GAME_RESULT
enumerator REF_MESSAGE_TYPE_ALL_ROBOT_HP
enumerator REF_MESSAGE_TYPE_SITE_EVENT_DATA
enumerator REF_MESSAGE_TYPE_PROJECTILE_SUPPPLIER_ACTION
enumerator REF_MESSAGE_TYPE_WARNING_DATA
enumerator REF_MESSAGE_TYPE_DART_INFO
enumerator REF_MESSAGE_TYPE_ROBOT_STATUS
enumerator REF_MESSAGE_TYPE_POWER_AND_HEAT
enumerator REF_MESSAGE_TYPE_ROBOT_POSITION
enumerator REF_MESSAGE_TYPE_ROBOT_BUFF_STATUS
enumerator REF_MESSAGE_TYPE_AERIAL_ENERGY_STATUS
enumerator REF_MESSAGE_TYPE_RECEIVE_DAMAGE
enumerator REF_MESSAGE_TYPE_PROJECTILE_LAUNCH
enumerator REF_MESSAGE_TYPE_BULLETS_REMAIN
enumerator REF_MESSAGE_TYPE_RFID_STATUS
enumerator REF_MESSAGE_TYPE_DART_STATION_INFO
enumerator REF_MESSAGE_TYPE_GROUND_ROBOT_POSITION
enumerator REF_MESSAGE_TYPE_RADAR_PROGRESS
enumerator REF_MESSAGE_TYPE_SENTRY_INFO
enumerator REF_MESSAGE_TYPE_RADAR_INFO
enumerator REF_MESSAGE_TYPE_CUSTOM_DATA

Public Functions

RefSerial(Drivers *drivers)

Constructs a RefSerial class connected to bound_ports::REF_SERIAL_UART_PORT with CRC enforcement enabled.

See also

DjiSerial

~RefSerial() = default
virtual void messageReceiveCallback(const ReceivedSerialMessage &completeMessage) override

Handles the types of messages defined above in the RX message handlers section.

bool getRefSerialReceivingData() const
const Rx::RobotData &getRobotData() const

Returns a reference to the most up to date robot data struct.

const Rx::GameData &getGameData() const

Returns a reference to the most up to date game data struct.

RobotId getRobotIdBasedOnCurrentRobotTeam(RobotId id)

Returns a robot id that is of the same color of this robot’s ID. This allows you to specify you want to send to one robot and then based on your team it will be sent to the correct robot (your team not the enemy team’s robot).

void attachRobotToRobotMessageHandler(uint16_t msgId, RobotToRobotMessageHandler *handler)
inline bool acquireTransmissionSemaphore()

Used by RefSerialTransmitter. Attempts to acquire transmission semaphore.

Note

should be called only using RF_WAIT_UNTIL to block until acquiring semaphore.

inline void releaseTransmissionSemaphore(uint32_t sentMsgLen)
bool operatorBlinded() const
Returns:

True if the robot operator is blinded, false otherwise. Also return false if the referee system is offline.

Public Static Functions

static inline bool heatAndLimitValid(uint16_t heat, uint16_t heatLimit)
Returns:

True if the specified heat and heatLimit values are “valid”. These values are valid if they aren’t 0xffff and if the heatLimit is not 0.