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 <duckdb.hpp>
22#include <functional>
23#include <memory>
24#include <optional>
25#include <shared_mutex>
26#include <string>
27#include <vector>
28
30
31
40{
41 public:
43 // Declare and define structs
45
46
53 struct PointRow
54 {
55 public:
56 int nID; // Unique identifier for the point.
57 double dEasting; // Easting coordinate in meters.
58 double dNorthing; // Northing coordinate in meters.
59 double dAltitude; // Altitude coordinate in meters.
60 std::string szZone; // UTM zone of the point.
61 std::string szClassification; // Classification of the point (e.g., ground, vegetation).
62 double dNormalX; // X component of the normal vector.
63 double dNormalY; // Y component of the normal vector.
64 double dNormalZ; // Z component of the normal vector.
65 double dSlope; // Slope of the point.
66 double dRoughness; // Roughness of the point.
67 double dCurvature; // Curvature of the point.
68 double dTraversalScore; // Traversal score for the point.
69 };
70
71
79 {
80 public:
81 double dEasting; // Easting coordinate to filter points by.
82 double dNorthing; // Northing coordinate to filter points by.
83 double dRadius; // Radius in meters to filter points by.
84 std::optional<std::string> szClassification = std::nullopt; // Optional classification to filter points by.
85
86 // Generic min/max pair for each filterable double property.
87 template<typename T>
88 struct Range
89 {
90 public:
91 T tMin;
92 T tMax;
93 };
94
95 std::optional<Range<double>> dNormalX = std::nullopt; // Optional range for X component of the normal vector.
96 std::optional<Range<double>> dNormalY = std::nullopt;
97 std::optional<Range<double>> dNormalZ = std::nullopt;
98 std::optional<Range<double>> dSlope = std::nullopt;
99 std::optional<Range<double>> dRoughness = std::nullopt;
100 std::optional<Range<double>> dCurvature = std::nullopt;
101 std::optional<Range<double>> dTraversalScore = std::nullopt;
102 };
103
105 // Declare class methods.
107
108 LiDARHandler();
109 LiDARHandler(const LiDARHandler& pOther) = delete;
110 LiDARHandler& operator=(const LiDARHandler& pOther) = delete;
112 bool OpenDB(const std::string& szDBPath);
113 bool CloseDB();
114 std::vector<PointRow> GetLiDARData(const PointFilter& stPointFilter);
115 bool DeclareLiDARObstacle(const geoops::UTMCoordinate& stPoint, double dRadius);
116
118 // Getters
120
121 bool IsDBOpen();
122
123 private:
125 // Private Methods
127
128 template<typename T>
129 void AddRangeFilter(std::vector<std::string>& vClauses,
131 const char* pColumn,
132 const std::optional<PointFilter::Range<T>>& stdOptRange);
133
135 // Private Members
137
138 std::unique_ptr<duckdb::DuckDB> m_pDB; // DuckDB database instance.
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:40
void AddRangeFilter(std::vector< std::string > &vClauses, duckdb::vector< duckdb::Value > &vBindValues, const char *pColumn, const std::optional< PointFilter::Range< T > > &stdOptRange)
Adds a range filter to the SQL query clauses and dynamically bound values.
Definition LiDARHandler.cpp:308
LiDARHandler()
Construct a new LiDARHandler::LiDARHandler object.
Definition LiDARHandler.cpp:27
std::vector< PointRow > GetLiDARData(const PointFilter &stPointFilter)
Retrieves LiDAR data points from DuckDB based on the specified filter.
Definition LiDARHandler.cpp:136
bool OpenDB(const std::string &szDBPath)
Initializes the LiDARHandler by opening the DuckDB database.
Definition LiDARHandler.cpp:61
bool DeclareLiDARObstacle(const geoops::UTMCoordinate &stPoint, double dRadius)
Modifies all LiDAR points in radius to reflect bad terrain.
Definition LiDARHandler.cpp:332
bool IsDBOpen()
Checks if the database is currently open.
Definition LiDARHandler.cpp:289
~LiDARHandler()
Destroy the LiDARHandler::LiDARHandler object.
Definition LiDARHandler.cpp:40
bool CloseDB()
Closes the currently open LiDAR DuckDB connection.
Definition LiDARHandler.cpp:112
Definition duckdb.hpp:960
Definition LiDARHandler.h:89
Struct for filtering LiDAR points during queries.
Definition LiDARHandler.h:79
Struct representing a single LiDAR point row from the database.
Definition LiDARHandler.h:54
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:211