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.cc File Reference

Unit tests for the LiDARHandler runtime query class. More...

Include dependency graph for LiDARHandler.cc:

Classes

class  LiDARHandlerTests
 Test fixture for LiDARHandler class. More...

Functions

 TEST_F (LiDARHandlerTests, CanInitializeWithValidDB)
 Confirm that handler opens the database correctly.
 TEST_F (LiDARHandlerTests, FailsToInitializeInvalidDB)
 Confirm that initialization fails with nonexistent DB.
 TEST_F (LiDARHandlerTests, CanCloseDB)
 Confirm that handler can close the database.
 TEST_F (LiDARHandlerTests, CloseDBWithoutOpenIsSafe)
 Confirm that closing without opening is safe.
 TEST_F (LiDARHandlerTests, DoubleOpenClosesPrevious)
 Confirm that double open closes previous and opens new DB.
 TEST_F (LiDARHandlerTests, DoubleCloseIsSafe)
 Confirm that double close is safe.
 TEST_F (LiDARHandlerTests, QueryWithoutOpenReturnsEmpty)
 Query returns empty if DB not open.
 TEST_F (LiDARHandlerTests, QueryReturnsResultsIfPresent)
 Query returns results if present.
 TEST_F (LiDARHandlerTests, QueryWithClassification)
 Query with classification filter.
 TEST_F (LiDARHandlerTests, QueryWithTraversalScoreRange)
 Query with traversal score range filter.
 TEST_F (LiDARHandlerTests, QueryWithAllRangeFilters)
 Query with all range filters.
 TEST_F (LiDARHandlerTests, ThreadSafetyOpenCloseQuery)
 Check thread safety of open/close/query operations.

Detailed Description

Unit tests for the LiDARHandler runtime query class.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-05-20

Function Documentation

◆ TEST_F() [1/12]

TEST_F ( LiDARHandlerTests ,
CanInitializeWithValidDB  )

Confirm that handler opens the database correctly.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-05-20
50{
51 LiDARHandler handler;
52 EXPECT_TRUE(handler.OpenDB(m_szDbPath));
53}
The LiDARHandler class manages runtime queries against a LiDAR point cloud database for autonomy navi...
Definition LiDARHandler.h:40
bool OpenDB(const std::string &szDBPath)
Initializes the LiDARHandler by opening the DuckDB database.
Definition LiDARHandler.cpp:61
Here is the call graph for this function:

◆ TEST_F() [2/12]

TEST_F ( LiDARHandlerTests ,
FailsToInitializeInvalidDB  )

Confirm that initialization fails with nonexistent DB.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-05-20
62{
63 LiDARHandler handler;
64 EXPECT_FALSE(handler.OpenDB("invalid/path/to.db"));
65}
Here is the call graph for this function:

◆ TEST_F() [3/12]

TEST_F ( LiDARHandlerTests ,
CanCloseDB  )

Confirm that handler can close the database.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
75{
76 LiDARHandler handler;
77 EXPECT_TRUE(handler.OpenDB(m_szDbPath));
78 EXPECT_TRUE(handler.CloseDB());
79 EXPECT_FALSE(handler.IsDBOpen());
80}
bool IsDBOpen()
Checks if the database is currently open.
Definition LiDARHandler.cpp:289
bool CloseDB()
Closes the currently open LiDAR DuckDB connection.
Definition LiDARHandler.cpp:112
Here is the call graph for this function:

◆ TEST_F() [4/12]

TEST_F ( LiDARHandlerTests ,
CloseDBWithoutOpenIsSafe  )

Confirm that closing without opening is safe.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
90{
91 LiDARHandler handler;
92 EXPECT_TRUE(handler.CloseDB());
93 EXPECT_FALSE(handler.IsDBOpen());
94}
Here is the call graph for this function:

◆ TEST_F() [5/12]

TEST_F ( LiDARHandlerTests ,
DoubleOpenClosesPrevious  )

Confirm that double open closes previous and opens new DB.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
104{
105 LiDARHandler handler;
106 EXPECT_TRUE(handler.OpenDB(m_szDbPath));
107 // Open again with same path, should close and reopen
108 EXPECT_TRUE(handler.OpenDB(m_szDbPath));
109 EXPECT_TRUE(handler.IsDBOpen());
110}
Here is the call graph for this function:

◆ TEST_F() [6/12]

TEST_F ( LiDARHandlerTests ,
DoubleCloseIsSafe  )

Confirm that double close is safe.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
120{
121 LiDARHandler handler;
122 EXPECT_TRUE(handler.OpenDB(m_szDbPath));
123 EXPECT_TRUE(handler.CloseDB());
124 EXPECT_TRUE(handler.CloseDB());
125}
Here is the call graph for this function:

◆ TEST_F() [7/12]

TEST_F ( LiDARHandlerTests ,
QueryWithoutOpenReturnsEmpty  )

