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
WaypointHandler Class Reference

The WaypointHandler class is used throughout the entire project (mainly by the state machine) to globally store a list of waypoints that the rover will navigate to. More...

#include <WaypointHandler.h>

Public Member Functions

 WaypointHandler ()
 Construct a new geoops::Waypoint Handler:: geoops::Waypoint Handler obstacle.
 
 ~WaypointHandler ()
 Destroy the geoops::Waypoint Handler:: geoops::Waypoint Handler obstacle.
 
void AddWaypoint (const geoops::Waypoint &stWaypoint)
 Append a waypoint to the end of the WaypointHandler's list.
 
void AddWaypoint (const geoops::GPSCoordinate &stLocation, const geoops::WaypointType &eType, const double dRadius=0.0)
 Append a waypoint to the end of the WaypointHandler's list.
 
void AddWaypoint (const geoops::UTMCoordinate &stLocation, const geoops::WaypointType &eType, const double dRadius=0.0)
 Append a waypoint to the end of the WaypointHandler's list.
 
void StorePath (const std::string &szPathName, const std::vector< geoops::Waypoint > &vWaypointPath)
 Store a path in the WaypointHandler.
 
void StorePath (const std::string &szPathName, const std::vector< geoops::GPSCoordinate > &vLocationPath)
 Store a path in the WaypointHandler.
 
void StorePath (const std::string &szPathName, const std::vector< geoops::UTMCoordinate > &vLocationPath)
 Store a path in the WaypointHandler.
 
void AddObstacle (const geoops::Waypoint &stWaypoint)
 Append a new obstacle to the WaypointHandler obstacle list.
 
void AddObstacle (const geoops::GPSCoordinate &stLocation, const double dRadius=0.0)
 Append a new obstacle to the WaypointHandler obstacle list.
 
void AddObstacle (const geoops::UTMCoordinate &stLocation, const double dRadius=0.0)
 Append a new obstacle to the WaypointHandler obstacle list.
 
void DeleteWaypoint (const long unsigned int nIndex)
 Delete the geoops::Waypoint at a given index from the waypoint handler.
 
void DeleteWaypoint (const geoops::Waypoint &stWaypoint)
 Delete a waypoint from the WaypointHandler given a matching waypoint. Any waypoint in the list that matches the given one will be removed.
 
void DeleteWaypoint (const geoops::GPSCoordinate &stLocation)
 Delete a waypoint from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.
 
void DeleteWaypoint (const geoops::UTMCoordinate &stLocation)
 Delete a waypoint from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.
 
bool DeletePath (const std::string &szPathName)
 Delete the path vector stored at the given key.
 
void DeleteObstacle (const long unsigned int nIndex)
 Delete the obstacle at a given index from the waypoint handler obstacle list.
 
void DeleteObstacle (const geoops::Waypoint &stWaypoint)
 Delete an obstacle from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.
 
void DeleteObstacle (const geoops::GPSCoordinate &stLocation)
 Delete an obstacle from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.
 
void DeleteObstacle (const geoops::UTMCoordinate &stLocation)
 Delete an obstacle from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.
 
void ClearWaypoints ()
 Clears/deletes all Waypoints stored in the WaypointHandler.
 
void ClearPaths ()
 Clears/deletes all keys and paths store in the WaypointHandler.
 
void ClearObstacles ()
 Clears/deletes all permanent objects stored in the WaypointHandler.
 
geoops::Waypoint PopNextWaypoint ()
 Removes and returns the next waypoint at the front of the list.
 
const geoops::Waypoint PeekNextWaypoint ()
 Returns an immutable reference to the geoops::Waypoint struct at the front of the list without removing it.
 
const geoops::Waypoint RetrieveWaypointAtIndex (const long unsigned int nIndex)
 Retrieve an immutable reference to the waypoint at the given index.
 
const std::vector< geoops::WaypointRetrievePath (const std::string &szPathName)
 Retrieve an immutable reference to the path at the given path name/key.
 
const geoops::Waypoint RetrieveObstacleAtIndex (const long unsigned int nIndex)
 Retrieve an immutable reference to the obstacle at the given index.
 
const std::vector< geoops::WaypointGetAllWaypoints ()
 Accessor for the full list of current waypoints stored in the WaypointHandler.
 
const std::vector< geoops::WaypointGetAllObstacles ()
 Accessor for the full list of current obstacle stored in the WaypointHandler.
 
int GetWaypointCount ()
 Accessor for the number of elements on the WaypointHandler's waypoint vector.
 
int GetPathsCount ()
 Accessor for the number of paths stored in the WaypointHandler.
 
int GetObstaclesCount ()
 Accessor for the number of elements on the WaypointHandler's obstacle vector.
 

Private Attributes

std::vector< geoops::Waypointm_vWaypointList
 
std::shared_mutex m_muWaypointsMutex
 
std::unordered_map< std::string, std::vector< geoops::Waypoint > > m_umStoredPaths
 
std::shared_mutex m_muPathMutex
 
std::vector< geoops::Waypointm_vPermanentObstacles
 
std::shared_mutex m_muObstaclesMutex
 
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddPositionLegCallback
 Callback function that is called whenever RoveComm receives new ADDPOSITIONLEG packet.
 
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddMarkerLegCallback
 Callback function that is called whenever RoveComm receives new ADDMARKERLEG packet.
 
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddObjectLegCallback
 Callback function that is called whenever RoveComm receives new ADDOBJECTLEG packet.
 
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddObstacleCallback
 Callback function that is called whenever RoveComm receives new ADDOBSTACLE packet.
 
