Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::communication::serial::RefSerialTransmitter Class Reference

#include <ref_serial_transmitter.hpp>

Inheritance diagram for tap::communication::serial::RefSerialTransmitter:
Collaboration diagram for tap::communication::serial::RefSerialTransmitter:

Public Member Functions

 RefSerialTransmitter (Drivers *drivers)
 
mockable modm::ResumableResult< void > deleteGraphicLayer (Tx::DeleteGraphicOperation graphicOperation, uint8_t graphicLayer)
 
mockable modm::ResumableResult< void > sendRobotToRobotMsg (Tx::RobotToRobotMessage *robotToRobotMsg, uint16_t msgId, RobotId receiverId, uint16_t msgLen)
 
mockable modm::ResumableResult< void > sendGraphic (Tx::Graphic1Message *graphicMsg, bool configMsgHeader=true, bool sendMsg=true)
 
mockable modm::ResumableResult< void > sendGraphic (Tx::Graphic2Message *graphicMsg, bool configMsgHeader=true, bool sendMsg=true)
 
mockable modm::ResumableResult< void > sendGraphic (Tx::Graphic5Message *graphicMsg, bool configMsgHeader=true, bool sendMsg=true)
 
mockable modm::ResumableResult< void > sendGraphic (Tx::Graphic7Message *graphicMsg, bool configMsgHeader=true, bool sendMsg=true)
 
mockable modm::ResumableResult< void > sendGraphic (Tx::GraphicCharacterMessage *graphicMsg, bool configMsgHeader=true, bool sendMsg=true)
 

Static Public Member Functions

static void configGraphicGenerics (Tx::GraphicData *graphicData, const uint8_t *name, Tx::GraphicOperation operation, uint8_t layer, Tx::GraphicColor color)
 
static void configLine (uint16_t width, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, Tx::GraphicData *sharedData)
 
static void configRectangle (uint16_t width, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, Tx::GraphicData *sharedData)
 
static void configCircle (uint16_t width, uint16_t centerX, uint16_t centerY, uint16_t radius, Tx::GraphicData *sharedData)
 
static void configEllipse (uint16_t width, uint16_t centerX, uint16_t centerY, uint16_t xLen, uint16_t yLen, Tx::GraphicData *sharedData)
 
static void configArc (uint16_t startAngle, uint16_t endAngle, uint16_t width, uint16_t centerX, uint16_t centerY, uint16_t xLen, uint16_t yLen, Tx::GraphicData *sharedData)
 
static void configFloatingNumber (uint16_t fontSize, uint16_t decimalPrecision, uint16_t width, uint16_t startX, uint16_t startY, float value, Tx::GraphicData *sharedData)
 
static void configInteger (uint16_t fontSize, uint16_t width, uint16_t startX, uint16_t startY, int32_t value, Tx::GraphicData *sharedData)
 
static void configCharacterMsg (uint16_t fontSize, uint16_t width, uint16_t startX, uint16_t startY, const char *dataToPrint, Tx::GraphicCharacterMessage *sharedData)
 
static void configFrameHeader (DJISerial::FrameHeader *header, uint16_t msgLen)
 
static void configInteractiveHeader (Tx::InteractiveHeader *header, uint16_t cmdId, RobotId senderId, uint16_t receiverId)
 
- Static Public Member Functions inherited from tap::communication::serial::RefSerialData
static bool isBlueTeam (RobotId id)
 

Additional Inherited Members

- Public Types inherited from tap::communication::serial::RefSerialData
enum class  RobotId : uint16_t {
  INVALID = 0 , RED_HERO = 1 , RED_ENGINEER = 2 , RED_SOLDIER_1 = 3 ,
  RED_SOLDIER_2 = 4 , RED_SOLDIER_3 = 5 , RED_DRONE = 6 , RED_SENTINEL = 7 ,
  RED_DART = 8 , RED_RADAR_STATION = 9 , BLUE_HERO = 101 , BLUE_ENGINEER = 102 ,
  BLUE_SOLDIER_1 = 103 , BLUE_SOLDIER_2 = 104 , BLUE_SOLDIER_3 = 105 , BLUE_DRONE = 106 ,
  BLUE_SENTINEL = 107 , BLUE_DART = 108 , BLUE_RADAR_STATION = 109
}
 

