cnwzhjs / rplidar.rs Goto Github PK
View Code? Open in Web Editor NEWRust driver for Slamtec RPLIDAR series
License: GNU General Public License v3.0
Rust driver for Slamtec RPLIDAR series
License: GNU General Public License v3.0
FYI, to run A1 in RP4, below line should be added after port creation.
(I forked mine from https://github.com/RandomStudio/rplidar.rs/tree/update-min BTW)
...
let dtr_result = serial_port.write_data_terminal_ready(false);
...
Anyway, thank you for the library!
I was able to use your driver on OSX with the following modification of your sample:
let serial_port = serialport::open_with_settings(devicepath,
&SerialPortSettings { baud_rate: 115200, ..SerialPortSettings::default()}
).unwrap();
Would you like to have this in the examples or might it be a good idea to add a featureflag for an optional serialport dependency and provide a method to create a RplidarDevice from a string directly? I'll create a pull request with your preferred option if you like
The C++ driver works without any issues but this driver seems to fail when start_scan()
is called.
I tried the ultra_simple
example. it fails with timeout message on version 0.5.0
failed to start scan in standard mode: Error { kind: OperationTimeout, description: "operation timeout" }
This is the full output. The driver can get the device info and health successfully.
Connected to LIDAR:
Model: 24
Firmware Version: 1.20
Hardware Version: 0
Serial Number: 9FC0FBF2C8E4DCCFC6E49FF16112130D
LIDAR is healthy.
All supported scan modes:
0 Standard : Max Distance: 8000.00m, Ans Type: 81, Us per sample: 500.00us
Typical scan mode: 0
Accessory board isn't detected
Starting LIDAR in typical mode...
thread 'main' panicked at 'failed to start scan in standard mode: Error { kind: OperationTimeout, description: "operation timeout" }', src\libcore\result.rs:1165:5
stack backtrace:
0: backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.37\src\backtrace\mod.rs:66
1: std::sys_common::backtrace::_print_fmt
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:76
2: std::sys_common::backtrace::_print::{{impl}}::fmt
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:60
3: core::fmt::write
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libcore\fmt\mod.rs:1030
4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\io\mod.rs:1412
5: std::sys_common::backtrace::_print
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:64
6: std::sys_common::backtrace::print
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\sys_common\backtrace.rs:49
7: std::panicking::default_hook::{{closure}}
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:196
8: std::panicking::default_hook
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:210
9: std::panicking::rust_panic_with_hook
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:473
10: std::panicking::continue_panic_fmt
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:380
11: std::panicking::rust_begin_panic
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:307
12: core::panicking::panic_fmt
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libcore\panicking.rs:85
13: core::result::unwrap_failed
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libcore\result.rs:1165
14: core::result::Result<rplidar_drv::prelude::ScanMode, rpos_drv::prelude::Error>::expect<rplidar_drv::prelude::ScanMode,rpos_drv::prelude::Error>
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libcore\result.rs:960
15: rplidar::main
at .\src\main.rs:118
16: std::rt::lang_start::{{closure}}<()>
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libstd\rt.rs:64
17: std::rt::lang_start_internal::{{closure}}
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\rt.rs:49
18: std::panicking::try::do_call<closure-0,i32>
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:292
19: panic_unwind::__rust_maybe_catch_panic
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libpanic_unwind\lib.rs:80
20: std::panicking::try
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panicking.rs:271
21: std::panic::catch_unwind
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\panic.rs:394
22: std::rt::lang_start_internal
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\/src\libstd\rt.rs:48
23: std::rt::lang_start<()>
at /rustc/4560ea788cb760f0a34127156c78e2552949f734\src\libstd\rt.rs:64
24: main
25: invoke_main
at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
26: __scrt_common_main_seh
at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
27: BaseThreadInitThunk
28: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\rplidar.exe COM6` (exit code: 101)
Edit: I updated the error message. I tried version 0.5.0
and 0.6.0
. Also, I tried to increase the timeout but it didn't make a difference.
Hello. Are there any plans by slamtec to support the rust implementation in the future?
error[E0793]: reference to packed field is unaligned
--> /home/woelwd/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rplidar_drv-0.6.0/src/ultra_capsuled_parser.rs:138:36
|
138 | let cabin_count = unsafe { prev_capsule.ultra_cabins.len() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.