const std::function< void(const rovecomm::RoveCommPacket< uint8_t > &, const sockaddr_in &)> ClearWaypointsCallback
 Callback function that is called whenever RoveComm receives new CLEARWAYPOINTS packet.
 
const std::function< void(const rovecomm::RoveCommPacket< uint8_t > &, const sockaddr_in &)> ClearObstaclesCallback
 Callback function that is called whenever RoveComm receives new CLEAROBSTACLES packet.
 

Detailed Description

The WaypointHandler class is used throughout the entire project (mainly by the state machine) to globally store a list of waypoints that the rover will navigate to.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-02

Constructor & Destructor Documentation

◆ WaypointHandler()

WaypointHandler::WaypointHandler ( )

Construct a new geoops::Waypoint Handler:: geoops::Waypoint Handler obstacle.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-02
30{
31 // Set RoveComm callbacks.
32 network::g_pRoveCommUDPNode->AddUDPCallback<double>(AddPositionLegCallback, manifest::Autonomy::COMMANDS.find("ADDPOSITIONLEG")->second.DATA_ID);
33 network::g_pRoveCommUDPNode->AddUDPCallback<double>(AddMarkerLegCallback, manifest::Autonomy::COMMANDS.find("ADDMARKERLEG")->second.DATA_ID);
34 network::g_pRoveCommUDPNode->AddUDPCallback<double>(AddObjectLegCallback, manifest::Autonomy::COMMANDS.find("ADDOBJECTLEG")->second.DATA_ID);
35 network::g_pRoveCommUDPNode->AddUDPCallback<double>(AddObstacleCallback, manifest::Autonomy::COMMANDS.find("ADDOBSTACLE")->second.DATA_ID);
36 network::g_pRoveCommUDPNode->AddUDPCallback<uint8_t>(ClearWaypointsCallback, manifest::Autonomy::COMMANDS.find("CLEARWAYPOINTS")->second.DATA_ID);
37 network::g_pRoveCommUDPNode->AddUDPCallback<uint8_t>(ClearObstaclesCallback, manifest::Autonomy::COMMANDS.find("CLEAROBSTACLES")->second.DATA_ID);
38}
const std::function< void(const rovecomm::RoveCommPacket< uint8_t > &, const sockaddr_in &)> ClearObstaclesCallback
Callback function that is called whenever RoveComm receives new CLEAROBSTACLES packet.
Definition WaypointHandler.h:335
const std::function< void(const rovecomm::RoveCommPacket< uint8_t > &, const sockaddr_in &)> ClearWaypointsCallback
Callback function that is called whenever RoveComm receives new CLEARWAYPOINTS packet.
Definition WaypointHandler.h:310
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddMarkerLegCallback
Callback function that is called whenever RoveComm receives new ADDMARKERLEG packet.
Definition WaypointHandler.h:142
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddPositionLegCallback
Callback function that is called whenever RoveComm receives new ADDPOSITIONLEG packet.
Definition WaypointHandler.h:108
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddObstacleCallback
Callback function that is called whenever RoveComm receives new ADDOBSTACLE packet.
Definition WaypointHandler.h:261
const std::function< void(const rovecomm::RoveCommPacket< double > &, const sockaddr_in &)> AddObjectLegCallback
Callback function that is called whenever RoveComm receives new ADDOBJECTLEG packet.
Definition WaypointHandler.h:192
::uint8_t uint8_t

◆ ~WaypointHandler()

WaypointHandler::~WaypointHandler ( )

Destroy the geoops::Waypoint Handler:: geoops::Waypoint Handler obstacle.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-02
48{
49 // Nothing to destroy.
50}

Member Function Documentation

◆ AddWaypoint() [1/3]

void WaypointHandler::AddWaypoint ( const geoops::Waypoint stWaypoint)

Append a waypoint to the end of the WaypointHandler's list.

Parameters
stWaypoint- The WaypointHandler::geoops::Waypoint struct containing information about the waypoint to store in the handler.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-02
62{
63 // Acquire a write lock on the waypoint vector.
64 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
65 // Add waypoint to end of member variable vector.
66 m_vWaypointList.emplace_back(stWaypoint);
67}

◆ AddWaypoint() [2/3]

void WaypointHandler::AddWaypoint ( const geoops::GPSCoordinate stLocation,
const geoops::WaypointType &  eType,
const double  dRadius = 0.0 
)

Append a waypoint to the end of the WaypointHandler's list.

Parameters
stLocation- The location of the waypoint stored in a geoops namespace GPSCoordinate struct.
eType- The leg type of the waypoint signalling if this is a tag, navigation, obstacle, etc. waypoint.
dRadius- The circular area around the waypoint that should be counted as reaching the waypoint. Or obstacle radius.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
80{
81 // Construct a new waypoint struct from the given info.
82 geoops::Waypoint stTempWaypoint(stLocation, eType, dRadius);
83
84 // Acquire a write lock on the waypoint vector.
85 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
86 // Add waypoint to end of member variable vector.
87 m_vWaypointList.emplace_back(stTempWaypoint);
88}
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:423