Query returns empty if DB not open.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
135{
136 LiDARHandler handler;
137 LiDARHandler::PointFilter filter{.dEasting = 0, .dNorthing = 0, .dRadius = 1.0};
138 std::vector<LiDARHandler::PointRow> vResults = handler.GetLiDARData(filter);
139 EXPECT_TRUE(vResults.empty());
140}
std::vector< PointRow > GetLiDARData(const PointFilter &stPointFilter)
Retrieves LiDAR data points from DuckDB based on the specified filter.
Definition LiDARHandler.cpp:136
void filter(InputArray image, InputArray kernel, OutputArray output)
Struct for filtering LiDAR points during queries.
Definition LiDARHandler.h:79
Here is the call graph for this function:

◆ TEST_F() [8/12]

TEST_F ( LiDARHandlerTests ,
QueryReturnsResultsIfPresent  )

Query returns results if present.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
150{
151 LiDARHandler handler;
152 ASSERT_TRUE(handler.OpenDB(m_szDbPath));
153 LiDARHandler::PointFilter filter{.dEasting = 614058.84, .dNorthing = 4189968.85, .dRadius = 3.0};
154 std::vector<LiDARHandler::PointRow> vResults = handler.GetLiDARData(filter);
155 // Can't guarantee DB contents, but should not crash
156 SUCCEED();
157}
Here is the call graph for this function:

◆ TEST_F() [9/12]

TEST_F ( LiDARHandlerTests ,
QueryWithClassification  )

Query with classification filter.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
167{
168 LiDARHandler handler;
169 ASSERT_TRUE(handler.OpenDB(m_szDbPath));
170 LiDARHandler::PointFilter filter{.dEasting = 614058.84, .dNorthing = 4189968.85, .dRadius = 3.0, .szClassification = std::optional<std::string>("ground")};
171 std::vector<LiDARHandler::PointRow> vResults = handler.GetLiDARData(filter);
172 // Should not crash, may be empty
173 SUCCEED();
174}
Here is the call graph for this function:

◆ TEST_F() [10/12]

TEST_F ( LiDARHandlerTests ,
QueryWithTraversalScoreRange  )

Query with traversal score range filter.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
184{
185 LiDARHandler handler;
186 ASSERT_TRUE(handler.OpenDB(m_szDbPath));
187 LiDARHandler::PointFilter filter{.dEasting = 614058.84,
188 .dNorthing = 4189968.85,
189 .dRadius = 3.0,
190 .dTraversalScore = std::optional<LiDARHandler::PointFilter::Range<double>>({0.95, 1.0})};
191 std::vector<LiDARHandler::PointRow> vResults = handler.GetLiDARData(filter);
192 // Should not crash, may be empty
193 SUCCEED();
194}
Here is the call graph for this function:

◆ TEST_F() [11/12]

TEST_F ( LiDARHandlerTests ,
QueryWithAllRangeFilters  )

Query with all range filters.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
204{
205 LiDARHandler handler;
206 ASSERT_TRUE(handler.OpenDB(m_szDbPath));
208 .dEasting = 614058.84,
209 .dNorthing = 4189968.85,
210 .dRadius = 3.0,
211 .dNormalX = std::optional<LiDARHandler::PointFilter::Range<double>>({-1.0, 1.0}),
212 .dNormalY = std::optional<LiDARHandler::PointFilter::Range<double>>({-1.0, 1.0}),
213 .dNormalZ = std::optional<LiDARHandler::PointFilter::Range<double>>({-1.0, 1.0}),
214 .dSlope = std::optional<LiDARHandler::PointFilter::Range<double>>({0.0, 90.0}),
215 .dRoughness = std::optional<LiDARHandler::PointFilter::Range<double>>({0.0, 10.0}),
216 .dCurvature = std::optional<LiDARHandler::PointFilter::Range<double>>({-10.0, 10.0}),
217 .dTraversalScore = std::optional<LiDARHandler::PointFilter::Range<double>>({0.0, 1.0}),
218 };
219 std::vector<LiDARHandler::PointRow> vResults = handler.GetLiDARData(stFilter);
220 SUCCEED();
221}
Definition LiDARHandler.h:89
Here is the call graph for this function:

◆ TEST_F() [12/12]

TEST_F ( LiDARHandlerTests ,
ThreadSafetyOpenCloseQuery  )

Check thread safety of open/close/query operations.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-07-14
231{
232 LiDARHandler handler;
233 std::function<void()> fnOpenClose = [&handler, this]()
234 {
235 for (int i = 0; i < 5; ++i)
236 {
237 handler.OpenDB(m_szDbPath);
238 handler.CloseDB();
239 }
240 };
241 std::function<void()> fnQuery = [&handler, this]()
242 {
243 for (int i = 0; i < 5; ++i)
244 {
245 handler.OpenDB(m_szDbPath);
246 LiDARHandler::PointFilter filter{.dEasting = 614058.84, .dNorthing = 4189968.85, .dRadius = 3.0};
247 handler.GetLiDARData(filter);
248 handler.CloseDB();
249 }
250 };
251 std::thread thThread1(fnOpenClose);
252 std::thread thThread2(fnQuery);
253 thThread1.join();
254 thThread2.join();
255 SUCCEED();
256}
Here is the call graph for this function: