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
PathTracer.hpp
Go to the documentation of this file.
1
12#ifndef PATH_TRACER_HPP
13#define PATH_TRACER_HPP
14
15#include "../GeospatialOperations.hpp"
16
18#include <chrono>
19#include <matplot/matplot.h>
20
22
23
31namespace logging
32{
33
42 namespace graphing
43 {
44
53 {
54 public:
55
64 PathTracer(const std::string& szPlotTitle = "Graph", bool bEnable3D = false)
65 {
66 // Initialize member variables.
67 m_mtRoverPathPlot = matplot::figure(true);
68 m_mtRoverPathAxes = m_mtRoverPathPlot->current_axes();
69 m_szPlotTitle = szPlotTitle;
70 m_bEnable3D = bEnable3D;
71
72 // 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.
73 std::string szPlotSavePath = logging::g_szLoggingOutputPath + "/path_plots/" + m_szPlotTitle;
74 m_szCurrentPlotSavePath = logging::g_szLoggingOutputPath + "/path_plots/CurrentPlot.png";
75 int nFileNum = 0;
76 while (std::filesystem::exists(szPlotSavePath + std::to_string(nFileNum) + ".png"))
77 {
78 ++nFileNum;
79 }
80 // Add the file number to the file name.
81 szPlotSavePath = szPlotSavePath + std::to_string(nFileNum);
82 // Check if the final directory exists. If not then create it.
83 if (!std::filesystem::exists(logging::g_szLoggingOutputPath + "/path_plots"))
84 {
85 std::filesystem::create_directory(logging::g_szLoggingOutputPath + "/path_plots");
86 }
87
88 // Configure the matplotplusplus gnuplot backend to not display the plot, instead save it to a file.
89 m_mtRoverPathPlot->backend()->output(szPlotSavePath + ".png");
90
91 // Make sure plot title is not empty.
92 if (m_szPlotTitle.empty())
93 {
94 // Submit logger message.
95 LOG_WARNING(logging::g_qSharedLogger, "Plot title is empty. Setting title to default.");
96 m_szPlotTitle = "RoverPath";
97 }
98
99 // Configure plot.
100 m_mtRoverPathPlot->title(m_szPlotTitle);
101 m_mtRoverPathAxes->xlabel("Easting");
102 m_mtRoverPathAxes->ylabel("Northing");
103 m_mtRoverPathAxes->zlabel("Altitude");
104 }
105
106
114 {
115 // Nothing to do yet.
116 }
117
118
170 bool CreatePathLayer(const std::string& szLayerName, const std::string& szStyleString = "-o")
171 {
172 // Check if the layer name exists in the map.
173 if (m_umPathMap.find(szLayerName) != m_umPathMap.end())
174 {
175 // Submit logger message.
176 LOG_WARNING(logging::g_qSharedLogger, "Layer already exists. Cannot create layer.");
177 return false;
178 }
179
180 // Add the layer to the maps.
181 m_umPathMap[szLayerName] = std::vector<std::tuple<double, double, double>>();
182 m_umPathLineStyleMap[szLayerName] = szStyleString;
183 m_umLastPlotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
184
185 return true;
186 }
187
188
209 bool CreateDotLayer(const std::string& szLayerName, const std::string& szColorString = "blue", const bool bFillMarkerFace = true)
210 {
211 // Check if the layer name exists in the map.
212 if (m_umDotMap.find(szLayerName) != m_umDotMap.end())
213 {
214 // Submit logger message.
215 LOG_WARNING(logging::g_qSharedLogger, "Layer already exists. Cannot create layer.");
216 return false;
217 }
218
219 // Add the layer to the maps.
220 m_umDotMap[szLayerName] = std::vector<std::tuple<double, double, double, double>>();
221 m_umDotLineStyleMap[szLayerName] = std::make_pair(szColorString, bFillMarkerFace);
222 m_umLastDotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
223
224 return true;
225 }
226
227
237 bool DeleteLayer(const std::string& szLayerName)
238 {
239 // Check if the layer name exist in the path or dot maps.
240 if (m_umPathMap.find(szLayerName) == m_umPathMap.end() && m_umDotMap.find(szLayerName) == m_umDotMap.end())
241 {
242 // Submit logger message.
243 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot delete layer.");
244 return false;
245 }
246
247 // Remove the appropriate layers from the maps.
248 if (m_umPathMap.find(szLayerName) != m_umPathMap.end())
249 {
250 m_umPathMap.erase(szLayerName);
251 m_umPathLineStyleMap.erase(szLayerName);
252 m_umLastPlotUpdateTimeMap.erase(szLayerName);
253 }
254 if (m_umDotMap.find(szLayerName) != m_umDotMap.end())
255 {
256 m_umDotMap.erase(szLayerName);
257 m_umDotLineStyleMap.erase(szLayerName);
258 m_umLastDotUpdateTimeMap.erase(szLayerName);
259 }
260
261 return true;
262 }
263
264
274 bool ClearLayer(const std::string& szLayerName)
275 {
276 // Check if the layer name exist in the path or dot maps.
277 if (m_umPathMap.find(szLayerName) == m_umPathMap.end() && m_umDotMap.find(szLayerName) == m_umDotMap.end())
278 {
279 // Submit logger message.
280 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot clear layer.");
281 return false;
282 }
283
284 // Clear the appropriate layer.
285 if (m_umPathMap.find(szLayerName) != m_umPathMap.end())
286 {
287 m_umPathMap[szLayerName].clear();
288 }
289 if (m_umDotMap.find(szLayerName) != m_umDotMap.end())
290 {
291 m_umDotMap[szLayerName].clear();
292 }
293
294 return true;
295 }
296
297
309 void AddPathPoint(const geoops::Waypoint& stWaypoint, const std::string& szLayerName, const uint nMaxWaypointsPerSecond = 1)
310 {
311 // Check the update time.
312 if (!this->CheckPathUpdateTime(szLayerName, nMaxWaypointsPerSecond))
313 {
314 // Return if the maximum number of waypoints per second has been exceeded.
315 return;
316 }
317
318 // Add the waypoint to the path.
319 m_umPathMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting,
320 stWaypoint.GetUTMCoordinate().dNorthing,
321 stWaypoint.GetUTMCoordinate().dAltitude);
322
323 // Update the plot.
324 this->UpdatePlot();
325 }
326
327
339 void AddPathPoint(const geoops::UTMCoordinate& stCoordinate, const std::string& szLayerName, const uint nMaxWaypointsPerSecond = 1)
340 {
341 // Check the update time.
342 if (!this->CheckPathUpdateTime(szLayerName, nMaxWaypointsPerSecond))
343 {
344 // Return if the maximum number of waypoints per second has been exceeded.
345 return;
346 }
347
348 // Add the waypoint to the path.
349 m_umPathMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing, stCoordinate.dAltitude);
350
351 // Update the plot.
352 this->UpdatePlot();
353 }
354
355
367 void AddPathPoint(const geoops::GPSCoordinate& stCoordinate, const std::string& szLayerName, const uint nMaxWaypointsPerSecond = 1)
368 {
369 // Check the update time.
370 if (!this->CheckPathUpdateTime(szLayerName, nMaxWaypointsPerSecond))
371 {
372 // Return if the maximum number of waypoints per second has been exceeded.
373 return;
374 }
375
376 // Create instance variables.
377 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
378
379 // Add the waypoint to the path.
380 m_umPathMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing, stUTMCoordinate.dAltitude);
381
382 // Update the plot.
383 this->UpdatePlot();
384 }
385
386
399 void AddPathPoints(const std::vector<geoops::Waypoint>& stWaypoints, const std::string& szLayerName, const uint unMaxUpdatesPerSecond = 1)
400 {
401 // Check the update time.
402 if (!this->CheckPathUpdateTime(szLayerName, unMaxUpdatesPerSecond))
403 {
404 // Return if the maximum number of waypoints per second has been exceeded.
405 return;
406 }
407
408 // Add the waypoints to the vector or double pairs at the given layer name in the map.
409 for (const geoops::Waypoint& stWaypoint : stWaypoints)
410 {
411 m_umPathMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting,
412 stWaypoint.GetUTMCoordinate().dNorthing,
413 stWaypoint.GetUTMCoordinate().dAltitude);
414 }
415
416 // Update the plot.
417 this->UpdatePlot();
418 }
419
420
433 void AddPathPoints(const std::vector<geoops::UTMCoordinate>& vCoordinates, const std::string& szLayerName, const uint unMaxUpdatesPerSecond = 1)
434 {
435 // Check the update time.
436 if (!this->CheckPathUpdateTime(szLayerName, unMaxUpdatesPerSecond))
437 {
438 // Return if the maximum number of waypoints per second has been exceeded.
439 return;
440 }
441
442 // Add the waypoints to the vector or double pairs at the given layer name in the map.
443 for (const geoops::UTMCoordinate& stCoordinate : vCoordinates)
444 {
445 m_umPathMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing, stCoordinate.dAltitude);
446 }
447
448 // Update the plot.
449 this->UpdatePlot();
450 }
451
452
465 void AddPathPoints(const std::vector<geoops::GPSCoordinate>& vCoordinates, const std::string& szLayerName, const uint unMaxUpdatesPerSecond = 1)
466 {
467 // Check the update time.
468 if (!this->CheckPathUpdateTime(szLayerName, unMaxUpdatesPerSecond))
469 {
470 // Return if the maximum number of waypoints per second has been exceeded.
471 return;
472 }
473
474 // Add the waypoints to the vector or double pairs at the given layer name in the map.
475 for (const geoops::GPSCoordinate& stCoordinate : vCoordinates)
476 {
477 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
478 m_umPathMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing, stUTMCoordinate.dAltitude);
479 }
480
481 // Update the plot.
482 this->UpdatePlot();
483 }
484
485
499 void AddDot(const geoops::Waypoint& stWaypoint, const std::string& szLayerName, const uint nMaxWaypointsPerSecond = 1)
500 {
501 // Check the update time.
502 if (!this->CheckDotUpdateTime(szLayerName, nMaxWaypointsPerSecond))
503 {
504 // Return if the maximum number of waypoints per second has been exceeded.
505 return;
506 }
507
508 // Check the radius of the waypoint. It shouldn't be less than 0.
509 if (stWaypoint.dRadius <= 0)
510 {
511 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting,
512 stWaypoint.GetUTMCoordinate().dNorthing,
513 stWaypoint.GetUTMCoordinate().dAltitude,
514 5.0);
515 }
516 else
517 {
518 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting,
519 stWaypoint.GetUTMCoordinate().dNorthing,
520 stWaypoint.GetUTMCoordinate().dAltitude,
521 stWaypoint.dRadius);
522 }
523
524 // Update the plot.
525 this->UpdatePlot();
526 }
527
528
541 void AddDot(const geoops::UTMCoordinate& stCoordinate, const std::string& szLayerName, const uint nMaxWaypointsPerSecond = 1, const double dDotRadius = 5)
542 {
543 // Check the update time.
544 if (!this->CheckDotUpdateTime(szLayerName, nMaxWaypointsPerSecond))
545 {
546 // Return if the maximum number of waypoints per second has been exceeded.
547 return;
548 }
549
550 // Add the waypoint to the path.
551 m_umDotMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing, stCoordinate.dAltitude, dDotRadius);
552
553 // Update the plot.
554 this->UpdatePlot();
555 }
556
557
570 void AddDot(const geoops::GPSCoordinate& stCoordinate, const std::string& szLayerName, const uint nMaxWaypointsPerSecond = 1, const double dDotRadius = 5)
571 {
572 // Check the update time.
573 if (!this->CheckDotUpdateTime(szLayerName, nMaxWaypointsPerSecond))
574 {
575 // Return if the maximum number of waypoints per second has been exceeded.
576 return;
577 }
578
579 // Create instance variables.
580 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
581
582 // Add the waypoint to the path.
583 m_umDotMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing, stUTMCoordinate.dAltitude, dDotRadius);
584
585 // Update the plot.
586 this->UpdatePlot();
587 }
588
589
604 void AddDots(const std::vector<geoops::Waypoint>& stWaypoints, const std::string& szLayerName, const uint unMaxUpdatesPerSecond = 1)
605 {
606 // Check the update time.
607 if (!this->CheckDotUpdateTime(szLayerName, unMaxUpdatesPerSecond))
608 {
609 // Return if the maximum number of waypoints per second has been exceeded.
610 return;
611 }
612
613 // Add the waypoints to the vector or double pairs at the given layer name in the map.
614 for (const geoops::Waypoint& stWaypoint : stWaypoints)
615 {
616 // Check the radius of the waypoint. It shouldn't be less than 0.
617 if (stWaypoint.dRadius <= 0)
618 {
619 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting,
620 stWaypoint.GetUTMCoordinate().dNorthing,
621 stWaypoint.GetUTMCoordinate().dAltitude,
622 5);
623 }
624 else
625 {
626 m_umDotMap[szLayerName].emplace_back(stWaypoint.GetUTMCoordinate().dEasting,
627 stWaypoint.GetUTMCoordinate().dNorthing,
628 stWaypoint.GetUTMCoordinate().dAltitude,
629 stWaypoint.dRadius);
630 }
631 }
632
633 // Update the plot.
634 this->UpdatePlot();
635 }
636
637
651 void AddDots(const std::vector<geoops::UTMCoordinate>& vCoordinates,
652 const std::string& szLayerName,
653 const uint unMaxUpdatesPerSecond = 1,
654 const double dDotRadius = 5)
655 {
656 // Check the update time.
657 if (!this->CheckDotUpdateTime(szLayerName, unMaxUpdatesPerSecond))
658 {
659 // Return if the maximum number of waypoints per second has been exceeded.
660 return;
661 }
662
663 // Add the waypoints to the vector or double pairs at the given layer name in the map.
664 for (const geoops::UTMCoordinate& stCoordinate : vCoordinates)
665 {
666 m_umDotMap[szLayerName].emplace_back(stCoordinate.dEasting, stCoordinate.dNorthing, stCoordinate.dAltitude, dDotRadius);
667 }
668
669 // Update the plot.
670 this->UpdatePlot();
671 }
672
673
687 void AddDots(const std::vector<geoops::GPSCoordinate>& vCoordinates,
688 const std::string& szLayerName,
689 const uint unMaxUpdatesPerSecond = 1,
690 const double dDotRadius = 5)
691 {
692 // Check the update time.
693 if (!this->CheckDotUpdateTime(szLayerName, unMaxUpdatesPerSecond))
694 {
695 // Return if the maximum number of waypoints per second has been exceeded.
696 return;
697 }
698
699 // Add the waypoints to the vector or double pairs at the given layer name in the map.
700 for (const geoops::GPSCoordinate& stCoordinate : vCoordinates)
701 {
702 geoops::UTMCoordinate stUTMCoordinate = geoops::ConvertGPSToUTM(stCoordinate);
703 m_umDotMap[szLayerName].emplace_back(stUTMCoordinate.dEasting, stUTMCoordinate.dNorthing, stUTMCoordinate.dAltitude, dDotRadius);
704 }
705
706 // Update the plot.
707 this->UpdatePlot();
708 }
709
710 private:
711 // Declare private member variables.
712 matplot::figure_handle m_mtRoverPathPlot;
713 matplot::axes_handle m_mtRoverPathAxes;
714 std::unordered_map<std::string, std::string> m_umPathLineStyleMap;
715 std::unordered_map<std::string, std::pair<std::string, bool>> m_umDotLineStyleMap;
716 std::unordered_map<std::string, std::chrono::system_clock::time_point> m_umLastPlotUpdateTimeMap;
717 std::unordered_map<std::string, std::chrono::system_clock::time_point> m_umLastDotUpdateTimeMap;
718 std::unordered_map<std::string, std::vector<std::tuple<double, double, double>>> m_umPathMap;
719 std::unordered_map<std::string, std::vector<std::tuple<double, double, double, double>>> m_umDotMap;
720 std::string m_szPlotTitle;
721 std::string m_szCurrentPlotSavePath;
722 bool m_bEnable3D;
723
724
732 {
733 // Create instance variables.
734 std::vector<std::string> vLayerNames;
735
736 // Clear the plot.
737 m_mtRoverPathAxes->clear();
738
739 /*
740 PATHS
741 */
742 // Loop through each of the layer name keys in the map.
743 for (const std::pair<const std::string, const std::string>& stdLayer : m_umPathLineStyleMap)
744 {
745 // Check if the vector or coordinates has more than one point.
746 if (m_umPathMap[stdLayer.first].size() > 1)
747 {
748 // Add the layer name to the vector.
749 vLayerNames.push_back(stdLayer.first);
750
751 // Check if we are in 3D mode.
752 if (m_bEnable3D)
753 {
754 // Get the x, y, and z coordinates for the layer.
755 std::vector<double> vEasting, vNorthing, vAltitude;
756 for (const std::tuple<double, double, double>& stCoordinate : m_umPathMap[stdLayer.first])
757 {
758 vEasting.push_back(std::get<0>(stCoordinate));
759 vNorthing.push_back(std::get<1>(stCoordinate));
760 vAltitude.push_back(std::get<2>(stCoordinate));
761 }
762
763 // Plot the path in 3D.
764 m_mtRoverPathAxes->plot3(vEasting, vNorthing, vAltitude, std::string_view(stdLayer.second));
765 }
766 else
767 {
768 // Get the x and y coordinates for the layer.
769 std::vector<double> vEasting, vNorthing;
770 for (const std::tuple<double, double, double>& stCoordinate : m_umPathMap[stdLayer.first])
771 {
772 vEasting.push_back(std::get<0>(stCoordinate));
773 vNorthing.push_back(std::get<1>(stCoordinate));
774 }
775
776 // Plot the path.
777 m_mtRoverPathAxes->plot(vEasting, vNorthing, std::string_view(stdLayer.second));
778 }
779
780 // Set the hold to true.
781 m_mtRoverPathAxes->hold(true);
782 }
783 }
784
785 /*
786 DOTS
787 */
788 // Loop through each of the layer name keys in the map.
789 for (const std::pair<const std::string, const std::pair<std::string, bool>>& stdLayer : m_umDotLineStyleMap)
790 {
791 // Check if the vector or coordinates has at least one point.
792 if (m_umDotMap[stdLayer.first].size() > 0)
793 {
794 // Add the layer name to the vector.
795 vLayerNames.push_back(stdLayer.first);
796
797 // Check if we are in 3D mode.
798 if (m_bEnable3D)
799 {
800 // Get the x and y coordinates for the layer.
801 std::vector<double> vEasting, vNorthing, vAltitude, vRadius;
802 for (const std::tuple<double, double, double, double>& stCoordinate : m_umDotMap[stdLayer.first])
803 {
804 vEasting.push_back(std::get<0>(stCoordinate));
805 vNorthing.push_back(std::get<1>(stCoordinate));
806 vAltitude.push_back(std::get<2>(stCoordinate));
807 vRadius.push_back(std::get<3>(stCoordinate));
808 }
809
810 // Plot the path.
811 matplot::line_handle mtLineHandle = m_mtRoverPathAxes->scatter3(vEasting, vNorthing, vAltitude, vRadius);
812 // Set the line style and marker face for the layer.
813 mtLineHandle->color(stdLayer.second.first);
814 mtLineHandle->marker_face(stdLayer.second.second);
815 }
816 else
817 {
818 // Get the x and y coordinates for the layer.
819 std::vector<double> vEasting, vNorthing, vRadius;
820 for (const std::tuple<double, double, double, double>& stCoordinate : m_umDotMap[stdLayer.first])
821 {
822 vEasting.push_back(std::get<0>(stCoordinate));
823 vNorthing.push_back(std::get<1>(stCoordinate));
824 vRadius.push_back(std::get<3>(stCoordinate));
825 }
826
827 // Plot the path.
828 matplot::line_handle mtLineHandle = m_mtRoverPathAxes->scatter(vEasting, vNorthing, vRadius);
829 // Set the line style and marker face for the layer.
830 mtLineHandle->color(stdLayer.second.first);
831 mtLineHandle->marker_face(stdLayer.second.second);
832 }
833
834 // Set the hold to true.
835 m_mtRoverPathAxes->hold(true);
836 }
837 }
838
839 // Update legend names.
840 m_mtRoverPathAxes->legend(vLayerNames);
841 matplot::legend_handle mtLegend = m_mtRoverPathAxes->legend();
842 mtLegend->font_size(8);
843 mtLegend->num_columns(2);
844 // Set axis options.
845 m_mtRoverPathAxes->grid(true);
846 m_mtRoverPathAxes->xtickangle(45);
847 m_mtRoverPathAxes->axis(matplot::square);
848 m_mtRoverPathAxes->xtickformat("%.0f"); // No decimal places for x-axis
849 m_mtRoverPathAxes->ytickformat("%.0f"); // No decimal places for y-axis
850 m_mtRoverPathAxes->ztickformat("%.0f"); // No decimal places for z-axis
851 // Set the hold to false.
852 m_mtRoverPathAxes->hold(false);
853 // Plot the path.
854 m_mtRoverPathPlot->draw();
855 m_mtRoverPathPlot->save(m_szCurrentPlotSavePath);
856 }
857
858
874 bool CheckPathUpdateTime(const std::string& szLayerName, const uint unMaxUpdatesPerSecond)
875 {
876 // Check if the layer name exists in the map.
877 if (m_umLastPlotUpdateTimeMap.find(szLayerName) == m_umLastPlotUpdateTimeMap.end())
878 {
879 // Submit logger message.
880 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot add waypoints.");
881 return false;
882 }
883
884 // Check if the maximum number of waypoints per second has been exceeded.
885 if (unMaxUpdatesPerSecond != 0 &&
886 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - m_umLastPlotUpdateTimeMap[szLayerName]).count() <
887 1.0 / unMaxUpdatesPerSecond)
888 {
889 // Return if the maximum number of waypoints per second has been exceeded.
890 return false;
891 }
892
893 // Update the last plot time.
894 m_umLastPlotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
895
896 // Return true.
897 return true;
898 }
899
900
916 bool CheckDotUpdateTime(const std::string& szLayerName, const uint unMaxUpdatesPerSecond)
917 {
918 // Check if the layer name exists in the map.
919 if (m_umLastDotUpdateTimeMap.find(szLayerName) == m_umLastDotUpdateTimeMap.end())
920 {
921 // Submit logger message.
922 LOG_WARNING(logging::g_qSharedLogger, "Layer does not exist. Cannot add waypoints.");
923 return false;
924 }
925
926 // Check if the maximum number of waypoints per second has been exceeded.
927 if (unMaxUpdatesPerSecond != 0 &&
928 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - m_umLastDotUpdateTimeMap[szLayerName]).count() <
929 1.0 / unMaxUpdatesPerSecond)
930 {
931 // Return if the maximum number of waypoints per second has been exceeded.
932 return false;
933 }
934
935 // Update the last plot time.
936 m_umLastDotUpdateTimeMap[szLayerName] = std::chrono::system_clock::now();
937
938 // Return true.
939 return true;
940 }
941 };
942 } // namespace graphing
943} // namespace logging
944
945#endif
The PathTracer class is used to trace the path of the rover and plot the path on a graph.
Definition PathTracer.hpp:53
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 PathTracer.hpp:874
PathTracer(const std::string &szPlotTitle="Graph", bool bEnable3D=false)
Construct a new Path Tracer object.
Definition PathTracer.hpp:64
~PathTracer()
Destroy the Path Tracer object.
Definition PathTracer.hpp:113
bool CreatePathLayer(const std::string &szLayerName, const std::string &szStyleString="-o")
Add a new draw layer to the plot.
Definition PathTracer.hpp:170
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 tha...
Definition PathTracer.hpp:399
bool ClearLayer(const std::string &szLayerName)
Clear the path or dots of a layer.
Definition PathTracer.hpp:274
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 a...
Definition PathTracer.hpp:541
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 a...
Definition PathTracer.hpp:499
void UpdatePlot()
Update the plot with the new waypoints and redraw the plot.
Definition PathTracer.hpp:731
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...
Definition PathTracer.hpp:339
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 ...
Definition PathTracer.hpp:651
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 tha...
Definition PathTracer.hpp:465
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 ...
Definition PathTracer.hpp:604
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 PathTracer.hpp:916
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...
Definition PathTracer.hpp:367
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 a...
Definition PathTracer.hpp:570
bool DeleteLayer(const std::string &szLayerName)
Delete a draw layer from the plot.
Definition PathTracer.hpp:237
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 ...
Definition PathTracer.hpp:687
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 tha...
Definition PathTracer.hpp:433
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...
Definition PathTracer.hpp:309
bool CreateDotLayer(const std::string &szLayerName, const std::string &szColorString="blue", const bool bFillMarkerFace=true)
Add a new draw layer to the plot.
Definition PathTracer.hpp:209
uint32_t uint
UTMCoordinate ConvertGPSToUTM(const GPSCoordinate &stGPSCoord)
Given a GPS coordinate, convert to UTM and create a new UTMCoordinate object.
Definition GeospatialOperations.hpp:332
Namespace containing all global type/structs that will be used project wide for logging.
Definition AutonomyLogging.cpp:33
This struct stores/contains information about a GPS data.
Definition GeospatialOperations.hpp:99
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:210
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:422
const geoops::UTMCoordinate & GetUTMCoordinate() const
Accessor for the geoops::UTMCoordinate member variable.
Definition GeospatialOperations.hpp:507