◆ AddWaypoint() [3/3]

void WaypointHandler::AddWaypoint ( const geoops::UTMCoordinate stLocation,
const geoops::WaypointType &  eType,
const double  dRadius = 0.0 
)

Append a waypoint to the end of the WaypointHandler's list.

Parameters
stLocation- The location of the waypoint stored in a geoops namespace UTMCoordinate struct.
eType- The leg type of the waypoint signalling if this is a tag, navigation, obstacle, etc. waypoint.
dRadius- The circular area around the waypoint that should be counted as reaching the waypoint. Or obstacle radius.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
101{
102 // Construct a new waypoint struct from the given info.
103 geoops::Waypoint stTempWaypoint(stLocation, eType, dRadius);
104
105 // Acquire a write lock on the waypoint vector.
106 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
107 // Add waypoint to end of member variable vector.
108 m_vWaypointList.emplace_back(stTempWaypoint);
109}

◆ StorePath() [1/3]

void WaypointHandler::StorePath ( const std::string &  szPathName,
const std::vector< geoops::Waypoint > &  vWaypointPath 
)

Store a path in the WaypointHandler.

Parameters
szPathName- The key that will be used to store, and later reference, the path in the WaypointHandler.
vWaypointPath- A vector containing geoops::Waypoint structs with data about each point on the path.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
121{
122 // Acquire a write lock on the path unordered map.
123 std::unique_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
124 // Add vector of waypoint to map with the given string as a key.
125 m_umStoredPaths[szPathName] = vWaypointPath;
126}
Here is the caller graph for this function:

◆ StorePath() [2/3]

void WaypointHandler::StorePath ( const std::string &  szPathName,
const std::vector< geoops::GPSCoordinate > &  vLocationPath 
)

Store a path in the WaypointHandler.

Parameters
szPathName- The key that will be used to store, and later reference, the path in the WaypointHandler.
vWaypointPath- A vector containing GPSCoordinate structs containing location data about each point in the path.
Note
Paths must be stored in the WaypointHandler as a vector is geoops::Waypoint structs. This will create a new geoops::Waypoint struct for each GPSCoordinate and use a default type of eNavigationWaypoint with a radius of 0.0.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
141{
142 // Create instance variables.
143 std::vector<geoops::Waypoint> vWaypointPath;
144
145 // Loop through each GPSCoordinate in the given vector and repack the info into a geoops::Waypoint.
146 for (geoops::GPSCoordinate stLocation : vLocationPath)
147 {
148 // Create a new waypoint and store location info in it.
149 geoops::Waypoint stWaypoint(stLocation, geoops::WaypointType::eNavigationWaypoint);
150
151 // Append waypoint to the temporary waypoint path.
152 vWaypointPath.emplace_back(stWaypoint);
153 }
154
155 // Acquire a write lock on the path unordered map.
156 std::unique_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
157 // Add vector of waypoint to map with the given string as a key.
158 m_umStoredPaths[szPathName] = vWaypointPath;
159}
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:100

◆ StorePath() [3/3]

void WaypointHandler::StorePath ( const std::string &  szPathName,
const std::vector< geoops::UTMCoordinate > &  vLocationPath 
)

Store a path in the WaypointHandler.

Parameters
szPathName- The key that will be used to store, and later reference, the path in the WaypointHandler.
vWaypointPath- A vector containing UTMCoordinate structs containing location data about each point in the path.
Note
Paths must be stored in the WaypointHandler as a vector is geoops::Waypoint structs. This will create a new geoops::Waypoint struct for each UTMCoordinate and use a default type of eNavigationWaypoint with a radius of 0.0.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
174{
175 // Create instance variables.
176 std::vector<geoops::Waypoint> vWaypointPath;
177
178 // Loop through each UTMCoordinate in the given vector and repack the info into a geoops::Waypoint.
179 for (geoops::UTMCoordinate stLocation : vLocationPath)
180 {
181 // Create a new waypoint and store location info in it.
182 geoops::Waypoint stWaypoint(stLocation, geoops::WaypointType::eNavigationWaypoint);
183
184 // Append waypoint to the temporary waypoint path.
185 vWaypointPath.emplace_back(stWaypoint);
186 }
187
188 // Acquire a write lock on the path unordered map.
189 std::unique_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
190 // Add vector of waypoint to map with the given string as a key.
191 m_umStoredPaths[szPathName] = vWaypointPath;
192}
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:211

◆ AddObstacle() [1/3]

void WaypointHandler::AddObstacle ( const geoops::Waypoint stWaypoint)

Append a new obstacle to the WaypointHandler obstacle list.

Parameters
stWaypoint- The WaypointHandler::geoops::Waypoint struct containing information about the obstacle to store in the handler.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
204{
205 // Acquire a write lock on the obstacle vector.
206 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
207 // Add obstacle waypoint to end of member variable vector.
208 m_vPermanentObstacles.emplace_back(stWaypoint);
209}

◆ AddObstacle() [2/3]

void WaypointHandler::AddObstacle ( const geoops::GPSCoordinate stLocation,
const double  dRadius = 0.0 
)

Append a new obstacle to the WaypointHandler obstacle list.

