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
LiDARHandler.h
Go to the documentation of this file.
1
15#ifndef LIDARHANDLER_H
16#define LIDARHANDLER_H
17
18#include "../util/GeospatialOperations.hpp"
19
21#include <functional>
22#include <optional>
23#include <shared_mutex>
24#include <sqlite3.h>
25#include <string>
26#include <vector>
27
29
31{
32 public:
34 // Declare and define structs
36
37 struct PointRow
38 {
39 public:
40 int nID; // Unique identifier for the point.
41 double dEasting; // Easting coordinate in meters.
42 double dNorthing; // Northing coordinate in meters.
43 double dAltitude; // Altitude coordinate in meters.
44 std::string szZone; // UTM zone of the point.
45 std::string szClassification; // Classification of the point (e.g., ground, vegetation).
46 double dNormalX; // X component of the normal vector.
47 double dNormalY; // Y component of the normal vector.
48 double dNormalZ; // Z component of the normal vector.
49 double dSlope; // Slope of the point.
50 double dRoughness; // Roughness of the point.
51 double dCurvature; // Curvature of the point.
52 double dTraversalScore; // Traversal score for the point.
53 };
54
56 {
57 public:
58 double dEasting; // Easting coordinate to filter points by.
59 double dNorthing; // Northing coordinate to filter points by.
60 double dRadius; // Radius in meters to filter points by.
61 std::optional<std::string> szClassification = std::nullopt; // Optional classification to filter points by.
62
63 // Generic min/max pair for each filterable double property.
64 template<typename T>
65 struct Range
66 {
67 public:
68 T tMin;
69 T tMax;
70 };
71
72 std::optional<Range<double>> dNormalX = std::nullopt; // Optional range for X component of the normal vector.
73 std::optional<Range<double>> dNormalY = std::nullopt;
74 std::optional<Range<double>> dNormalZ = std::nullopt;
75 std::optional<Range<double>> dSlope = std::nullopt;
76 std::optional<Range<double>> dRoughness = std::nullopt;
77 std::optional<Range<double>> dCurvature = std::nullopt;
78 std::optional<Range<double>> dTraversalScore = std::nullopt;
79 };
80
82 // Declare class methods.
84
86 LiDARHandler(const LiDARHandler& pOther) = delete;
87 LiDARHandler& operator=(const LiDARHandler& pOther) = delete;
89 bool OpenDB(const std::string& szDBPath);
90 bool CloseDB();
91 std::vector<PointRow> GetLiDARData(const PointFilter& stPointFilter);
92 bool InsertLiDARData(const std::vector<geoops::Waypoint>& vPoints);
93
95 // Getters
97
98 bool IsDBOpen();
99
100 private:
102 // Private Methods
104
105 template<typename T>
106 void AddRangeFilter(std::vector<std::string>& vClauses,
107 std::vector<std::function<void(sqlite3_stmt*, int&)>>& vBinders,
108 const char* pColumn,
109 const std::optional<PointFilter::Range<T>>& stdOptRange);
110
112 // Private Members
114
115 sqlite3* m_pSQLDatabase;
116 sqlite3_stmt* m_pSQLStatement;
117 bool m_bIsDBOpen;
118 std::shared_mutex m_muQueryMutex; // Mutex for thread-safe access to the database.
119};
120
121#endif
Definition LiDARHandler.h:31
LiDARHandler()
Construct a new LiDARHandler::LiDARHandler object.
Definition LiDARHandler.cpp:21
std::vector< PointRow > GetLiDARData(const PointFilter &stPointFilter)
Retrieves LiDAR data points from the database based on the specified filter.
Definition LiDARHandler.cpp:155
bool OpenDB(const std::string &szDBPath)
Initializes the LiDARHandler by opening the SQLite database and preparing the query.
Definition LiDARHandler.cpp:60
void AddRangeFilter(std::vector< std::string > &vClauses, std::vector< std::function< void(sqlite3_stmt *, int &)> > &vBinders, const char *pColumn, const std::optional< PointFilter::Range< T > > &stdOptRange)
Adds a range filter to the SQL query clauses and binders.
Definition LiDARHandler.cpp:337
bool IsDBOpen()
Checks if the database is currently open.
Definition LiDARHandler.cpp:316
~LiDARHandler()
Destroy the LiDARHandler::LiDARHandler object.
Definition LiDARHandler.cpp:35
bool CloseDB()
Closes the currently open LiDAR database.
Definition LiDARHandler.cpp:104
Definition LiDARHandler.h:66
Definition LiDARHandler.h:56
Definition LiDARHandler.h:38