Skip to content

Commit

Permalink
Move files and make library directory for RPLidar
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Dec 7, 2023
1 parent 04ec5e4 commit 1606818
Show file tree
Hide file tree
Showing 71 changed files with 56 additions and 10 deletions.
14 changes: 6 additions & 8 deletions Car-Application.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
"path": "."
},
{
"path": "backend"
"path": "app/backend"
},
{
"path": "frontend"
"path": "app/frontend"
},
{
"path": "raspberry_pi"
"path": "app/raspberry_pi"
},
{
"path": "tcp"
},
{
"path": "legacy"
"path": "old/legacy"
}
],
"settings": {
Expand Down Expand Up @@ -111,7 +108,8 @@
"source_location": "cpp",
"shared_mutex": "cpp",
"cinttypes": "cpp",
"filesystem": "cpp"
"filesystem": "cpp",
"variant": "cpp"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ namespace rplidar {
tl::expected<std::tuple<uint8_t, bool, uint8_t>, std::string> RPLidar::_read_descriptor()
{
// Read descriptor packet
std::vector<uint8_t> descriptor(DESCRIPTOR_LEN);
this->_serial->read(descriptor.data(), DESCRIPTOR_LEN);
std::string descriptor(DESCRIPTOR_LEN, '\0');
this->_serial->read(reinterpret_cast<uint8_t*>(&descriptor[0]), DESCRIPTOR_LEN);
spdlog::debug("Received descriptor: {}", spdlog::to_hex(descriptor));

if (descriptor.size() != DESCRIPTOR_LEN)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions libraries/RPLidar/test/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <RPLidar.h>

int main()
{
auto lidar = RPLidar("COM3");

auto info = lidar.get_info();
std::cout << fmt::format("model: {}, firmware: ({}, {}), hardware: {}, serialnumber: {}\n", info.model, info.firmware.first, info.firmware.second, info.hardware, info.serialNumber);

auto health = lidar.get_health();
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;
}
}

lidar.stop();
lidar.stop_motor();
lidar.disconnect();
return 0;
}
16 changes: 16 additions & 0 deletions libraries/RPLidar/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_requires("serial", "spdlog")

target("RPLidar")
set_kind("static")
add_files("src/*.cpp")
add_headerfiles("include/(**.h)")
add_headerfiles("include/(**.hpp)")
add_includedirs("include")
add_packages("serial", "spdlog")

target("test")
set_kind("binary")
add_files("test/*.cpp")
add_includedirs("include")
add_deps("RPLidar")
add_links("RPLidar")
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1606818

Please sign in to comment.