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
logging::graphing::PathTracer Class Reference

The PathTracer class is used to trace the path of the rover and plot the path on a 2D graph. More...

#include <PathTracer2D.hpp>

Public Member Functions

 PathTracer (const std::string &szPlotTitle="Graph")
 Construct a new Path Tracer object.
 
 ~PathTracer ()
 Destroy the Path Tracer object.
 
bool CreatePathLayer (const std::string &szLayerName, const std::string &szStyleString="-o")
 Add a new draw layer to the plot.
 
bool CreateDotLayer (const std::string &szLayerName, const std::string &szColorString="blue", const bool bFillMarkerFace=true)
 Add a new draw layer to the plot.
 
bool DeleteLayer (const std::string &szLayerName)
 Delete a draw layer from the plot.
 
bool ClearLayer (const std::string &szLayerName)
 Clear the path or dots of a layer.
 
void AddPathPoint (const geoops::Waypoint &stWaypoint, const std::string &szLayerName, const uint nMaxWaypointsPerSecond=1)
 Add a waypoint to the path and plot the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddPathPoint (const geoops::UTMCoordinate &stCoordinate, const std::string &szLayerName, const uint nMaxWaypointsPerSecond=1)
 Add a waypoint to the path and plot the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddPathPoint (const geoops::GPSCoordinate &stCoordinate, const std::string &szLayerName, const uint nMaxWaypointsPerSecond=1)
 Add a waypoint to the path and plot the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddPathPoints (const std::vector< geoops::Waypoint > &stWaypoints, const std::string &szLayerName, const uint unMaxUpdatesPerSecond=1)
 Add a waypoint to the path and plot the path. This method has no limit to the number of waypoints that can be added per call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddPathPoints (const std::vector< geoops::UTMCoordinate > &vCoordinates, const std::string &szLayerName, const uint unMaxUpdatesPerSecond=1)
 Add a waypoint to the path and plot the path. This method has no limit to the number of waypoints that can be added per call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddPathPoints (const std::vector< geoops::GPSCoordinate > &vCoordinates, const std::string &szLayerName, const uint unMaxUpdatesPerSecond=1)
 Add a waypoint to the path and plot the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddDot (const geoops::Waypoint &stWaypoint, const std::string &szLayerName, const uint nMaxWaypointsPerSecond=1)
 Add a waypoint as a dot to the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddDot (const geoops::UTMCoordinate &stCoordinate, const std::string &szLayerName, const uint nMaxWaypointsPerSecond=1, const double dDotRadius=5)
 Add a waypoint as a dot to the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddDot (const geoops::GPSCoordinate &stCoordinate, const std::string &szLayerName, const uint nMaxWaypointsPerSecond=1, const double dDotRadius=5)
 Add a waypoint as a dot to the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddDots (const std::vector< geoops::Waypoint > &stWaypoints, const std::string &szLayerName, const uint unMaxUpdatesPerSecond=1)
 Add a waypoint as a dot to the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddDots (const std::vector< geoops::UTMCoordinate > &vCoordinates, const std::string &szLayerName, const uint unMaxUpdatesPerSecond=1, const double dDotRadius=5)
 Add a waypoint as a dot to the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.
 
void AddDots (const std::vector< geoops::GPSCoordinate > &vCoordinates, const std::string &szLayerName, const uint unMaxUpdatesPerSecond=1, const double dDotRadius=5)
 Add a waypoint as a dot to the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.
 

Private Member Functions

void UpdatePlot ()
 Update the plot with the new waypoints and redraw the plot.
 
bool CheckPathUpdateTime (const std::string &szLayerName, const uint unMaxUpdatesPerSecond)
 Checks the unordered map of last update times for a given layer name and returns true if the time since the last update is greater than the maximum updates per second, then it updates the time in the map. If the layer name does not exist in the map then it returns false. If the given update time is 0, then it will just check if the layer name exists in the map.
 
bool CheckDotUpdateTime (const std::string &szLayerName, const uint unMaxUpdatesPerSecond)
 Checks the unordered map of last update times for a given layer name and returns true if the time since the last update is greater than the maximum updates per second, then it updates the time in the map. If the layer name does not exist in the map then it returns false. If the given update time is 0, then it will just check if the layer name exists in the map.
 

