11#ifndef WAYPOINT_HANDLER_H
12#define WAYPOINT_HANDLER_H
14#include "../util/GeospatialOperations.hpp"
17#include <RoveComm/RoveComm.h>
18#include <RoveComm/RoveCommManifest.h>
19#include <shared_mutex>
48 void StorePath(
const std::string& szPathName,
const std::vector<geoops::Waypoint>& vWaypointPath);
49 void StorePath(
const std::string& szPathName,
const std::vector<geoops::GPSCoordinate>& vLocationPath);
50 void StorePath(
const std::string& szPathName,
const std::vector<geoops::UTMCoordinate>& vLocationPath);
58 bool DeletePath(
const std::string& szPathName);
77 const std::vector<geoops::Waypoint>
RetrievePath(
const std::string& szPathName);
95 std::vector<geoops::Waypoint> m_vWaypointList;
96 std::shared_mutex m_muWaypointsMutex;
97 std::unordered_map<std::string, std::vector<geoops::Waypoint>> m_umStoredPaths;
98 std::shared_mutex m_muPathMutex;
99 std::vector<geoops::Waypoint> m_vPermanentObjects;
100 std::shared_mutex m_muObjectsMutex;
114 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
123 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
125 m_vWaypointList.emplace_back(stNavWaypoint);
127 lkWaypointsLock.unlock();
130 LOG_INFO(logging::g_qSharedLogger,
131 "Incoming Navigation Waypoint Data: Added (lat: {}, lon: {}) to WaypointHandler queue.",
144 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
150 int nMarkerID = stPacket.vData[2];
151 double dRadius = stPacket.vData[3];
157 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Marker Waypoint Data: Radius is less than 0, setting to 0.");
160 else if (dRadius > 40)
163 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Marker Waypoint Data: Radius is greater than 40, setting to 40.");
171 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
173 m_vWaypointList.emplace_back(stMarkerWaypoint);
175 lkWaypointsLock.unlock();
178 LOG_INFO(logging::g_qSharedLogger,
179 "Incoming Marker Waypoint Data: Added (lat: {}, lon: {}, marker ID: {}, radius: {}) to WaypointHandler queue.",
194 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
200 double dRadius = stPacket.vData[2];
206 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Object Waypoint Data: Radius is less than 0, setting to 0.");
209 else if (dRadius > 40)
212 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Object Waypoint Data: Radius is greater than 40, setting to 40.");
220 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
222 m_vWaypointList.emplace_back(stObjectWaypoint);
224 lkWaypointsLock.unlock();
227 LOG_INFO(logging::g_qSharedLogger,
228 "Incoming Object Waypoint Data: Added (lat: {}, lon: {}, radius: {}) to WaypointHandler queue.",
241 const std::function<void(
const rovecomm::RoveCommPacket<double>&,
const sockaddr_in&)>
AddObstacleCallback =
242 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
248 double dRadius = stPacket.vData[2];
254 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Obstacle Waypoint Data: Radius is less than 0, setting to 0.");
257 else if (dRadius > 40)
260 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Obstacle Waypoint Data: Radius is greater than 40, setting to 40.");
268 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
270 m_vWaypointList.emplace_back(stObstacleWaypoint);
272 lkWaypointsLock.unlock();
275 LOG_INFO(logging::g_qSharedLogger,
276 "Incoming Obstacle Waypoint Data: Added (lat: {}, lon: {}, radius: {}) to WaypointHandler queue.",
290 [
this](
const rovecomm::RoveCommPacket<uint8_t>& stPacket,
const sockaddr_in& stdAddr)
297 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
299 m_vWaypointList.clear();
301 lkWaypointsLock.unlock();
304 LOG_INFO(logging::g_qSharedLogger,
"Incoming Clear Waypoints packet: Cleared WaypointHandler queue.");
The WaypointHandler class is used throughout the entire project (mainly by the state machine) to glob...
Definition WaypointHandler.h:33
void ClearPaths()
Clears/deletes all keys and paths store in the WaypointHandler.
Definition WaypointHandler.cpp:468
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:289
void DeleteObject(const long unsigned int nIndex)
Delete the object at a given index from the waypoint handler object list.
Definition WaypointHandler.cpp:365
bool DeletePath(const std::string &szPathName)
Delete the path vector stored at the given key.
Definition WaypointHandler.cpp:349
~WaypointHandler()
Destroy the geoops::Waypoint Handler:: geoops::Waypoint Handler object.
Definition WaypointHandler.cpp:46
double SmartRetrieveVelocity()
Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDC...
Definition WaypointHandler.cpp:883
const geoops::Waypoint PeekNextWaypoint()
Returns an immutable reference to the geoops::Waypoint struct at the front of the list without removi...
Definition WaypointHandler.cpp:539
const geoops::Waypoint RetrieveWaypointAtIndex(const long unsigned int nIndex)
Retrieve an immutable reference to the waypoint at the given index.
Definition WaypointHandler.cpp:568
int GetPathsCount()
Accessor for the number of paths stored in the WaypointHandler.
Definition WaypointHandler.cpp:702
geoops::RoverPose SmartRetrieveRoverPose(bool bVIOTracking=false)
Retrieve the rover's current position and heading. Automatically picks between getting the position/h...
Definition WaypointHandler.cpp:738
void StorePath(const std::string &szPathName, const std::vector< geoops::Waypoint > &vWaypointPath)
Store a path in the WaypointHandler.
Definition WaypointHandler.cpp:119
void ClearObjects()
Clears/deletes all permanent objects stored in the WaypointHandler.
Definition WaypointHandler.cpp:483
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:143
WaypointHandler()
Construct a new geoops::Waypoint Handler:: geoops::Waypoint Handler object.
Definition WaypointHandler.cpp:29
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
geoops::Waypoint PopNextWaypoint()
Removes and returns the next waypoint at the front of the list.
Definition WaypointHandler.cpp:499
const std::vector< geoops::Waypoint > RetrievePath(const std::string &szPathName)
Retrieve an immutable reference to the path at the given path name/key.
Definition WaypointHandler.cpp:599
void AddObject(const geoops::Waypoint &stWaypoint)
Append a new object to the WaypointHandler object list.
Definition WaypointHandler.cpp:202
int GetWaypointCount()
Accessor for the number of elements on the WaypointHandler's waypoint vector.
Definition WaypointHandler.cpp:686
void ClearWaypoints()
Clears/deletes all Waypoints stored in the WaypointHandler.
Definition WaypointHandler.cpp:453
const std::vector< geoops::Waypoint > GetAllWaypoints()
Accessor for the full list of current waypoints stored in the WaypointHandler.
Definition WaypointHandler.cpp:653
double SmartRetrieveAngularVelocity()
Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDC...
Definition WaypointHandler.cpp:899
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:241
void AddWaypoint(const geoops::Waypoint &stWaypoint)
Append a waypoint to the end of the WaypointHandler's list.
Definition WaypointHandler.cpp:60
const std::vector< geoops::Waypoint > GetAllObjects()
Accessor for the full list of current object stored in the WaypointHandler.
Definition WaypointHandler.cpp:670
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:193
const geoops::Waypoint RetrieveObjectAtIndex(const long unsigned int nIndex)
Retrieve an immutable reference to the object at the given index.
Definition WaypointHandler.cpp:625
void DeleteWaypoint(const long unsigned int nIndex)
Delete the geoops::Waypoint at a given index from the waypoint handler.
Definition WaypointHandler.cpp:258
int GetObjectsCount()
Accessor for the number of elements on the WaypointHandler's object vector.
Definition WaypointHandler.cpp:718
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:148
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:674
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:244
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:551