Parameters
stLocation- The location of the waypoint stored in a geoops namespace GPSCoordinate struct.
dRadius- The circular area around the obstacle or the obstacle radius.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
221{
222 // Construct a new waypoint struct from the given info.
223 geoops::Waypoint stTempWaypoint(stLocation, geoops::WaypointType::eObstacleWaypoint, dRadius);
224
225 // Acquire a write lock on the waypoint vector.
226 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
227 // Add waypoint to end of member variable vector.
228 m_vPermanentObstacles.emplace_back(stTempWaypoint);
229}

◆ AddObstacle() [3/3]

void WaypointHandler::AddObstacle ( const geoops::UTMCoordinate stLocation,
const double  dRadius = 0.0 
)

Append a new obstacle to the WaypointHandler obstacle list.

Parameters
stLocation- The location of the waypoint stored in a geoops namespace UTMCoordinate struct.
dRadius- The circular area around the obstacle or the obstacle radius.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
241{
242 // Construct a new waypoint struct from the given info.
243 geoops::Waypoint stTempWaypoint(stLocation, geoops::WaypointType::eObstacleWaypoint, dRadius);
244
245 // Acquire a write lock on the waypoint vector.
246 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
247 // Add waypoint to end of member variable vector.
248 m_vPermanentObstacles.emplace_back(stTempWaypoint);
249}

◆ DeleteWaypoint() [1/4]

void WaypointHandler::DeleteWaypoint ( const long unsigned int  nIndex)

Delete the geoops::Waypoint at a given index from the waypoint handler.

Parameters
nIndex- The index of the element to remove.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
260{
261 // Acquire a read lock on the waypoint vector.
262 std::shared_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
263 // Check if the vector has at least one waypoint.
264 if (nIndex < m_vWaypointList.size())
265 {
266 // Release read lock.
267 lkWaypointListLock.unlock();
268
269 // Acquire a write lock on the waypoint vector.
270 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
271 // Delete the geoops::Waypoint at the index.
272 m_vWaypointList.erase(m_vWaypointList.begin() + nIndex);
273 }
274 else
275 {
276 // Submit logger message.
277 LOG_ERROR(logging::g_qSharedLogger,
278 "Attempted to delete a waypoint at index {} from the WaypointHandler but it is already empty or the index is out of bounds!",
279 nIndex);
280 }
281}

◆ DeleteWaypoint() [2/4]

void WaypointHandler::DeleteWaypoint ( const geoops::Waypoint stWaypoint)

Delete a waypoint from the WaypointHandler given a matching waypoint. Any waypoint in the list that matches the given one will be removed.

Parameters
stWaypoint- The equivalent waypoint that should be removed.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
293{
294 // Acquire a write lock on the waypoint vector.
295 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
296 // Delete any waypoint matching the given one from the list.
297 m_vWaypointList.erase(std::remove(m_vWaypointList.begin(), m_vWaypointList.end(), stWaypoint), m_vWaypointList.end());
298}

◆ DeleteWaypoint() [3/4]

void WaypointHandler::DeleteWaypoint ( const geoops::GPSCoordinate stLocation)

Delete a waypoint from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.

Parameters
stLocation- The equivalent location that should be removed.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
310{
311 // Acquire a write lock on the waypoint vector.
312 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
313 // Delete any waypoint matching the given location from the list.
314 m_vWaypointList.erase(std::remove_if(m_vWaypointList.begin(),
315 m_vWaypointList.end(),
316 [stLocation](const geoops::Waypoint& stWaypoint) { return stWaypoint.GetGPSCoordinate() == stLocation; }),
317 m_vWaypointList.end());
318}

◆ DeleteWaypoint() [4/4]

void WaypointHandler::DeleteWaypoint ( const geoops::UTMCoordinate stLocation)

Delete a waypoint from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.

Parameters
stLocation- The equivalent location that should be removed.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
330{
331 // Acquire a write lock on the waypoint vector.
332 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
333 // Delete any waypoint matching the given location from the list.
334 m_vWaypointList.erase(std::remove_if(m_vWaypointList.begin(),
335 m_vWaypointList.end(),
336 [stLocation](const geoops::Waypoint& stWaypoint) { return stWaypoint.GetUTMCoordinate() == stLocation; }),
337 m_vWaypointList.end());
338}

◆ DeletePath()

bool WaypointHandler::DeletePath ( const std::string &  szPathName)

Delete the path vector stored at the given key.

Parameters
szPathName- The name/key of the path that was previously used to store the path.
Returns
true - Key was found and deleted successfully.
false - Key was not found and therefore nothing was deleted.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
351{
352 // Acquire a write lock on the path unordered map.
353 std::unique_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
354 // Remove the given key and value from the map.
355 return m_umStoredPaths.erase(szPathName);
356}

◆ DeleteObstacle() [1/4]

void WaypointHandler::DeleteObstacle ( const long unsigned int  nIndex)

Delete the obstacle at a given index from the waypoint handler obstacle list.

Parameters
nIndex- The index of the element to remove.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
367{
368 // Acquire a read lock on the waypoint vector.
369 std::shared_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
370 // Check if the vector has at least one waypoint.
371 if (nIndex < m_vPermanentObstacles.size())
372 {
373 // Release read lock.
374 lkObjectListLock.unlock();
375
376 // Acquire a write lock on the obstacle vector.
377 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
378 // Delete the geoops::Waypoint at the index.
379 m_vPermanentObstacles.erase(m_vPermanentObstacles.begin() + nIndex);
380 }
381 else
382 {
383 // Submit logger message.
384 LOG_ERROR(logging::g_qSharedLogger,
385 "Attempted to delete an obstacle waypoint at index {} from the WaypointHandler but it is already empty or the index is out of bounds!",
386 nIndex);
387 }
388}