Private Attributes

matplot::figure_handle m_mtRoverPathPlot
 
matplot::axes_handle m_mtRoverPathAxes
 
std::unordered_map< std::string, std::string > m_umPathLineStyleMap
 
std::unordered_map< std::string, std::pair< std::string, bool > > m_umDotLineStyleMap
 
std::unordered_map< std::string, std::chrono::system_clock::time_point > m_umLastPlotUpdateTimeMap
 
std::unordered_map< std::string, std::chrono::system_clock::time_point > m_umLastDotUpdateTimeMap
 
std::unordered_map< std::string, std::vector< std::pair< double, double > > > m_umPathMap
 
std::unordered_map< std::string, std::vector< std::tuple< double, double, double > > > m_umDotMap
 
std::string m_szPlotTitle
 
std::string m_szCurrentPlotSavePath
 

Detailed Description

The PathTracer class is used to trace the path of the rover and plot the path on a 2D graph.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08

Constructor & Destructor Documentation

◆ PathTracer()

logging::graphing::PathTracer::PathTracer ( const std::string &  szPlotTitle = "Graph")
inline

Construct a new Path Tracer object.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
63 {
64 // Initialize member variables.
65 m_mtRoverPathPlot = matplot::figure(true);
66 m_mtRoverPathAxes = m_mtRoverPathPlot->current_axes();
67 m_szPlotTitle = szPlotTitle;
68
69 // Check if a file with the same title name already exists. If so then append a number to the end of the file name and recheck.
70 std::string szPlotSavePath = logging::g_szLoggingOutputPath + "/path_plots/" + m_szPlotTitle;
71 m_szCurrentPlotSavePath = logging::g_szLoggingOutputPath + "/path_plots/CurrentPlot.png";
72 int nFileNum = 0;
73 while (std::filesystem::exists(szPlotSavePath + std::to_string(nFileNum) + ".png"))
74 {
75 ++nFileNum;
76 }
77 // Add the file number to the file name.
78 szPlotSavePath = szPlotSavePath + std::to_string(nFileNum);
79 // Check if the final directory exists. If not then create it.
80 if (!std::filesystem::exists(logging::g_szLoggingOutputPath + "/path_plots"))
81 {
82 std::filesystem::create_directory(logging::g_szLoggingOutputPath + "/path_plots");
83 }
84
85 // Configure the matplotplusplus gnuplot backend to not display the plot, instead save it to a file.
86 m_mtRoverPathPlot->backend()->output(szPlotSavePath + ".png");
87
88 // Make sure plot title is not empty.
89 if (m_szPlotTitle.empty())
90 {
91 // Submit logger message.
92 LOG_WARNING(logging::g_qSharedLogger, "Plot title is empty. Setting title to default.");
93 m_szPlotTitle = "RoverPath";
94 }
95
96 // Configure plot.
97 m_mtRoverPathPlot->title(m_szPlotTitle);
98 m_mtRoverPathAxes->xlabel("Easting");
99 m_mtRoverPathAxes->ylabel("Northing");
100 }

◆ ~PathTracer()

logging::graphing::PathTracer::~PathTracer ( )
inline

Destroy the Path Tracer object.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
110 {
111 // Nothing to do yet.
112 }

Member Function Documentation

◆ CreatePathLayer()

bool logging::graphing::PathTracer::CreatePathLayer ( const std::string &  szLayerName,
const std::string &  szStyleString = "-o" 
)
inline

Add a new draw layer to the plot.

Parameters
szLayerName- The alias name of the layer.
szStyleString- The style of the layer. Default is "-o" which is a blue line with blue dots. Here are the full options for the style string: Line Styles: "-": Solid line "--": Dashed line "-.": Dash-dot line ":": Dotted line Marker Styles "+": Plus sign "o": Circle "*": Asterisk ".": Point "x": Cross "s" or "square": Square "d" or "diamond": Diamond "^": Upward-pointing triangle "v" or "V": Downward-pointing triangle ">": Custom marker (right arrow, ▶) "<": Custom marker (left arrow, ◀) "p" or "pentagram": Pentagram "h" or "hexagram": Hexagram

