Crates.io | tether-lidar2d-consolidation-rs |
lib.rs | tether-lidar2d-consolidation-rs |
version | 0.3.1 |
source | src |
created_at | 2023-11-07 14:56:49.802373 |
updated_at | 2023-11-07 14:56:49.802373 |
description | Tether Lidar2D Consolidator Agent, Rust edition |
homepage | |
repository | https://github.com/RandomStudio/tether-lidar2d-consolidation-rs |
max_upload_size | |
id | 1028162 |
size | 102,076 |
This is more or a less a direct port of the original NodeJS Agent (here referred to as "the OG Agent" ✌️) into Rust 🦀.
All the essential features of the OG Agent have been implemented, but the structure of the application does not attempt to replicate the original.
The two main goals were
Paho Eclipse MQTT has some (non-Rust) dependencies of its own. On Mac, you might need to the following:
brew install openssh cmake
And on Linux:
sudo apt install libssl-dev build-essential cmake
If using cargo, you can simply use
cargo run
Or, for example running in release (recommended) and with some command-line arguments:
cargo run --release -- --loglevel debug
Alternatively, run the compiled binary (assuming you've already run cargo build --release
), typically located in ./target/release/tether-lidar2d-consolidation-rs
You can see a full list of available command-line arguments by appending --help
onto your executing command, e.g. cargo run -- --help
Options are deliberately made to be almost identical to those used in the OG Agent, with a few notable exceptions:
--perspectiveTransform.includeOutside
instead of setting a boolean ignoreOutside
. This reflects the default usage better and makes more sense when using a flag (which defaults to false
if not explicitly appended)--tether.host
, --tether.username
, --tether.password
if these differ from the defaultsautoBroadcastConfig
as there is no need for this behaviour; we save and (re)publish configuration essentially every time it changes, on startup and when requestedInitially we tried using mqtt-rs, as it seems relatively simple to use, but in the future mqttrs might be "better".
For now have settled on paho-mqtt since it seems well-supported and provides examples in realistic scenarios (especially async).
rmp_serde is useful for both JSON and MsgPack serialisation/deserialisation. We might not be taking full advantage of zero-copy operations everywhere, but this will take a little more time to figure out.
In the beginning we tried msgpack-simple which warns that it is "not as performant as static solutions" but was much easier to use as a starting point.
We tried the library kddbscan, but although this may well be more "accurate" it seems to run far too slowly. In any case, this is a very different algorithm from the DBSCAN used in the OG Agent.
We then settled for the more humble (but apparently much more performant) petal-clustering. This in turn requires something called ndarray which seems very similar (and likely based on) numpy for Python.
For now, we use the DBSCAN method as per the OG Agent, but in future it might be worth tested the other supported mode in this library, HDbscan which may be faster still (see the paper).
Another possibility might be the library linfa-clustering.
We are using a combination of the libraries serde and serde_json which makes it easy to handle JSON in various ways - including strongly typed corresponding to Rust types/structs, which is what we need here in the case of our Config loading/saving.
We are attempting to do a "quad to quad projection" from the ROI to a normalised "square" output quad, similar to perspective-transform as per the OG Agent.
So far
Finally, used a combination of ndarray
(which was already installed, to support the clustering calculations) and nalgebra
.
We are using log and env-logger. Log level has been set to INFO by default, but can be overridden, for example by prefixing with an environment variable, e.g.
RUST_LOG=debug cargo run
We are using clap which does command-line argument parsing only (no use of files, environment variables, etc.)
Something like more-config could be useful, since it includes functionality similar to the rc package for NodeJS.
agentIdOrGroup
part in lidar2d/{agentIdOrGroup}/scans
[angle, distance]
and sometimes [angle, distance, quality]
(although the latter is not handled yet). The samples are converted into points and the list(vector) of all converted points are "inserted" (i.e. replaced, if key already exists) into the hashmap which represents all LIDAR devices (with serial strings as keys).
.unwrap()
in this process; errors should be handled more carefully in some cases