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
30
39{
40 public:
42 // Declare and define structs
44
45
52 struct PointRow
53 {
54 public:
55 int nID; // Unique identifier for the point.
56 double dEasting; // Easting coordinate in meters.
57 double dNorthing; // Northing coordinate in meters.
58 double dAltitude; // Altitude coordinate in meters.
59 std::string szZone; // UTM zone of the point.
60 std::string szClassification; // Classification of the point (e.g., ground, vegetation).
61 double dNormalX; // X component of the normal vector.
62 double dNormalY; // Y component of the normal vector.
63 double dNormalZ; // Z component of the normal vector.
64 double dSlope; // Slope of the point.
65 double dRoughness; // Roughness of the point.
66 double dCurvature; // Curvature of the point.
67 double dTraversalScore; // Traversal score for the point.
68 };
69
70
78 {
79 public:
80 double dEasting; // Easting coordinate to filter points by.
81 double dNorthing; // Northing coordinate to filter points by.
82 double dRadius; // Radius in meters to filter points by.
83 std::optional<std::string> szClassification = std::nullopt; // Optional classification to filter points by.
84
85 // Generic min/max pair for each filterable double property.
86 template<typename T>
87 struct Range
88 {
89 public:
90 T tMin;
91 T tMax;
92 };
93
94 std::optional<Range<double>> dNormalX = std::nullopt; // Optional range for X component of the normal vector.
95 std::optional<Range<double>> dNormalY = std::nullopt;
96 std::optional<Range<double>> dNormalZ = std::nullopt;
97 std::optional<Range<double>> dSlope = std::nullopt;
98 std::optional<Range<double>> dRoughness = std::nullopt;
99 std::optional<Range<double>> dCurvature = std::nullopt;
100 std::optional<Range<double>> dTraversalScore = std::nullopt;
101 };
102
104 // Declare class methods.
106
107 LiDARHandler();
108 LiDARHandler(const LiDARHandler& pOther) = delete;
109 LiDARHandler& operator=(const LiDARHandler& pOther) = delete;
111 bool OpenDB(const std::string& szDBPath);
112 bool CloseDB();
113 std::vector<PointRow> GetLiDARData(const PointFilter& stPointFilter);
114 bool InsertLiDARData(const std::vector<geoops::Waypoint>& vPoints);
115
117 // Getters
119
120 bool IsDBOpen();
121
122 private:
124 // Private Methods
126
127 template<typename T>
128 void AddRangeFilter(std::vector<std::string>& vClauses,
129 std::vector<std::function<void(sqlite3_stmt*, int&)>>& vBinders,
130 const char* pColumn,
131 const std::optional<PointFilter::Range<T>>& stdOptRange);
132
134 // Private Members
136
137 sqlite3* m_pSQLDatabase;
138 sqlite3_stmt* m_pSQLStatement;
139 bool m_bIsDBOpen;
140 std::shared_mutex m_muQueryMutex; // Mutex for thread-safe access to the database.
141};
142
143#endif
The LiDARHandler class manages runtime queries against a LiDAR point cloud database for autonomy navi...
Definition LiDARHandler.h:39
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:335
bool IsDBOpen()
Checks if the database is currently open.
Definition LiDARHandler.cpp:314
~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:88
Struct for filtering LiDAR points during queries.
Definition LiDARHandler.h:78
Struct representing a single LiDAR point row from the database.
Definition LiDARHandler.h:53