Colors: (These colors can be used for line color, marker color, or marker face color. The letter corresponds to a color) "b": Blue "k": Black "r": Red "g": Green "y": Yellow "c": Cyan "m": Magenta "w": White Additional Options: "f" or "filled": Fills the marker's face (if the marker style supports it). Line width and marker size can be adjusted programmatically, not directly in the style string. Example Usage of Style Strings You can combine line styles, marker styles, and colors into a single string:

"--o": Dashed line with circle markers. ":x": Dotted line with cross markers. "-r": Solid red line. "o": Circle markers with default line style (solid). "-om": Solid magenta line with circle markers.

Returns
true - The layer was successfully created.
false - The layer already exists and cannot be created.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
167 {
168 // Check if the layer name exists in the map.
169 if (m_umPathMap.find(szLayerName) != m_umPathMap.end())
170 {
171 // Submit logger message.
172 LOG_WARNING(logging::g_qSharedLogger, "Layer already exists. Cannot create layer.");
173 return false;
174 }
175
176 // Add the layer to the maps.
177 m_umPathMap[szLayerName] = std::vector<std::pair<double, double>>();
178 m_umPathLineStyleMap[szLayerName] = szStyleString;
179 m_umLastPlotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
180
181 return true;
182 }

◆ CreateDotLayer()

bool logging::graphing::PathTracer::CreateDotLayer ( const std::string &  szLayerName,
const std::string &  szColorString = "blue",
const bool  bFillMarkerFace = true 
)
inline

Add a new draw layer to the plot.

Parameters
szLayerName- The alias name of the layer.
szColorString- The color of the layer. The default is "blue". Here are the full options for the color string: "blue": Blue "black": Black "red": Red "green": Green "yellow": Yellow "cyan": Cyan "magenta": Magenta "white": White
bFillMarkerFace- Whether or not to fill the marker face. Default is true.
Returns
true - The layer was successfully created.
false - The layer already exists and cannot be created.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
206 {
207 // Check if the layer name exists in the map.
208 if (m_umDotMap.find(szLayerName) != m_umDotMap.end())
209 {
210 // Submit logger message.
211 LOG_WARNING(logging::g_qSharedLogger, "Layer already exists. Cannot create layer.");
212 return false;
213 }
214
215 // Add the layer to the maps.
216 m_umDotMap[szLayerName] = std::vector<std::tuple<double, double, double>>();
217 m_umDotLineStyleMap[szLayerName] = std::make_pair(szColorString, bFillMarkerFace);
218 m_umLastDotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
219
220 return true;
221 }

◆ DeleteLayer()

bool logging::graphing::PathTracer::DeleteLayer ( const std::string &  szLayerName)
inline

Delete a draw layer from the plot.

Parameters
szLayerName- The alias name of the layer.
Returns
true - The layer was successfully deleted.
false - The layer does not exist and cannot be deleted.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
234 {
235 // Check if the layer name exist in the path or dot maps.
236 if (m_umPathMap.find(szLayerName) == m_umPathMap.end() && m_umDotMap.find(szLayerName) == m_umDotMap.end())
237 {
238 // Submit logger message.
239 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot delete layer.");
240 return false;
241 }
242
243 // Remove the appropriate layers from the maps.
244 if (m_umPathMap.find(szLayerName) != m_umPathMap.end())
245 {
246 m_umPathMap.erase(szLayerName);
247 m_umPathLineStyleMap.erase(szLayerName);
248 m_umLastPlotUpdateTimeMap.erase(szLayerName);
249 }
250 if (m_umDotMap.find(szLayerName) != m_umDotMap.end())
251 {
252 m_umDotMap.erase(szLayerName);
253 m_umDotLineStyleMap.erase(szLayerName);
254 m_umLastDotUpdateTimeMap.erase(szLayerName);
255 }
256
257 return true;
258 }

◆ ClearLayer()

bool logging::graphing::PathTracer::ClearLayer ( const std::string &  szLayerName)
inline

Clear the path or dots of a layer.

