Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
MultimediaBoard Class Reference

This class handles communication with the multimedia board on the rover by sending RoveComm packets over the network. More...

#include <MultimediaBoard.h>

Collaboration diagram for MultimediaBoard:

Classes

struct  RGB
 This struct serves as a container for RGB values, and provides a few overridden constructors for converting from hex to 8-bit RGB values. More...
 

Public Types

enum class  MultimediaBoardLightingState {
  eOff = -2 , eCustom , eTeleOp , eAutonomy ,
  eReachedGoal
}
 

Public Member Functions

 MultimediaBoard ()
 Construct a new Multimedia Board:: Multimedia Board object.
 
 ~MultimediaBoard ()
 Destroy the Multimedia Board:: Multimedia Board object.
 
void SendLightingState (MultimediaBoardLightingState eState)
 Sends a predetermined color pattern to board.
 
void SendRGB (RGB stRGBVal)
 Send a custom RGB value to the board.
 
MultimediaBoardLightingState GetCurrentLightingState () const
 Accessor for the current lighting state of the multimedia board.
 
RGB GetCustomLightingValues () const
 Accessor for the current custom lighting RGB values.
 

Private Attributes

MultimediaBoardLightingState m_eCurrentLightingState
 
RGB m_stCustomRGBValues
 

Detailed Description

This class handles communication with the multimedia board on the rover by sending RoveComm packets over the network.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-23

Member Enumeration Documentation

◆ MultimediaBoardLightingState

enum class MultimediaBoard::MultimediaBoardLightingState
strong
96 {
97 eOff = -2, // LED panel off.
98 eCustom, // A custom value has been set or board should go back to a previously custom set value.
99 eTeleOp, // TeleOp color = BLUE
100 eAutonomy, // Autonomy color = RED
101 eReachedGoal // Goal reached = FLASH GREEN
102 };

Constructor & Destructor Documentation

◆ MultimediaBoard()

MultimediaBoard::MultimediaBoard ( )

Construct a new Multimedia Board:: Multimedia Board object.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-23
28{
29 // Initialize member variables.
30 m_eCurrentLightingState = MultimediaBoardLightingState::eOff;
31}

◆ ~MultimediaBoard()

MultimediaBoard::~MultimediaBoard ( )

Destroy the Multimedia Board:: Multimedia Board object.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-23
41{
42 // Send RGB 0, 0, 0 to multimedia board to turn LED panel off.
43 this->SendLightingState(MultimediaBoardLightingState::eOff);
44}
void SendLightingState(MultimediaBoardLightingState eState)
Sends a predetermined color pattern to board.
Definition MultimediaBoard.cpp:55
Here is the call graph for this function:

Member Function Documentation

◆ SendLightingState()

void MultimediaBoard::SendLightingState ( MultimediaBoardLightingState  eState)

Sends a predetermined color pattern to board.