◆ DeleteObstacle() [2/4]

void WaypointHandler::DeleteObstacle ( const geoops::Waypoint stWaypoint)

Delete an obstacle from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.

Parameters
stWaypoint- The equivalent obstacle location that should be removed.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
400{
401 // Acquire a write lock on the obstacle vector.
402 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
403 // Delete any waypoint matching the given one from the list.
404 m_vPermanentObstacles.erase(std::remove(m_vPermanentObstacles.begin(), m_vPermanentObstacles.end(), stWaypoint), m_vPermanentObstacles.end());
405}

◆ DeleteObstacle() [3/4]

void WaypointHandler::DeleteObstacle ( const geoops::GPSCoordinate stLocation)

Delete an obstacle from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.

Parameters
stLocation- The equivalent obstacle location that should be removed.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
417{
418 // Acquire a write lock on the obstacle vector.
419 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
420 // Delete any waypoint matching the given location from the list.
421 m_vPermanentObstacles.erase(std::remove_if(m_vPermanentObstacles.begin(),
422 m_vPermanentObstacles.end(),
423 [stLocation](const geoops::Waypoint& stWaypoint) { return stWaypoint.GetGPSCoordinate() == stLocation; }),
424 m_vPermanentObstacles.end());
425}

◆ DeleteObstacle() [4/4]

void WaypointHandler::DeleteObstacle ( const geoops::UTMCoordinate stLocation)

Delete an obstacle from the WaypointHandler given a matching location. Any waypoint in the list that matches the given location will be removed.

Parameters
stLocation- The equivalent obstacle location that should be removed.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
437{
438 // Acquire a write lock on the obstacle vector.
439 std::unique_lock<std::shared_mutex> lkObjectListLock(m_muObstaclesMutex);
440 // Delete any waypoint matching the given location from the list.
441 m_vPermanentObstacles.erase(std::remove_if(m_vPermanentObstacles.begin(),
442 m_vPermanentObstacles.end(),
443 [stLocation](const geoops::Waypoint& stWaypoint) { return stWaypoint.GetUTMCoordinate() == stLocation; }),
444 m_vPermanentObstacles.end());
445}

◆ ClearWaypoints()

void WaypointHandler::ClearWaypoints ( )

Clears/deletes all Waypoints stored in the WaypointHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
455{
456 // Acquire a write lock on the waypoint vector.
457 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
458 // Clear the waypoint vector.
459 m_vWaypointList.clear();
460}

◆ ClearPaths()

void WaypointHandler::ClearPaths ( )

Clears/deletes all keys and paths store in the WaypointHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
470{
471 // Acquire a write lock on the path unordered map.
472 std::unique_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
473 // Clear the path map.
474 m_umStoredPaths.clear();
475}

◆ ClearObstacles()

void WaypointHandler::ClearObstacles ( )

Clears/deletes all permanent objects stored in the WaypointHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
485{
486 // Acquire a write lock on the path unordered map.
487 std::unique_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
488 // Clear the obstacle vector.
489 m_vPermanentObstacles.clear();
490}

◆ PopNextWaypoint()

geoops::Waypoint WaypointHandler::PopNextWaypoint ( )

Removes and returns the next waypoint at the front of the list.

Returns
WaypointHandler::geoops::Waypoint - The next waypoint data stored in a geoops::Waypoint struct.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
501{
502 // Acquire a read lock on the waypoint vector.
503 std::shared_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
504 // Check if the vector has at least one waypoint.
505 if (!m_vWaypointList.empty())
506 {
507 // Release read lock.
508 lkWaypointListLock.unlock();
509
510 // Acquire a write lock on the waypoint vector.
511 std::unique_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
512 // Pop a waypoint from the front of the waypoint list and store it.
513 geoops::Waypoint stWaypoint = m_vWaypointList[0];
514 m_vWaypointList.erase(m_vWaypointList.begin());
515 // Unlock shared mutex.
516 lkWaypointListLock.unlock();
517
518 // Return a copy of the waypoint.
519 return stWaypoint;
520 }
521 else
522 {
523 // Submit logger message.
524 LOG_ERROR(logging::g_qSharedLogger, "Attempted to pop a waypoint from the WaypointHandler but it is empty!");
525
526 // Return an empty waypoint.
527 return geoops::Waypoint(geoops::GPSCoordinate(), geoops::WaypointType::eUNKNOWN);
528 }
529}
Here is the caller graph for this function:

◆ PeekNextWaypoint()

const geoops::Waypoint WaypointHandler::PeekNextWaypoint ( )

Returns an immutable reference to the geoops::Waypoint struct at the front of the list without removing it.

