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.
 
geoops::RoverPose SmartRetrieveRoverPose (bool bVIOHeading=true, bool bVIOTracking=false)
 Retrieve the rover's current position and heading. Automatically picks between getting the position/heading from the NavBoard, ZEDSDK Fusion module, or ZED positional tracking. In most cases, this will be the method that should be called over getting the data directly from NavBoard.
 
double SmartRetrieveVelocity ()
 Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDCam so this method just returns the GPS-based velocity.
 
double SmartRetrieveAngularVelocity ()
 Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDCam so this method just returns the GPS-based velocity.
 

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:336
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:311
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:147
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:113
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:262
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:197
::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:392

◆ 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}

◆ 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:99

◆ 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:195

◆ 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}

◆ 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}

◆ 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}

◆ SmartRetrieveRoverPose()

geoops::RoverPose WaypointHandler::SmartRetrieveRoverPose ( bool  bVIOHeading = true,
bool  bVIOTracking = false 
)

Retrieve the rover's current position and heading. Automatically picks between getting the position/heading from the NavBoard, ZEDSDK Fusion module, or ZED positional tracking. In most cases, this will be the method that should be called over getting the data directly from NavBoard.

Parameters
bVIOHeading- Whether to use ZED Heading Fusion.
bVIOTracking- Whether to use ZED Positional Tracking.
Returns
geoops::RoverPose - The current position and heading (pose) of the rover stored in a RoverPose struct.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-06
743{
744 // Get and store the normal GPS position and heading from NavBoard.
745 geoops::GPSCoordinate stCurrentGPSPosition = globals::g_pNavigationBoard->GetGPSData();
746 double dCurrentGPSHeading = globals::g_pNavigationBoard->GetHeading();
747
748 // Create instance variables.
749 std::shared_ptr<ZEDCamera> pMainCam = globals::g_pCameraHandler->GetZED(CameraHandler::ZEDCamName::eHeadMainCam);
750 geoops::GPSCoordinate stCurrentVIOPosition = stCurrentGPSPosition;
751 double dCurrentHeading = dCurrentGPSHeading;
752 bool bVIOGPSFused = false;
753 static bool bAlreadyPrinted = false;
754
755 if ((bVIOHeading || bVIOTracking) && !constants::MODE_SIM)
756 {
757 // Check if the main ZED camera is opened and the fusion module is initialized.
758 if (pMainCam->GetCameraIsOpen() && pMainCam->GetPositionalTrackingEnabled())
759 {
760 // Get the fused positional tracking state of the main camera.
761 sl::GNSS_FUSION_STATUS slGNSSFusionStatus = pMainCam->GetFusedPositionalTrackingState().gnss_fusion_status;
762
763 // Check if GNSS fusion is enabled and current GPS data from has differential accuracy and GNSS fusion is calibrated.
764 if (constants::FUSION_ENABLE_GNSS_FUSION && pMainCam->GetIsFusionMaster() && stCurrentGPSPosition.bIsDifferential &&
765 (slGNSSFusionStatus == sl::GNSS_FUSION_STATUS::OK || slGNSSFusionStatus == sl::GNSS_FUSION_STATUS::RECALIBRATION_IN_PROGRESS))
766 {
767 // Create instance variables.
768 sl::GeoPose slCurrentCameraGeoPose;
769 ZEDCam::Pose stCurrentCameraVIOPose;
770
771 // Check if position VIO tracking should be used.
772 if (bVIOTracking)
773 {
774 // Get the current camera pose from the ZEDCam.
775 std::future<bool> fuResultStatus = pMainCam->RequestFusionGeoPoseCopy(slCurrentCameraGeoPose);
776 if (fuResultStatus.get())
777 {
778 // Repack the camera pose into a GPSCoordinate.
779 stCurrentVIOPosition.dLatitude = slCurrentCameraGeoPose.latlng_coordinates.getLatitude(false);
780 stCurrentVIOPosition.dLongitude = slCurrentCameraGeoPose.latlng_coordinates.getLongitude(false);
781 stCurrentVIOPosition.dAltitude = slCurrentCameraGeoPose.latlng_coordinates.getAltitude();
782
783 // Set fused toggle.
784 bVIOGPSFused = true;
785 }
786 }
787
788 // Check if heading VIO tracking should be used.
789 if (bVIOHeading)
790 {
791 // Get the current camera pose from the ZEDCam.
792 std::future<bool> fuResultStatus2 = pMainCam->RequestPositionalPoseCopy(stCurrentCameraVIOPose);
793 if (fuResultStatus2.get())
794 {
795 // Repack the camera pose into a UTMCoordinate.
796 // dCurrentHeading = slCurrentCameraGeoPose.heading * (180.0 / M_PI); // This doesn't work because the heading is on the wrong axis for some
797 // reason.
798 dCurrentHeading = stCurrentCameraVIOPose.stEulerAngles.dYO;
799
800 // Set fused toggle.
801 bVIOGPSFused = true;
802 }
803 }
804
805 // Check toggle so we only print once.
806 if (bAlreadyPrinted)
807 {
808 // Submit logger message.
809 LOG_NOTICE(logging::g_qSharedLogger, "GNSS Fusion has now converged! Using GNSS Fusion for rover pose...");
810 // Set toggle.
811 bAlreadyPrinted = false;
812 }
813 }
814 else
815 {
816 // Create instance variables.
817 ZEDCam::Pose stCurrentCameraVIOPose;
818
819 // Get the current camera pose from the ZEDCam.
820 std::future<bool> fuResultStatus = pMainCam->RequestPositionalPoseCopy(stCurrentCameraVIOPose);
821 // Wait for future to be fulfilled.
822 if (fuResultStatus.get())
823 {
824 // Check if position VIO tracking should be used.
825 if (bVIOTracking)
826 {
827 // Camera is using UTM. Modify current GPS position to be camera's position.
828 geoops::UTMCoordinate stCameraUTMLocation = geoops::ConvertGPSToUTM(stCurrentGPSPosition);
829 // Repack the camera pose into a GPSCoordinate.
830 stCameraUTMLocation.dEasting = stCurrentCameraVIOPose.stTranslation.dX;
831 stCameraUTMLocation.dNorthing = stCurrentCameraVIOPose.stTranslation.dZ;
832 stCameraUTMLocation.dAltitude = stCurrentCameraVIOPose.stTranslation.dY;
833 // Convert back to GPS coordinate and store.
834 stCurrentVIOPosition = geoops::ConvertUTMToGPS(stCameraUTMLocation);
835 }
836
837 // Check if heading VIO tracking should be used.
838 if (bVIOHeading)
839 {
840 // Get compass heading based off of the ZED's aligned accelerometer.
841 dCurrentHeading = stCurrentCameraVIOPose.stEulerAngles.dYO;
842 }
843
844 // Set fused toggle.
845 bVIOGPSFused = false;
846 }
847
848 // Check toggle so we only print once.
849 if (!bAlreadyPrinted && constants::FUSION_ENABLE_GNSS_FUSION)
850 {
851 // Submit logger message.
852 LOG_NOTICE(logging::g_qSharedLogger, "GNSS Fusion is still calibrating. Using VIO tracking for rover pose...");
853 // Set toggle.
854 bAlreadyPrinted = true;
855 }
856 }
857 }
858 else
859 {
860 LOG_WARNING_LIMIT(std::chrono::seconds(5),
861 logging::g_qSharedLogger,
862 "Positional tracking is not enabled or camera is not open! Using NavBoard GPS data for rover pose...");
863 }
864 }
865
866 // Submit a debug print for the current rover pose.
867 geoops::UTMCoordinate stCurrentUTMPosition = geoops::ConvertGPSToUTM(stCurrentVIOPosition);
868 LOG_DEBUG(logging::g_qSharedLogger,
869 "Rover Pose is currently: {} (easting), {} (northing), {} (alt), {} (degrees), GNSS/VIO FUSED? = {}, VIOPosition = {}, VIOHeading = {}",
870 stCurrentUTMPosition.dEasting,
871 stCurrentUTMPosition.dNorthing,
872 stCurrentUTMPosition.dAltitude,
873 dCurrentHeading,
874 bVIOGPSFused ? "true" : "false",
875 bVIOTracking ? "true" : "false",
876 bVIOHeading ? "true" : "false");
877
878 // Submit a debug print for some error metrics pertaining to the ZED camera and NavBoard locations and headings.
879 double dHeadingError = dCurrentHeading - dCurrentGPSHeading;
880 double dEastingError = ConvertGPSToUTM(stCurrentGPSPosition).dEasting - stCurrentUTMPosition.dEasting;
881 double dNorthingError = ConvertGPSToUTM(stCurrentGPSPosition).dNorthing - stCurrentUTMPosition.dNorthing;
882
883 // Check if VIO tracking or heading is being used.
884 if (bVIOHeading || bVIOTracking)
885 {
886 // Assemble the error metrics into a single string. We are going to include the original GPS positions of the NavBoard and the Camera and then include the error.
887 // Same thing for the heading data.
888 std::string szErrorMetrics = "--------[ Pose Tracking Error ]--------\nGPS/VIO Position Error (UTM for easy reading):\n" +
889 std::to_string(ConvertGPSToUTM(stCurrentGPSPosition).dEasting) + " (NavBoard) vs. " + std::to_string(stCurrentUTMPosition.dEasting) +
890 " (Camera) = " + std::to_string(dEastingError) + " (error)\n" + std::to_string(ConvertGPSToUTM(stCurrentGPSPosition).dNorthing) +
891 " (NavBoard) vs. " + std::to_string(stCurrentUTMPosition.dNorthing) + " (Camera) = " + std::to_string(dNorthingError) +
892 " (error)\n" + "Heading Error:\n" + std::to_string(dCurrentGPSHeading) + " (NavBoard) vs. " + std::to_string(dCurrentHeading) +
893 " (Camera) = " + std::to_string(dHeadingError) + " (error)\n GNSS/VIO FUSED? = " + (bVIOGPSFused ? "true" : "false") +
894 ", VIOPosition = " + (bVIOTracking ? "true" : "false") + ", VIOHeading = " + (bVIOHeading ? "true" : "false");
895 // Submit the error metrics to the logger.
896 LOG_DEBUG(logging::g_qSharedLogger, "{}", szErrorMetrics);
897 }
898
899 return geoops::RoverPose(stCurrentVIOPosition, dCurrentHeading);
900}
std::shared_ptr< ZEDCamera > GetZED(ZEDCamName eCameraName)
Accessor for ZED cameras.
Definition CameraHandler.cpp:170
double GetHeading()
Accessor for the most recent compass heading received from the NavBoard.
Definition NavigationBoard.cpp:161
geoops::GPSCoordinate GetGPSData()
Accessor for most recent GPS data received from NavBoard.
Definition NavigationBoard.cpp:78
GPSCoordinate ConvertUTMToGPS(const UTMCoordinate &stUTMCoord)
Given a UTM coordinate, convert to GPS and create a new GPSCoordinate object.
Definition GeospatialOperations.hpp:347
UTMCoordinate ConvertGPSToUTM(const GPSCoordinate &stGPSCoord)
Given a GPS coordinate, convert to UTM and create a new UTMCoordinate object.
Definition GeospatialOperations.hpp:302
This struct is used within the ZEDCam class to store the camera pose with high precision....
Definition ZEDCamera.hpp:77
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:677
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SmartRetrieveVelocity()