Parameters
szLayerName- The alias name of the layer.
Returns
true - The layer was successfully cleared.
false - The layer does not exist and cannot be cleared.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
271 {
272 // Check if the layer name exist in the path or dot maps.
273 if (m_umPathMap.find(szLayerName) == m_umPathMap.end() && m_umDotMap.find(szLayerName) == m_umDotMap.end())
274 {
275 // Submit logger message.
276 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot clear layer.");
277 return false;
278 }
279
280 // Clear the appropriate layer.
281 if (m_umPathMap.find(szLayerName) != m_umPathMap.end())
282 {
283 m_umPathMap[szLayerName].clear();
284 }
285 if (m_umDotMap.find(szLayerName) != m_umDotMap.end())
286 {
287 m_umDotMap[szLayerName].clear();
288 }
289
290 return true;
291 }

◆ AddPathPoint() [1/3]

void logging::graphing::PathTracer::AddPathPoint ( const geoops::Waypoint stWaypoint,
const std::string &  szLayerName,
const uint  nMaxWaypointsPerSecond = 1 
)
inline

Add a waypoint to the path and plot the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stWaypoint- The waypoint to add to the path.
szLayerName- The name of the layer to add the waypoints to.
nMaxWaypointsPerSecond- The maximum number of waypoints that can be added per second.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
306 {
307 // Check the update time.
308 if (!this->CheckPathUpdateTime(szLayerName, nMaxWaypointsPerSecond))
309 {
310 // Return if the maximum number of waypoints per second has been exceeded.
311 return;
312 }
313
314 // Add the waypoint to the path.
315 m_umPathMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting, stWaypoint.GetUTMCoordinate().dNorthing);
316
317 // Update the plot.
318 this->UpdatePlot();
319 }
bool CheckPathUpdateTime(const std::string &szLayerName, const uint unMaxUpdatesPerSecond)
Checks the unordered map of last update times for a given layer name and returns true if the time sin...
Definition PathTracer2D.hpp:809
void UpdatePlot()
Update the plot with the new waypoints and redraw the plot.
Definition PathTracer2D.hpp:710
const geoops::UTMCoordinate & GetUTMCoordinate() const
Accessor for the geoops::UTMCoordinate member variable.
Definition GeospatialOperations.hpp:477
Here is the call graph for this function:

◆ AddPathPoint() [2/3]

void logging::graphing::PathTracer::AddPathPoint ( const geoops::UTMCoordinate stCoordinate,
const std::string &  szLayerName,
const uint  nMaxWaypointsPerSecond = 1 
)
inline

Add a waypoint to the path and plot the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stCoordinate- The coordinate of the waypoint to add to the path.
szLayerName- The name of the layer to add the waypoints to.
nMaxWaypointsPerSecond- The maximum number of waypoints that can be added per second.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
334 {
335 // Check the update time.
336 if (!this->CheckPathUpdateTime(szLayerName, nMaxWaypointsPerSecond))
337 {
338 // Return if the maximum number of waypoints per second has been exceeded.
339 return;
340 }
341
342 // Add the waypoint to the path.
343 m_umPathMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing);
344
345 // Update the plot.
346 this->UpdatePlot();
347 }
Here is the call graph for this function:

◆ AddPathPoint() [3/3]

void logging::graphing::PathTracer::AddPathPoint ( const geoops::GPSCoordinate stCoordinate,
const std::string &  szLayerName,
const uint  nMaxWaypointsPerSecond = 1 
)
inline

Add a waypoint to the path and plot the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stCoordinate- The coordinate of the waypoint to add to the path.
szLayerName- The name of the layer to add the waypoints to.
nMaxWaypointsPerSecond- The maximum number of waypoints that can be added per second.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
362 {
363 // Check the update time.
364 if (!this->CheckPathUpdateTime(szLayerName, nMaxWaypointsPerSecond))
365 {
366 // Return if the maximum number of waypoints per second has been exceeded.
367 return;
368 }
369
370 // Create instance variables.
371 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
372
373 // Add the waypoint to the path.
374 m_umPathMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing);
375
376 // Update the plot.
377 this->UpdatePlot();
378 }
UTMCoordinate ConvertGPSToUTM(const GPSCoordinate &stGPSCoord)
Given a GPS coordinate, convert to UTM and create a new UTMCoordinate object.
Definition GeospatialOperations.hpp:302
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:195
Here is the call graph for this function:

◆ AddPathPoints() [1/3]

void logging::graphing::PathTracer::AddPathPoints ( const std::vector< geoops::Waypoint > &  stWaypoints,
const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond = 1 
)
inline