Returns
const WaypointHandler::geoops::Waypoint - A reference to a geoops::Waypoint struct containing waypoint data.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
541{
542 // Acquire a read lock on the waypoint vector.
543 std::shared_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
544 // Check if the vector has at least one waypoint.
545 if (!m_vWaypointList.empty())
546 {
547 // Return an immutable reference to the waypoint.
548 return m_vWaypointList.front();
549 }
550 else
551 {
552 // Submit logger message.
553 LOG_ERROR(logging::g_qSharedLogger, "Attempted to peek a waypoint from the WaypointHandler but it is empty!");
554
555 // Return an empty waypoint.
556 return geoops::Waypoint(geoops::GPSCoordinate(), geoops::WaypointType::eUNKNOWN);
557 }
558}
Here is the caller graph for this function:

◆ RetrieveWaypointAtIndex()

const geoops::Waypoint WaypointHandler::RetrieveWaypointAtIndex ( const long unsigned int  nIndex)

Retrieve an immutable reference to the waypoint at the given index.

Parameters
nIndex- The index of the element to retrieve.
Returns
const WaypointHandler::geoops::Waypoint - An immutable reference to the geoops::Waypoint containing data.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
570{
571 // Acquire a read lock on the waypoint vector.
572 std::shared_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
573 // Check if the vector has at least one waypoint.
574 if (nIndex < m_vWaypointList.size())
575 {
576 // Return an immutable reference to the waypoint at the index.
577 return m_vWaypointList[nIndex];
578 }
579 else
580 {
581 // Submit logger message.
582 LOG_ERROR(logging::g_qSharedLogger,
583 "Attempted to retrieve a waypoint at index {} from the WaypointHandler but it is empty or the index is out of bounds!",
584 nIndex);
585
586 // Return an empty waypoint.
587 return geoops::Waypoint(geoops::GPSCoordinate(), geoops::WaypointType::eUNKNOWN);
588 }
589}

◆ RetrievePath()

const std::vector< geoops::Waypoint > WaypointHandler::RetrievePath ( const std::string &  szPathName)

Retrieve an immutable reference to the path at the given path name/key.

Parameters
szPathName- The name/key of the path that was previously used to store the path.
Returns
const std::vector<WaypointHandler::geoops::Waypoint> - A reference to the geoops::Waypoint vector located at the given key.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
601{
602 // Acquire a read lock on the path unordered map.
603 std::shared_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
604 // Check if the map contains the given key.
605 if (m_umStoredPaths.count(szPathName) > 0)
606 {
607 // Return the path vector at the given key.
608 return m_umStoredPaths[szPathName];
609 }
610 else
611 {
612 // Return an empty vector.
613 return std::vector<geoops::Waypoint>();
614 }
615}
Here is the caller graph for this function:

◆ RetrieveObstacleAtIndex()

const geoops::Waypoint WaypointHandler::RetrieveObstacleAtIndex ( const long unsigned int  nIndex)

Retrieve an immutable reference to the obstacle at the given index.

Parameters
nIndex- The index of the element to retrieve.
Returns
const WaypointHandler::geoops::Waypoint - An immutable reference to the obstacle geoops::Waypoint containing data.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
627{
628 // Acquire a read lock on the waypoint vector.
629 std::shared_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
630 // Check if the vector has at least one waypoint.
631 if (nIndex < m_vPermanentObstacles.size())
632 {
633 // Return an immutable reference to the waypoint at the index.
634 return m_vPermanentObstacles[nIndex];
635 }
636 else
637 {
638 // Submit logger message.
639 LOG_ERROR(logging::g_qSharedLogger,
640 "Attempted to retrieve a obstacle at index {} from the WaypointHandler but it is empty or the index is out of bounds!",
641 nIndex);
642
643 // Return an empty waypoint.
644 return geoops::Waypoint(geoops::GPSCoordinate(), geoops::WaypointType::eUNKNOWN);
645 }
646}

◆ GetAllWaypoints()

const std::vector< geoops::Waypoint > WaypointHandler::GetAllWaypoints ( )

Accessor for the full list of current waypoints stored in the WaypointHandler.

Returns
const std::vector<WaypointHandler::geoops::Waypoint> - A vector of geoops::Waypoint structs currently stored in the WaypointHandler.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
657{
658 // Acquire a read lock on the waypoint vector.
659 std::shared_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
660 // Return a copy of the current waypoint list.
661 return m_vWaypointList;
662}
Here is the caller graph for this function:

◆ GetAllObstacles()

const std::vector< geoops::Waypoint > WaypointHandler::GetAllObstacles ( )

Accessor for the full list of current obstacle stored in the WaypointHandler.

Returns
const std::vector<WaypointHandler::geoops::Waypoint> - A vector of geoops::Waypoint structs representing objects that are currently stored in the WaypointHandler.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-04
674{
675 // Acquire a read lock on the path unordered map.
676 std::shared_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
677 // Return a copy of the current obstacle list.
678 return m_vPermanentObstacles;
679}
Here is the caller graph for this function:

◆ GetWaypointCount()

int WaypointHandler::GetWaypointCount ( )

Accessor for the number of elements on the WaypointHandler's waypoint vector.

Returns
int - The size of the waypoint vector.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
690{
691 // Acquire a read lock on the waypoint vector.
692 std::shared_lock<std::shared_mutex> lkWaypointListLock(m_muWaypointsMutex);
693 // Return total number of waypoints stored.
694 return m_vWaypointList.size();
695}

◆ GetPathsCount()

int WaypointHandler::GetPathsCount ( )

Accessor for the number of paths stored in the WaypointHandler.