Parameters
eState- The lighting state. Enum defined in header file for MultimediaBoard.h
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-23
56{
57 // Update member variables.
58 m_eCurrentLightingState = eState;
59
60 // Create new RoveCommPacket. Will be constructed in enum.
61 rovecomm::RoveCommPacket<uint8_t> stCorePacket;
62 rovecomm::RoveCommPacket<uint8_t> stTelemPacket;
63
64 // Decide what lighting operation to execute.
65 switch (eState)
66 {
67 case MultimediaBoardLightingState::eOff:
68 {
69 // Construct a RoveComm packet with the lighting data.
70 stCorePacket.unDataId = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_ID;
71 stCorePacket.unDataCount = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_COUNT;
72 stCorePacket.eDataType = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_TYPE;
73 // Use RoveComm to send 0, 0, 0 RGB values.
74 stCorePacket.vData.emplace_back(0);
75 stCorePacket.vData.emplace_back(0);
76 stCorePacket.vData.emplace_back(0);
77 break;
78 }
79 case MultimediaBoardLightingState::eCustom:
80 {
81 // Use RoveComm to send old custom values previously set.
82 this->SendRGB(m_stCustomRGBValues);
83 break;
84 }
85 case MultimediaBoardLightingState::eTeleOp:
86 {
87 // Send Reached Goal state over RoveComm.
88 stTelemPacket.unDataId = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_ID;
89 stTelemPacket.unDataCount = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_COUNT;
90 stTelemPacket.eDataType = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_TYPE;
91 stTelemPacket.vData.emplace_back(static_cast<uint8_t>(manifest::Core::DISPLAYSTATE::TELEOP));
92 // Construct a RoveComm packet with the lighting data.
93 stCorePacket.unDataId = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_ID;
94 stCorePacket.unDataCount = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_COUNT;
95 stCorePacket.eDataType = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_TYPE;
96 // Use RoveComm to send BLUE color state value.
97 stCorePacket.vData.emplace_back(static_cast<uint8_t>(manifest::Core::DISPLAYSTATE::TELEOP));
98 break;
99 }
100 case MultimediaBoardLightingState::eAutonomy:
101 {
102 // Send Reached Goal state over RoveComm.
103 stTelemPacket.unDataId = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_ID;
104 stTelemPacket.unDataCount = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_COUNT;
105 stTelemPacket.eDataType = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_TYPE;
106 stTelemPacket.vData.emplace_back(static_cast<uint8_t>(manifest::Core::DISPLAYSTATE::AUTONOMY));
107 // Construct a RoveComm packet with the lighting data.
108 stCorePacket.unDataId = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_ID;
109 stCorePacket.unDataCount = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_COUNT;
110 stCorePacket.eDataType = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_TYPE;
111 // Use RoveComm to send RED color state value.
112 stCorePacket.vData.emplace_back(static_cast<uint8_t>(manifest::Core::DISPLAYSTATE::AUTONOMY));
113 break;
114 }
115 case MultimediaBoardLightingState::eReachedGoal:
116 {
117 // Send Reached Goal state over RoveComm.
118 stTelemPacket.unDataId = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_ID;
119 stTelemPacket.unDataCount = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_COUNT;
120 stTelemPacket.eDataType = manifest::Autonomy::TELEMETRY.find("STATEDISPLAY")->second.DATA_TYPE;
121 stTelemPacket.vData.emplace_back(static_cast<uint8_t>(manifest::Core::DISPLAYSTATE::REACHED_GOAL));
122 // Construct a RoveComm packet with the lighting data.
123 stCorePacket.unDataId = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_ID;
124 stCorePacket.unDataCount = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_COUNT;
125 stCorePacket.eDataType = manifest::Core::COMMANDS.find("STATEDISPLAY")->second.DATA_TYPE;
126 stCorePacket.vData.clear();
127 // Use RoveComm to send flashing GREEN color state value.
128 stCorePacket.vData.emplace_back(static_cast<uint8_t>(manifest::Core::DISPLAYSTATE::REACHED_GOAL));
129 break;
130 }
131 default:
132 {
133 // Construct a RoveComm packet with the lighting data.
134 stCorePacket.unDataId = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_ID;
135 stCorePacket.unDataCount = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_COUNT;
136 stCorePacket.eDataType = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_TYPE;
137 // Send lighting state over RoveComm.
138 stCorePacket.vData.emplace_back(0);
139 stCorePacket.vData.emplace_back(0);
140 stCorePacket.vData.emplace_back(0);
141 break;
142 }
143 }
144
145 // Check if we should send packets to the SIM or board.
146 const char* cIPAddress = constants::MODE_SIM ? constants::SIM_IP_ADDRESS.c_str() : manifest::Core::IP_ADDRESS.IP_STR.c_str();
147 // Send multimedia board lighting state to board over RoveComm.
148 if (network::g_pRoveCommUDPNode)
149 {
150 network::g_pRoveCommUDPNode->SendUDPPacket(stCorePacket, cIPAddress, constants::ROVECOMM_OUTGOING_UDP_PORT);
151 network::g_pRoveCommUDPNode->SendUDPPacket(stTelemPacket, cIPAddress, constants::ROVECOMM_OUTGOING_UDP_PORT);
152 }
153}
void SendRGB(RGB stRGBVal)
Send a custom RGB value to the board.
Definition MultimediaBoard.cpp:163
::uint8_t uint8_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendRGB()

void MultimediaBoard::SendRGB ( RGB  stRGBVal)

Send a custom RGB value to the board.

Parameters
stRGBVal- RGB struct containing color information.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-23
164{
165 // Update custom RGB values.
166 m_stCustomRGBValues = stRGBVal;
167 // Update internal lighting state.
168 m_eCurrentLightingState = MultimediaBoardLightingState::eCustom;
169
170 // Construct a RoveComm packet with the lighting data.
171 rovecomm::RoveCommPacket<uint8_t> stPacket;
172 stPacket.unDataId = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_ID;
173 stPacket.unDataCount = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_COUNT;
174 stPacket.eDataType = manifest::Core::COMMANDS.find("LEDRGB")->second.DATA_TYPE;
175 stPacket.vData.emplace_back(stRGBVal.dRed);
176 stPacket.vData.emplace_back(stRGBVal.dGreen);
177 stPacket.vData.emplace_back(stRGBVal.dBlue);
178 // Check if we should send packets to the SIM or board.
179 const char* cIPAddress = constants::MODE_SIM ? constants::SIM_IP_ADDRESS.c_str() : manifest::Core::IP_ADDRESS.IP_STR.c_str();
180 // Send RGB values to multimedia board over RoveComm.
181 if (network::g_pRoveCommUDPNode)
182 {
183 network::g_pRoveCommUDPNode->SendUDPPacket(stPacket, cIPAddress, constants::ROVECOMM_OUTGOING_UDP_PORT);
184 }
185}
Here is the caller graph for this function:

◆ GetCurrentLightingState()

MultimediaBoard::MultimediaBoardLightingState MultimediaBoard::GetCurrentLightingState ( ) const

Accessor for the current lighting state of the multimedia board.

Returns
MultimediaBoard::MultimediaBoardLightingState - An enumerator value representing the current lighting state of the board.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-03
197{
198 // Return the current lighting state.
199 return m_eCurrentLightingState;
200}

◆ GetCustomLightingValues()

MultimediaBoard::RGB MultimediaBoard::GetCustomLightingValues ( ) const

Accessor for the current custom lighting RGB values.

Returns
MultimediaBoard::RGB - The custom lighting values stored in an RGB struct.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-03
211{
212 // Return the currently stored custom lighting values.
213 return m_stCustomRGBValues;
214}

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