Add a waypoint to the path and plot the path. This method has no limit to the number of waypoints that can be added per call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stWaypoints- The waypoints to add to the path.
szLayerName- The name of the layer to add the waypoints to.
unMaxUpdatesPerSecond- The maximum number of waypoints that can be added per second. Set to 0 for no limit.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
394 {
395 // Check the update time.
396 if (!this->CheckPathUpdateTime(szLayerName, unMaxUpdatesPerSecond))
397 {
398 // Return if the maximum number of waypoints per second has been exceeded.
399 return;
400 }
401
402 // Add the waypoints to the vector or double pairs at the given layer name in the map.
403 for (const geoops::Waypoint& stWaypoint : stWaypoints)
404 {
405 m_umPathMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting, stWaypoint.GetUTMCoordinate().dNorthing);
406 }
407
408 // Update the plot.
409 this->UpdatePlot();
410 }
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:392
Here is the call graph for this function:

◆ AddPathPoints() [2/3]

void logging::graphing::PathTracer::AddPathPoints ( const std::vector< geoops::UTMCoordinate > &  vCoordinates,
const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond = 1 
)
inline

Add a waypoint to the path and plot the path. This method has no limit to the number of waypoints that can be added per call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
vCoordinates- The coordinates to add to the path.
szLayerName- The name of the layer to add the waypoints to.
unMaxUpdatesPerSecond- The maximum number of waypoints that can be added per second. Set to 0 for no limit.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
426 {
427 // Check the update time.
428 if (!this->CheckPathUpdateTime(szLayerName, unMaxUpdatesPerSecond))
429 {
430 // Return if the maximum number of waypoints per second has been exceeded.
431 return;
432 }
433
434 // Add the waypoints to the vector or double pairs at the given layer name in the map.
435 for (const geoops::UTMCoordinate& stCoordinate : vCoordinates)
436 {
437 m_umPathMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing);
438 }
439
440 // Update the plot.
441 this->UpdatePlot();
442 }
Here is the call graph for this function:

◆ AddPathPoints() [3/3]

void logging::graphing::PathTracer::AddPathPoints ( const std::vector< geoops::GPSCoordinate > &  vCoordinates,
const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond = 1 
)
inline

Add a waypoint to the path and plot the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
vCoordinates- The coordinates to add to the path.
szLayerName- The name of the layer to add the waypoints to.
unMaxUpdatesPerSecond- The maximum number of waypoints that can be added per second. Set to 0 for no limit.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
458 {
459 // Check the update time.
460 if (!this->CheckPathUpdateTime(szLayerName, unMaxUpdatesPerSecond))
461 {
462 // Return if the maximum number of waypoints per second has been exceeded.
463 return;
464 }
465
466 // Add the waypoints to the vector or double pairs at the given layer name in the map.
467 for (const geoops::GPSCoordinate& stCoordinate : vCoordinates)
468 {
469 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
470 m_umPathMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing);
471 }
472
473 // Update the plot.
474 this->UpdatePlot();
475 }
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:99
Here is the call graph for this function:

◆ AddDot() [1/3]

void logging::graphing::PathTracer::AddDot ( const geoops::Waypoint stWaypoint,
const std::string &  szLayerName,
const uint  nMaxWaypointsPerSecond = 1 
)
inline

Add a waypoint as a dot to the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stWaypoint- The waypoint to add to the path.
szLayerName- The name of the layer to add the waypoints to.
nMaxWaypointsPerSecond- The maximum number of waypoints that can be added per second.
Note
Because this method uses Waypoint structs, the radius of the waypoint will be used as the size of the dot.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
492 {
493 // Check the update time.
494 if (!this->CheckDotUpdateTime(szLayerName, nMaxWaypointsPerSecond))
495 {
496 // Return if the maximum number of waypoints per second has been exceeded.
497 return;
498 }
499
500 // Check the radius of the waypoint. It shouldn't be less than 0.
501 if (stWaypoint.dRadius <= 0)
502 {
503 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting, stWaypoint.GetUTMCoordinate().dNorthing, 5);
504 }
505 else
506 {
507 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting, stWaypoint.GetUTMCoordinate().dNorthing, stWaypoint.dRadius);
508 }
509
510 // Update the plot.
511 this->UpdatePlot();
512 }
bool CheckDotUpdateTime(const std::string &szLayerName, const uint unMaxUpdatesPerSecond)
Checks the unordered map of last update times for a given layer name and returns true if the time sin...
Definition PathTracer2D.hpp:851
Here is the call graph for this function:

◆ AddDot() [2/3]

void logging::graphing::PathTracer::AddDot ( const geoops::UTMCoordinate stCoordinate,
const std::string &  szLayerName,
const uint  nMaxWaypointsPerSecond = 1,
const double  dDotRadius = 5 
)
inline

Add a waypoint as a dot to the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stCoordinate- The coordinate of the waypoint to add to the path.
szLayerName- The name of the layer to add the waypoints to.
nMaxWaypointsPerSecond- The maximum number of waypoints that can be added per second.
dDotRadius- The radius of the dot to add to the path.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
528 {
529 // Check the update time.
530 if (!this->CheckDotUpdateTime(szLayerName, nMaxWaypointsPerSecond))
531 {
532 // Return if the maximum number of waypoints per second has been exceeded.
533 return;
534 }
535
536 // Add the waypoint to the path.
537 m_umDotMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing, dDotRadius);
538
539 // Update the plot.
540 this->UpdatePlot();
541 }
Here is the call graph for this function:

◆ AddDot() [3/3]

void logging::graphing::PathTracer::AddDot ( const geoops::GPSCoordinate stCoordinate,
const std::string &  szLayerName,
const uint  nMaxWaypointsPerSecond = 1,
const double  dDotRadius = 5 
)
inline

Add a waypoint as a dot to the path. This method has a limit to the number of waypoints that can be added per second. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stCoordinate- The coordinate of the waypoint to add to the path.
szLayerName- The name of the layer to add the waypoints to.
nMaxWaypointsPerSecond- The maximum number of waypoints that can be added per second.
dDotRadius- The radius of the dot to add to the path.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
557 {
558 // Check the update time.
559 if (!this->CheckDotUpdateTime(szLayerName, nMaxWaypointsPerSecond))
560 {
561 // Return if the maximum number of waypoints per second has been exceeded.
562 return;
563 }
564
565 // Create instance variables.
566 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
567
568 // Add the waypoint to the path.
569 m_umDotMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing, dDotRadius);
570
571 // Update the plot.
572 this->UpdatePlot();
573 }
Here is the call graph for this function:

◆ AddDots() [1/3]

void logging::graphing::PathTracer::AddDots ( const std::vector< geoops::Waypoint > &  stWaypoints,
const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond = 1 
)
inline

Add a waypoint as a dot to the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
stWaypoints- The waypoints to add to the path.
szLayerName- The name of the layer to add the waypoints to.
unMaxUpdatesPerSecond- The maximum number of waypoints that can be added per second. Set to 0 for no limit.
Note
Because this method uses Waypoint structs, the radius of the waypoint will be used as the size of the dot.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
591 {
592 // Check the update time.
593 if (!this->CheckDotUpdateTime(szLayerName, unMaxUpdatesPerSecond))
594 {
595 // Return if the maximum number of waypoints per second has been exceeded.
596 return;
597 }
598
599 // Add the waypoints to the vector or double pairs at the given layer name in the map.
600 for (const geoops::Waypoint& stWaypoint : stWaypoints)
601 {
602 // Check the radius of the waypoint. It shouldn't be less than 0.
603 if (stWaypoint.dRadius <= 0)
604 {
605 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting, stWaypoint.GetUTMCoordinate().dNorthing, 5);
606 }
607 else
608 {
609 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting, stWaypoint.GetUTMCoordinate().dNorthing, stWaypoint.dRadius);
610 }
611 }
612
613 // Update the plot.
614 this->UpdatePlot();
615 }
Here is the call graph for this function:

◆ AddDots() [2/3]

void logging::graphing::PathTracer::AddDots ( const std::vector< geoops::UTMCoordinate > &  vCoordinates,
const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond = 1,
const double  dDotRadius = 5 
)
inline

Add a waypoint as a dot to the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
vCoordinates- The coordinates to add to the path.
szLayerName- The name of the layer to add the waypoints to.
unMaxUpdatesPerSecond- The maximum number of waypoints that can be added per second. Set to 0 for no limit.
dDotRadius- The radius of the dot to add to the path.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
635 {
636 // Check the update time.
637 if (!this->CheckDotUpdateTime(szLayerName, unMaxUpdatesPerSecond))
638 {
639 // Return if the maximum number of waypoints per second has been exceeded.
640 return;
641 }
642
643 // Add the waypoints to the vector or double pairs at the given layer name in the map.
644 for (const geoops::UTMCoordinate& stCoordinate : vCoordinates)
645 {
646 m_umDotMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing, dDotRadius);
647 }
648
649 // Update the plot.
650 this->UpdatePlot();
651 }
Here is the call graph for this function:

◆ AddDots() [3/3]

void logging::graphing::PathTracer::AddDots ( const std::vector< geoops::GPSCoordinate > &  vCoordinates,
const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond = 1,
const double  dDotRadius = 5 
)
inline

Add a waypoint as a dot to the path. This method has no limit to the number of waypoints that can be added per one call. But the number of waypoints that can be added per second is limited. Set the maximum number of waypoints per second to 0 for no limit.

Parameters
vCoordinates- The coordinates to add to the path.
szLayerName- The name of the layer to add the waypoints to.
unMaxUpdatesPerSecond- The maximum number of waypoints that can be added per second. Set to 0 for no limit.
dDotRadius- The radius of the dot to add to the path.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
671 {
672 // Check the update time.
673 if (!this->CheckDotUpdateTime(szLayerName, unMaxUpdatesPerSecond))
674 {
675 // Return if the maximum number of waypoints per second has been exceeded.
676 return;
677 }
678
679 // Add the waypoints to the vector or double pairs at the given layer name in the map.
680 for (const geoops::GPSCoordinate& stCoordinate : vCoordinates)
681 {
682 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
683 m_umDotMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing, dDotRadius);
684 }
685
686 // Update the plot.
687 this->UpdatePlot();
688 }
Here is the call graph for this function:

◆ UpdatePlot()

void logging::graphing::PathTracer::UpdatePlot ( )
inlineprivate

Update the plot with the new waypoints and redraw the plot.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-08
711 {
712 // Create instance variables.
713 std::vector<std::string> vLayerNames;
714
715 // Clear the plot.
716 m_mtRoverPathAxes->clear();
717
718 /*
719 PATHS
720 */
721 // Loop through each of the layer name keys in the map.
722 for (const std::pair<const std::string, const std::string>& stdLayer : m_umPathLineStyleMap)
723 {
724 // Check if the vector or coordinates has more than one point.
725 if (m_umPathMap[stdLayer.first].size() > 1)
726 {
727 // Add the layer name to the vector.
728 vLayerNames.push_back(stdLayer.first);
729
730 // Get the x and y coordinates for the layer.
731 std::vector<double> vEasting, vNorthing;
732 for (const std::pair<double, double>& stCoordinate : m_umPathMap[stdLayer.first])
733 {
734 vEasting.push_back(stCoordinate.first);
735 vNorthing.push_back(stCoordinate.second);
736 }
737
738 // Plot the path.
739 m_mtRoverPathAxes->plot(vEasting, vNorthing, std::string_view(stdLayer.second));
740 // Set the hold to true.
741 m_mtRoverPathAxes->hold(true);
742 }
743 }
744
745 /*
746 DOTS
747 */
748 // Loop through each of the layer name keys in the map.
749 for (const std::pair<const std::string, const std::pair<std::string, bool>>& stdLayer : m_umDotLineStyleMap)
750 {
751 // Check if the vector or coordinates has at least one point.
752 if (m_umDotMap[stdLayer.first].size() > 0)
753 {
754 // Add the layer name to the vector.
755 vLayerNames.push_back(stdLayer.first);
756
757 // Get the x and y coordinates for the layer.
758 std::vector<double> vEasting, vNorthing, vRadius;
759 for (const std::tuple<double, double, double>& stCoordinate : m_umDotMap[stdLayer.first])
760 {
761 vEasting.push_back(std::get<0>(stCoordinate));
762 vNorthing.push_back(std::get<1>(stCoordinate));
763 vRadius.push_back(std::get<2>(stCoordinate));
764 }
765
766 // Plot the path.
767 matplot::line_handle mtLineHandle = m_mtRoverPathAxes->scatter(vEasting, vNorthing, vRadius);
768 mtLineHandle->color(stdLayer.second.first);
769 mtLineHandle->marker_face(stdLayer.second.second);
770 // Set the hold to true.
771 m_mtRoverPathAxes->hold(true);
772 }
773 }
774
775 // Update legend names.
776 m_mtRoverPathAxes->legend(vLayerNames);
777 matplot::legend_handle mtLegend = m_mtRoverPathAxes->legend();
778 mtLegend->font_size(8);
779 mtLegend->num_columns(2);
780 // Set axis options.
781 m_mtRoverPathAxes->grid(true);
782 m_mtRoverPathAxes->xtickangle(45);
783 m_mtRoverPathAxes->axis(matplot::square);
784 m_mtRoverPathAxes->xtickformat("%.0f"); // No decimal places for x-axis
785 m_mtRoverPathAxes->ytickformat("%.0f"); // No decimal places for y-axis
786 // Set the hold to false.
787 m_mtRoverPathAxes->hold(false);
788 // Plot the path.
789 m_mtRoverPathPlot->draw();
790 m_mtRoverPathPlot->save(m_szCurrentPlotSavePath);
791 }
Here is the caller graph for this function:

◆ CheckPathUpdateTime()

bool logging::graphing::PathTracer::CheckPathUpdateTime ( const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond 
)
inlineprivate

Checks the unordered map of last update times for a given layer name and returns true if the time since the last update is greater than the maximum updates per second, then it updates the time in the map. If the layer name does not exist in the map then it returns false. If the given update time is 0, then it will just check if the layer name exists in the map.

Parameters
szLayerName- The name of the layer to check the update time for.
unMaxUpdatesPerSecond- The maximum number of updates per second.
Returns
true - The time since the last update is greater than the maximum updates per second.
false - The time since the last update is less than the maximum updates per second.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-09
810 {
811 // Check if the layer name exists in the map.
812 if (m_umLastPlotUpdateTimeMap.find(szLayerName) == m_umLastPlotUpdateTimeMap.end())
813 {
814 // Submit logger message.
815 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot add waypoints.");
816 return false;
817 }
818
819 // Check if the maximum number of waypoints per second has been exceeded.
820 if (unMaxUpdatesPerSecond != 0 &&
821 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - m_umLastPlotUpdateTimeMap[szLayerName]).count() <
822 1.0 / unMaxUpdatesPerSecond)
823 {
824 // Return if the maximum number of waypoints per second has been exceeded.
825 return false;
826 }
827
828 // Update the last plot time.
829 m_umLastPlotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
830
831 // Return true.
832 return true;
833 }
Here is the caller graph for this function:

◆ CheckDotUpdateTime()

bool logging::graphing::PathTracer::CheckDotUpdateTime ( const std::string &  szLayerName,
const uint  unMaxUpdatesPerSecond 
)
inlineprivate

Checks the unordered map of last update times for a given layer name and returns true if the time since the last update is greater than the maximum updates per second, then it updates the time in the map. If the layer name does not exist in the map then it returns false. If the given update time is 0, then it will just check if the layer name exists in the map.

Parameters
szLayerName- The name of the layer to check the update time for.
unMaxUpdatesPerSecond- The maximum number of updates per second.
Returns
true - The time since the last update is greater than the maximum updates per second.
false - The time since the last update is less than the maximum updates per second.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-01-27
852 {
853 // Check if the layer name exists in the map.
854 if (m_umLastDotUpdateTimeMap.find(szLayerName) == m_umLastDotUpdateTimeMap.end())
855 {
856 // Submit logger message.
857 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot add waypoints.");
858 return false;
859 }
860
861 // Check if the maximum number of waypoints per second has been exceeded.
862 if (unMaxUpdatesPerSecond != 0 &&
863 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - m_umLastDotUpdateTimeMap[szLayerName]).count() <
864 1.0 / unMaxUpdatesPerSecond)
865 {
866 // Return if the maximum number of waypoints per second has been exceeded.
867 return false;
868 }
869
870 // Update the last plot time.
871 m_umLastDotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
872
873 // Return true.
874 return true;
875 }
Here is the caller graph for this function:

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