Returns
int - The size of the unordered_map storing the paths.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
706{
707 // Acquire a read lock on the path unordered map.
708 std::shared_lock<std::shared_mutex> lkPathsLock(m_muPathMutex);
709 // Return total number of paths.
710 return m_umStoredPaths.size();
711}

◆ GetObstaclesCount()

int WaypointHandler::GetObstaclesCount ( )

Accessor for the number of elements on the WaypointHandler's obstacle vector.

Returns
int - The size of the obstacle vector.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-02-03
722{
723 // Acquire a write lock on the waypoint vector.
724 std::shared_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
725 // Return total number of objects stored.
726 return m_vPermanentObstacles.size();
727}

Member Data Documentation

◆ AddPositionLegCallback

const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> WaypointHandler::AddPositionLegCallback
private
Initial value:
=
[this](const rovecomm::RoveCommPacket<double>& stPacket, const sockaddr_in& stdAddr)
{
(void) stdAddr;
geoops::Waypoint stNavWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]),
geoops::WaypointType::eNavigationWaypoint,
0.0,
stPacket.vData[2]);
std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
m_vWaypointList.emplace_back(stNavWaypoint);
lkWaypointsLock.unlock();
LOG_NOTICE(logging::g_qSharedLogger,
"Incoming Navigation Waypoint Data: Added (lat: {}, lon: {}, id: {}) to WaypointHandler queue.",
stPacket.vData[0],
stPacket.vData[1],
stPacket.vData[2]);
}

Callback function that is called whenever RoveComm receives new ADDPOSITIONLEG packet.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-03
110 {
111 // Not using this.
112 (void) stdAddr;
113
114 // Create new waypoint struct with data from the RoveComm packet.
115 geoops::Waypoint stNavWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]),
116 geoops::WaypointType::eNavigationWaypoint,
117 0.0,
118 stPacket.vData[2]);
119
120 // Acquire write lock for writing to waypoints vector.
121 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
122 // Queue waypoint.
123 m_vWaypointList.emplace_back(stNavWaypoint);
124 // Unlock mutex.
125 lkWaypointsLock.unlock();
126
127 // Submit logger message.
128 LOG_NOTICE(logging::g_qSharedLogger,
129 "Incoming Navigation Waypoint Data: Added (lat: {}, lon: {}, id: {}) to WaypointHandler queue.",
130 stPacket.vData[0],
131 stPacket.vData[1],
132 stPacket.vData[2]);
133 };

◆ AddMarkerLegCallback

const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> WaypointHandler::AddMarkerLegCallback
private

Callback function that is called whenever RoveComm receives new ADDMARKERLEG packet.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-03
144 {
145 // Not using this.
146 (void) stdAddr;
147
148 // Create instance variables.
149 int nMarkerID = stPacket.vData[2];
150 double dRadius = stPacket.vData[3];
151
152 // Limit the radius to 0-40.
153 if (dRadius < 0)
154 {
155 // Submit logger message.
156 LOG_WARNING(logging::g_qSharedLogger, "Incoming Marker Waypoint Data: Radius is less than 0, setting to 0.");
157 dRadius = 0;
158 }
159 else if (dRadius > 40)
160 {
161 // Submit logger message.
162 LOG_WARNING(logging::g_qSharedLogger, "Incoming Marker Waypoint Data: Radius is greater than 40, setting to 40.");
163 dRadius = 40;
164 }
165
166 // Create new waypoint struct with data from the RoveComm packet.
167 geoops::Waypoint stMarkerWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eTagWaypoint, dRadius, nMarkerID);
168
169 // Acquire write lock for writing to waypoints vector.
170 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
171 // Queue waypoint.
172 m_vWaypointList.emplace_back(stMarkerWaypoint);
173 // Unlock mutex.
174 lkWaypointsLock.unlock();
175
176 // Submit logger message.
177 LOG_NOTICE(logging::g_qSharedLogger,
178 "Incoming Marker Waypoint Data: Added (lat: {}, lon: {}, marker ID: {}, radius: {}) to WaypointHandler queue.",
179 stPacket.vData[0],
180 stPacket.vData[1],
181 nMarkerID,
182 dRadius);
183 };

◆ AddObjectLegCallback

const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> WaypointHandler::AddObjectLegCallback
private