double WaypointHandler::SmartRetrieveVelocity ( )

Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDCam so this method just returns the GPS-based velocity.

Returns
double - The current velocity of the rover. (m/s)
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-06
913{
914 // Return the GPS-based velocity from the NavBoard.
915 return globals::g_pNavigationBoard->GetVelocity();
916}
double GetVelocity()
The rover's current velocity based off of the distance covered over the last two GPSCoordinates.
Definition NavigationBoard.cpp:244
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SmartRetrieveAngularVelocity()

double WaypointHandler::SmartRetrieveAngularVelocity ( )

Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDCam so this method just returns the GPS-based velocity.

Returns
double - The current angular velocity of the rover. (deg/s)
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-04-06
929{
930 // Return the GPS-based angular velocity from the NavBoard.
931 return globals::g_pNavigationBoard->GetAngularVelocity();
932}
double GetAngularVelocity()
The rover's current angular velocity based off of the change in angle over the last two headings.
Definition NavigationBoard.cpp:286
Here is the call graph for this function:
Here is the caller graph for this function:

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
115 {
116 // Not using this.
117 (void) stdAddr;
118
119 // Create new waypoint struct with data from the RoveComm packet.
120 geoops::Waypoint stNavWaypoint(geoops::GPSCoordinate(stPacket.vData[0], stPacket.vData[1]),
121 geoops::WaypointType::eNavigationWaypoint,
122 0.0,
123 stPacket.vData[2]);
124
125 // Acquire write lock for writing to waypoints vector.
126 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
127 // Queue waypoint.
128 m_vWaypointList.emplace_back(stNavWaypoint);
129 // Unlock mutex.
130 lkWaypointsLock.unlock();
131
132 // Submit logger message.
133 LOG_NOTICE(logging::g_qSharedLogger,
134 "Incoming Navigation Waypoint Data: Added (lat: {}, lon: {}, id: {}) to WaypointHandler queue.",
135 stPacket.vData[0],
136 stPacket.vData[1],
137 stPacket.vData[2]);
138 };

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

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

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

◆ 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
313 {
314 // Not using this.
315 (void) stPacket;
316 (void) stdAddr;
317
318 // Acquire write lock for writing to waypoints vector.
319 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
320 // Clear waypoints queue.
321 m_vWaypointList.clear();
322 // Unlock mutex.
323 lkWaypointsLock.unlock();
324
325 // Submit logger message.
326 LOG_NOTICE(logging::g_qSharedLogger, "Incoming Clear Waypoints packet: Cleared WaypointHandler queue.");
327 };

◆ 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
338 {
339 // Not using this.
340 (void) stPacket;
341 (void) stdAddr;
342
343 // Acquire write lock for obstacle vector.
344 std::unique_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
345 // Clear obstacles queue.
346 m_vPermanentObstacles.clear();
347 // Unlock mutex.
348 lkObstaclesLock.unlock();
349
350 // Submit logger message.
351 LOG_NOTICE(logging::g_qSharedLogger, "Incoming Clear Obstacles packet: Cleared permanent obstacles list.");
352 };

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