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_vPermanentObstacles;
100 std::shared_mutex m_muObstaclesMutex;
114 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
121 geoops::WaypointType::eNavigationWaypoint,
126 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
128 m_vWaypointList.emplace_back(stNavWaypoint);
130 lkWaypointsLock.unlock();
133 LOG_NOTICE(logging::g_qSharedLogger,
134 "Incoming Navigation Waypoint Data: Added (lat: {}, lon: {}, id: {}) to WaypointHandler queue.",
148 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
154 int nMarkerID = stPacket.vData[2];
155 double dRadius = stPacket.vData[3];
161 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Marker Waypoint Data: Radius is less than 0, setting to 0.");
164 else if (dRadius > 40)
167 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Marker Waypoint Data: Radius is greater than 40, setting to 40.");
175 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
177 m_vWaypointList.emplace_back(stMarkerWaypoint);
179 lkWaypointsLock.unlock();
182 LOG_NOTICE(logging::g_qSharedLogger,
183 "Incoming Marker Waypoint Data: Added (lat: {}, lon: {}, marker ID: {}, radius: {}) to WaypointHandler queue.",
198 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
204 geoops::WaypointType eWaypointType = geoops::WaypointType::eObjectWaypoint;
205 double dObjectID = stPacket.vData[2];
206 double dRadius = stPacket.vData[3];
209 if (dObjectID ==
static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::MALLET))
211 eWaypointType = geoops::WaypointType::eMalletWaypoint;
213 else if (dObjectID ==
static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::WATERBOTTLE))
215 eWaypointType = geoops::WaypointType::eWaterBottleWaypoint;
219 eWaypointType = geoops::WaypointType::eObjectWaypoint;
226 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Object Waypoint Data: Radius is less than 0, setting to 0.");
229 else if (dRadius > 40)
232 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Object Waypoint Data: Radius is greater than 40, setting to 40.");
240 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
242 m_vWaypointList.emplace_back(stObjectWaypoint);
244 lkWaypointsLock.unlock();
247 LOG_NOTICE(logging::g_qSharedLogger,
248 "Incoming Object Waypoint Data: Added (lat: {}, lon: {}, id: {}, radius: {}) to WaypointHandler queue.",
262 const std::function<void(
const rovecomm::RoveCommPacket<double>&,
const sockaddr_in&)>
AddObstacleCallback =
263 [
this](
const rovecomm::RoveCommPacket<double>& stPacket,
const sockaddr_in& stdAddr)
269 double dRadius = stPacket.vData[2];
275 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Obstacle Waypoint Data: Radius is less than 0, setting to 0.");
278 else if (dRadius > 40)
281 LOG_WARNING(logging::g_qSharedLogger,
"Incoming Obstacle Waypoint Data: Radius is greater than 40, setting to 40.");
289 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
291 m_vPermanentObstacles.emplace_back(stObstacleWaypoint);
293 lkWaypointsLock.unlock();
296 LOG_NOTICE(logging::g_qSharedLogger,
297 "Incoming Obstacle Waypoint Data: Added (lat: {}, lon: {}, radius: {}) to WaypointHandler queue. Total Obstacles: {}",
301 m_vPermanentObstacles.size());
312 [
this](
const rovecomm::RoveCommPacket<uint8_t>& stPacket,
const sockaddr_in& stdAddr)
319 std::unique_lock<std::shared_mutex> lkWaypointsLock(m_muWaypointsMutex);
321 m_vWaypointList.clear();
323 lkWaypointsLock.unlock();
326 LOG_NOTICE(logging::g_qSharedLogger,
"Incoming Clear Waypoints packet: Cleared WaypointHandler queue.");
337 [
this](
const rovecomm::RoveCommPacket<uint8_t>& stPacket,
const sockaddr_in& stdAddr)
344 std::unique_lock<std::shared_mutex> lkObstaclesLock(m_muObstaclesMutex);
346 m_vPermanentObstacles.clear();
348 lkObstaclesLock.unlock();
351 LOG_NOTICE(logging::g_qSharedLogger,
"Incoming Clear Obstacles packet: Cleared permanent obstacles list.");
The WaypointHandler class is used throughout the entire project (mainly by the state machine) to glob...
Definition WaypointHandler.h:33
int GetObstaclesCount()
Accessor for the number of elements on the WaypointHandler's obstacle vector.
Definition WaypointHandler.cpp:721
void AddObstacle(const geoops::Waypoint &stWaypoint)
Append a new obstacle to the WaypointHandler obstacle list.
Definition WaypointHandler.cpp:203
void ClearPaths()
Clears/deletes all keys and paths store in the WaypointHandler.
Definition WaypointHandler.cpp:469
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
bool DeletePath(const std::string &szPathName)
Delete the path vector stored at the given key.
Definition WaypointHandler.cpp:350
~WaypointHandler()
Destroy the geoops::Waypoint Handler:: geoops::Waypoint Handler obstacle.
Definition WaypointHandler.cpp:47
double SmartRetrieveVelocity()
Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDC...
Definition WaypointHandler.cpp:912
const geoops::Waypoint PeekNextWaypoint()
Returns an immutable reference to the geoops::Waypoint struct at the front of the list without removi...
Definition WaypointHandler.cpp:540
const geoops::Waypoint RetrieveWaypointAtIndex(const long unsigned int nIndex)
Retrieve an immutable reference to the waypoint at the given index.
Definition WaypointHandler.cpp:569
int GetPathsCount()
Accessor for the number of paths stored in the WaypointHandler.
Definition WaypointHandler.cpp:705
void StorePath(const std::string &szPathName, const std::vector< geoops::Waypoint > &vWaypointPath)
Store a path in the WaypointHandler.
Definition WaypointHandler.cpp:120
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
geoops::RoverPose SmartRetrieveRoverPose(bool bVIOHeading=true, bool bVIOTracking=false)
Retrieve the rover's current position and heading. Automatically picks between getting the position/h...
Definition WaypointHandler.cpp:742
void DeleteObstacle(const long unsigned int nIndex)
Delete the obstacle at a given index from the waypoint handler obstacle list.
Definition WaypointHandler.cpp:366
void ClearObstacles()
Clears/deletes all permanent objects stored in the WaypointHandler.
Definition WaypointHandler.cpp:484
WaypointHandler()
Construct a new geoops::Waypoint Handler:: geoops::Waypoint Handler obstacle.
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:500
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:600
int GetWaypointCount()
Accessor for the number of elements on the WaypointHandler's waypoint vector.
Definition WaypointHandler.cpp:689
void ClearWaypoints()
Clears/deletes all Waypoints stored in the WaypointHandler.
Definition WaypointHandler.cpp:454
const std::vector< geoops::Waypoint > GetAllWaypoints()
Accessor for the full list of current waypoints stored in the WaypointHandler.
Definition WaypointHandler.cpp:656
double SmartRetrieveAngularVelocity()
Retrieve the rover's current velocity. Currently there is no easy way to get the velocity of the ZEDC...
Definition WaypointHandler.cpp:928
const std::vector< geoops::Waypoint > GetAllObstacles()
Accessor for the full list of current obstacle stored in the WaypointHandler.
Definition WaypointHandler.cpp:673
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
void AddWaypoint(const geoops::Waypoint &stWaypoint)
Append a waypoint to the end of the WaypointHandler's list.
Definition WaypointHandler.cpp:61
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
const geoops::Waypoint RetrieveObstacleAtIndex(const long unsigned int nIndex)
Retrieve an immutable reference to the obstacle at the given index.
Definition WaypointHandler.cpp:626
void DeleteWaypoint(const long unsigned int nIndex)
Delete the geoops::Waypoint at a given index from the waypoint handler.
Definition WaypointHandler.cpp:259
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:99
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:677
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:195
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:392