Skip to content

Commit

Permalink
Update test.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Dec 8, 2023
1 parent 9a5effd commit 613973d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions libraries/RPLidar/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ int main()
{
spdlog::set_level(spdlog::level::debug);

auto lidar_result = RPLidar::create("/dev/ttyUSB0");
// auto lidar_result = RPLidar::create("/dev/ttyUSB0");
auto lidar_result = RPLidar::create("COM3");
if (!lidar_result.has_value())
{
return 0;
}
auto lidar = std::move(lidar_result.value());
auto& lidar = std::move(lidar_result.value());

auto info_result = lidar->get_info();
if (!info_result.has_value())
{
std::cout << info_result.error();
return 0;
}
auto info = info_result.value();
auto& info = info_result.value();
std::cout << fmt::format("model: {}, firmware: ({}, {}), hardware: {}, serialnumber: {}\n", info.model, info.firmware.first, info.firmware.second, info.hardware, info.serialNumber);

auto health_result = lidar->get_health();
Expand All @@ -30,23 +30,23 @@ int main()
std::cout << health_result.error();
return 0;
}
auto health = health_result.value();
auto& health = health_result.value();
std::cout << fmt::format("({}, {})\n", health.status, health.errorCode);

std::function<std::vector<Measure>()> scanGenerator = lidar->iter_scans();
for (int i = 0; i < 10; i++)
{
std::vector<Measure> scan = scanGenerator();
std::cout << "Got " << scan.size() << " Measures!\n";
for (const Measure &measure : scan)
{
// Access individual measurements in the scan
bool newScan = measure.newScan;
int quality = measure.quality;
float angle = measure.angle;
float distance = measure.distance;
}
}
// std::function<std::vector<Measure>()> scanGenerator = lidar->iter_scans();
// for (int i = 0; i < 10; i++)
// {
// std::vector<Measure> scan = scanGenerator();
// std::cout << "Got " << scan.size() << " Measures!\n";
// for (const Measure &measure : scan)
// {
// // Access individual measurements in the scan
// bool newScan = measure.newScan;
// int quality = measure.quality;
// float angle = measure.angle;
// float distance = measure.distance;
// }
// }

lidar->stop();
lidar->stop_motor();
Expand Down

0 comments on commit 613973d

Please sign in to comment.