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
GetNearbyLiDAR.hpp
Go to the documentation of this file.
1
13#include "../../src/AutonomyConstants.h"
14#include "../../src/AutonomyLogging.h"
15#include "../../src/handlers/LiDARHandler.h"
16#include "../../src/util/ExampleChecker.h"
17
19#include <iostream>
20
22
23
30{
31 // Create and initialize handler
32 LiDARHandler handler;
33 if (!handler.OpenDB(constants::LIDAR_HANDLER_DB_PATH))
34 {
35 std::cerr << "Failed to initialize LiDARHandler.\n";
36 return;
37 }
38
39 // Define test location and radius
40 double dTestEasting = 614058.84;
41 double dTestNorthing = 4189968.85;
42 double dRadiusMeters = 3.0;
43 double dMinTravScore = 0.95;
44
45 LOG_INFO(logging::g_qSharedLogger, "Querying for points within {} meters of ({}, {}, {}):", dRadiusMeters, dTestEasting, dTestNorthing, dMinTravScore);
46
47 // Execute query
48 std::vector<LiDARHandler::PointRow> vPoints =
49 handler.GetLiDARData({.dEasting = dTestEasting,
50 .dNorthing = dTestNorthing,
51 .dRadius = dRadiusMeters,
52 .dTraversalScore = std::optional<LiDARHandler::PointFilter::Range<double>>({dMinTravScore, 1.0})});
53
54 // Print results
55 if (vPoints.empty())
56 {
57 LOG_INFO(logging::g_qSharedLogger, "No points found in that radius.");
58 }
59 else
60 {
61 // Loop through and print each point
62 for (const LiDARHandler::PointRow& stPoint : vPoints)
63 {
64 // Assemble a string to print point data.
65 std::string szPointInfo = "Point ID: " + std::to_string(stPoint.nID) + "\n";
66 szPointInfo += "Easting: " + std::to_string(stPoint.dEasting) + "\n";
67 szPointInfo += "Northing: " + std::to_string(stPoint.dNorthing) + "\n";
68 szPointInfo += "Altitude: " + std::to_string(stPoint.dAltitude) + "\n";
69 szPointInfo += "Zone: " + stPoint.szZone + "\n";
70 szPointInfo += "Classification: " + stPoint.szClassification + "\n";
71 szPointInfo +=
72 "Normal Vector: (" + std::to_string(stPoint.dNormalX) + ", " + std::to_string(stPoint.dNormalY) + ", " + std::to_string(stPoint.dNormalZ) + ")\n";
73 szPointInfo += "Slope: " + std::to_string(stPoint.dSlope) + "\n";
74 szPointInfo += "Roughness: " + std::to_string(stPoint.dRoughness) + "\n";
75 szPointInfo += "Curvature: " + std::to_string(stPoint.dCurvature) + "\n";
76 szPointInfo += "Traversal Score: " + std::to_string(stPoint.dTraversalScore) + "\n";
77 szPointInfo += "-----------------------------------\n";
78
79 // Submit logger message.
80 LOG_NOTICE(logging::g_qSharedLogger, "{}", szPointInfo);
81 }
82
83 LOG_INFO(logging::g_qSharedLogger, "Query complete. {} result(s) returned.", vPoints.size());
84 }
85}
void RunExample()
Example function to demonstrate the usage of LiDARHandler.
Definition GetNearbyLiDAR.hpp:29
The LiDARHandler class manages runtime queries against a LiDAR point cloud database for autonomy navi...
Definition LiDARHandler.h:39
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
Struct representing a single LiDAR point row from the database.
Definition LiDARHandler.h:53