Callback function that is called whenever RoveComm receives new ADDOBJECTLEG packet.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-03
194 {
195 // Not using this.
196 (void) stdAddr;
197
198 // Create instance variables.
199 geoops::WaypointType eWaypointType = geoops::WaypointType::eObjectWaypoint;
200 double dObjectID = stPacket.vData[2];
201 double dRadius = stPacket.vData[3];
202
203 // Parse the object ID from the RoveComm packet to a waypoint type.
204 if (dObjectID == static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::MALLET))
205 {
206 eWaypointType = geoops::WaypointType::eMalletWaypoint;
207 }
208 else if (dObjectID == static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::WATERBOTTLE))
209 {
210 eWaypointType = geoops::WaypointType::eWaterBottleWaypoint;
211 }
212 else if (dObjectID == static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::ROCKPICK))
213 {
214 eWaypointType = geoops::WaypointType::eRockPickWaypoint;
215 }
216 else
217 {
218 eWaypointType = geoops::WaypointType::eObjectWaypoint;
219 }
220
221 // Limit the radius to 0-40.
222 if (dRadius < 0)
223 {
224 // Submit logger message.
225 LOG_WARNING(logging::g_qSharedLogger, "Incoming Object Waypoint Data: Radius is less than 0, setting to 0.");
226 dRadius = 0;
227 }
228 else if (dRadius > 40)
229 {
230 // Submit logger message.
231 LOG_WARNING(logging::g_qSharedLogger, "Incoming Object Waypoint Data: Radius is greater than 40, setting to 40.");
232 dRadius = 40;
233 }
234
235 // Create new waypoint struct with data from the RoveComm packet.
236 geoops::Waypoint stObjectWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), eWaypointType, dRadius);
237
238 // Acquire write lock for writing to waypoints vector.
239 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
240 // Queue waypoint.
241 m_vWaypointList.emplace_back(stObjectWaypoint);
242 // Unlock mutex.
243 lkWaypointsLock.unlock();
244
245 // Submit logger message.
246 LOG_NOTICE(logging::g_qSharedLogger,
247 "Incoming Object Waypoint Data: Added (lat: {}, lon: {}, id: {}, radius: {}) to WaypointHandler queue.",
248 stPacket.vData[0],
249 stPacket.vData[1],
250 dObjectID,
251 dRadius);
252 };

◆ AddObstacleCallback

const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> WaypointHandler::AddObstacleCallback
private

Callback function that is called whenever RoveComm receives new ADDOBSTACLE packet.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-06
263 {
264 // Not using this.
265 (void) stdAddr;
266
267 // Create instance variables.
268 double dRadius = stPacket.vData[2];
269
270 // Limit the radius to 0-40.
271 if (dRadius < 0)
272 {
273 // Submit logger message.
274 LOG_WARNING(logging::g_qSharedLogger, "Incoming Obstacle Waypoint Data: Radius is less than 0, setting to 0.");
275 dRadius = 0;
276 }
277 else if (dRadius > 40)
278 {
279 // Submit logger message.
280 LOG_WARNING(logging::g_qSharedLogger, "Incoming Obstacle Waypoint Data: Radius is greater than 40, setting to 40.");
281 dRadius = 40;
282 }
283
284 // Create new waypoint struct with data from the RoveComm packet.
285 geoops::Waypoint stObstacleWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]), geoops::WaypointType::eObstacleWaypoint, dRadius);
286
287 // Acquire write lock for writing to waypoints vector.
288 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
289 // Queue waypoint.
290 m_vPermanentObstacles.emplace_back(stObstacleWaypoint);
291 // Unlock mutex.
292 lkWaypointsLock.unlock();
293
294 // Submit logger message.
295 LOG_NOTICE(logging::g_qSharedLogger,
296 "Incoming Obstacle Waypoint Data: Added (lat: {}, lon: {}, radius: {}) to WaypointHandler queue. Total Obstacles: {}",
297 stPacket.vData[0],
298 stPacket.vData[1],
299 dRadius,
300 m_vPermanentObstacles.size());
301 };

◆ ClearWaypointsCallback

const std::function<void(const rovecomm::RoveCommPacket<uint8_t>&, const sockaddr_in&)> WaypointHandler::ClearWaypointsCallback
private
Initial value:
=
[this](const rovecomm::RoveCommPacket<uint8_t>& stPacket, const sockaddr_in& stdAddr)
{
(void) stPacket;
(void) stdAddr;
std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
m_vWaypointList.clear();
lkWaypointsLock.unlock();
LOG_NOTICE(logging::g_qSharedLogger, "Incoming Clear Waypoints packet: Cleared WaypointHandler queue.");
}

Callback function that is called whenever RoveComm receives new CLEARWAYPOINTS packet.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-03
312 {
313 // Not using this.
314 (void) stPacket;
315 (void) stdAddr;
316
317 // Acquire write lock for writing to waypoints vector.
318 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
319 // Clear waypoints queue.
320 m_vWaypointList.clear();
321 // Unlock mutex.
322 lkWaypointsLock.unlock();
323
324 // Submit logger message.
325 LOG_NOTICE(logging::g_qSharedLogger, "Incoming Clear Waypoints packet: Cleared WaypointHandler queue.");
326 };

◆ ClearObstaclesCallback

const std::function<void(const rovecomm::RoveCommPacket<uint8_t>&, const sockaddr_in&)> WaypointHandler::ClearObstaclesCallback
private
Initial value:
=
[this](const rovecomm::RoveCommPacket<uint8_t>& stPacket, const sockaddr_in& stdAddr)
{
(void) stPacket;
(void) stdAddr;
std::unique_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
m_vPermanentObstacles.clear();
lkObstaclesLock.unlock();
LOG_NOTICE(logging::g_qSharedLogger, "Incoming Clear Obstacles packet: Cleared permanent obstacles list.");
}

Callback function that is called whenever RoveComm receives new CLEAROBSTACLES packet.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-19
337 {
338 // Not using this.
339 (void) stPacket;
340 (void) stdAddr;
341
342 // Acquire write lock for obstacle vector.
343 std::unique_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
344 // Clear obstacles queue.
345 m_vPermanentObstacles.clear();
346 // Unlock mutex.
347 lkObstaclesLock.unlock();
348
349 // Submit logger message.
350 LOG_NOTICE(logging::g_qSharedLogger, "Incoming Clear Obstacles packet: Cleared permanent obstacles list.");
351 };

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