Detailed Description

Encapsulates logic for sending messages to the referee system. This includes sending robot-to-robot communication messages and UI drawing instructions to the RoboMaster client.

The instance member functions of this class that return a modm::ResumableResult<void> must be used in a protothread or resumable function. In other words, member functions such as sendGraphic must be in a call of PT_CALL or RF_CALL.

This transmitter allows the user to send data to the referee system from multiple protothreads. An instance of the ref serial transmitter should be instantiated for each protothread. If unique instances are not used, behavior is undefined.

Constructor & Destructor Documentation

◆ RefSerialTransmitter()

tap::communication::serial::RefSerialTransmitter::RefSerialTransmitter ( Drivers drivers)

Member Function Documentation

◆ configArc()

void tap::communication::serial::RefSerialTransmitter::configArc ( uint16_t  startAngle,
uint16_t  endAngle,
uint16_t  width,
uint16_t  centerX,
uint16_t  centerY,
uint16_t  xLen,
uint16_t  yLen,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with an arc graphic whose parameters are specified.

Parameters
[out]sharedDataThe graphic data struct to configure.

◆ configCharacterMsg()

void tap::communication::serial::RefSerialTransmitter::configCharacterMsg ( uint16_t  fontSize,
uint16_t  width,
uint16_t  startX,
uint16_t  startY,
const char *  dataToPrint,
Tx::GraphicCharacterMessage *  sharedData 
)
static

Configures a character message in the passed in GraphicCharacterMessage.

Recommended font size and line width ratio is 10:1.

Parameters
[out]sharedDataThe message to configure.

◆ configCircle()

void tap::communication::serial::RefSerialTransmitter::configCircle ( uint16_t  width,
uint16_t  centerX,
uint16_t  centerY,
uint16_t  radius,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with a circle graphic whose parameters are specified.

Parameters
[out]sharedDataThe graphic data struct to configure.

◆ configEllipse()

void tap::communication::serial::RefSerialTransmitter::configEllipse ( uint16_t  width,
uint16_t  centerX,
uint16_t  centerY,
uint16_t  xLen,
uint16_t  yLen,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with an ellipse graphic whose parameters are specified.

Parameters
[out]sharedDataThe graphic data struct to configure.

◆ configFloatingNumber()

void tap::communication::serial::RefSerialTransmitter::configFloatingNumber ( uint16_t  fontSize,
uint16_t  decimalPrecision,
uint16_t  width,
uint16_t  startX,
uint16_t  startY,
float  value,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with a floating point number.

Recommended font size and line width ratio is 10:1.

Note
This function doesn't work because of known issues in the referee system server.
Parameters
[out]sharedDataThe graphic data struct to configure.

◆ configFrameHeader()

void tap::communication::serial::RefSerialTransmitter::configFrameHeader ( DJISerial::FrameHeader header,
uint16_t  msgLen 
)
static

Properly constructs the frame header and places it in the passed in header.

Parameters
[out]headerThe frame header struct to store the constructed frame header.
[in]msgLenThe length of the message. This includes only the length of the data and not the length of the cmdId or frame tail.

◆ configGraphicGenerics()

void tap::communication::serial::RefSerialTransmitter::configGraphicGenerics ( Tx::GraphicData *  graphicData,
const uint8_t *  name,
Tx::GraphicOperation  operation,
uint8_t  layer,
Tx::GraphicColor  color 
)
static

Configures the graphicData with all data generic to the type of graphic being configured.

For sending graphics, the general schema is to create a Graphic<n>Message struct, configure the individual GraphicData structs in the graphic message using the configGraphicGenerics and then config<Line|Rectangle|Circle|etc.> functions. Finally, send the graphic message using sendGraphic.

For example, to configure and send a line graphic (refSerialTransmitter is a pointer to a RefSerialTransmitter object):

Graphic1Message msg;
&msg.graphicData,
"\x00\x00\x01",
RefSerial::GRAPHIC_ADD,1,
YELLOW);
RefSerialTransmitter::configLine(4, 100, 100, 200, 200, &msg.graphicData);
refSerialTransmitter->sendGraphic(&msg);
static void configLine(uint16_t width, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY, Tx::GraphicData *sharedData)
Definition ref_serial_transmitter.cpp:50
static void configGraphicGenerics(Tx::GraphicData *graphicData, const uint8_t *name, Tx::GraphicOperation operation, uint8_t layer, Tx::GraphicColor color)
Definition ref_serial_transmitter.cpp:37
Parameters
[out]graphicDataThe structure where generic data will be stored.
[in]nameThe name of the graphic.
[in]operationThe graphic operation to be done (add/remove, etc).
[in]layerThe graphic layer the graphic will be located at. Must be between 0-9
[in]colorThe color of the graphic.

◆ configInteger()

void tap::communication::serial::RefSerialTransmitter::configInteger ( uint16_t  fontSize,
uint16_t  width,
uint16_t  startX,
uint16_t  startY,
int32_t  value,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with an integer.

Recommended font size and line width ratio is 10:1.

Note
This function doesn't display negative numbers properly because of known issues in the referee system server.
Parameters
[out]sharedDataThe graphic data struct to configure.

◆ configInteractiveHeader()

void tap::communication::serial::RefSerialTransmitter::configInteractiveHeader ( Tx::InteractiveHeader *  header,
uint16_t  cmdId,
RobotId  senderId,
uint16_t  receiverId 
)
static

◆ configLine()

void tap::communication::serial::RefSerialTransmitter::configLine ( uint16_t  width,
uint16_t  startX,
uint16_t  startY,
uint16_t  endX,
uint16_t  endY,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with a line graphic whose parameters are specified.

Parameters
[out]sharedDataThe graphic data struct to configure.

◆ configRectangle()

void tap::communication::serial::RefSerialTransmitter::configRectangle ( uint16_t  width,
uint16_t  startX,
uint16_t  startY,
uint16_t  endX,
uint16_t  endY,
Tx::GraphicData *  sharedData 
)
static

Configures sharedData with a rectangle graphic whose parameters are specified.

Parameters
[out]sharedDataThe graphic data struct to configure.

◆ deleteGraphicLayer()

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::deleteGraphicLayer ( Tx::DeleteGraphicOperation  graphicOperation,
uint8_t  graphicLayer 
)

Deletes an entire graphic layer or the entire screen

Parameters
[in]graphicOperationWhether to delete a single layer or the entire screen.
[in]graphicLayerThe layer to remove. Must be between 0-9

◆ sendGraphic() [1/5]

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::sendGraphic ( Tx::Graphic1Message *  graphicMsg,
bool  configMsgHeader = true,
bool  sendMsg = true 
)

This function and the ones below all configure the message header and sends the specified message struct to the referee system unless configMsgHeader or sendMsg are false.

Parameters
[in]graphicMsgThe graphic message to send. Note that this struct is updated with header information in this function.
[in]configMsgHeaderWhether or not to update the graphicMsg's header information.
[in]sendMsgWhether or not to send the message.
Todo:
template instantiation?

◆ sendGraphic() [2/5]

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::sendGraphic ( Tx::Graphic2Message *  graphicMsg,
bool  configMsgHeader = true,
bool  sendMsg = true 
)

◆ sendGraphic() [3/5]

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::sendGraphic ( Tx::Graphic5Message *  graphicMsg,
bool  configMsgHeader = true,
bool  sendMsg = true 
)

◆ sendGraphic() [4/5]

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::sendGraphic ( Tx::Graphic7Message *  graphicMsg,
bool  configMsgHeader = true,
bool  sendMsg = true 
)

◆ sendGraphic() [5/5]

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::sendGraphic ( Tx::GraphicCharacterMessage *  graphicMsg,
bool  configMsgHeader = true,
bool  sendMsg = true 
)

◆ sendRobotToRobotMsg()

modm::ResumableResult< void > tap::communication::serial::RefSerialTransmitter::sendRobotToRobotMsg ( Tx::RobotToRobotMessage *  robotToRobotMsg,
uint16_t  msgId,
RobotId  receiverId,
uint16_t  msgLen 
)

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