Repository navigation
Lighthouse memory bindings - #17
ArisMorgens wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The locked dependency lacks required APIs, and unvalidated YAML can clear existing Lighthouse configuration.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds Python bindings for Lighthouse configuration and matched-angle measurements, integrating APIs from the linked Rust PR #71.
Changes:
- Adds geometry, calibration, and write-report classes with memory read/write methods.
- Exposes matched-angle streaming and updates Python type stubs.
- Replaces the persistence-only example with YAML configuration reading, writing, and persistence.
| File | Description |
|---|---|
| rust/src/subsystems/mod.rs | Exports new Lighthouse types. |
| rust/src/subsystems/memory.rs | Implements configuration classes and memory operations. |
| rust/src/subsystems/localization.rs | Adds matched-angle bindings. |
| rust/src/lib.rs | Registers new Python classes. |
| pyproject.toml | Adds PyYAML development dependency. |
| examples/lighthouse_persist.py | Removes persistence-only example. |
| examples/lighthouse_config.py | Adds YAML configuration workflow. |
| cflib2/memory.py | Exports configuration classes. |
| cflib2/localization.py | Exports matched-angle data. |
| cflib2/_rust.pyi | Documents and types new APIs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| file_geos: dict[int, Any] = config.get("geos", {}) | ||
| file_calibs: dict[int, Any] = config.get("calibs", {}) |
There was a problem hiding this comment.
I introduced a LighthouseConfig module in the rust lib that checks the lighthouse YAML file format. This way, we only maintain one implementation of the file format and its checks, shared by all the tools, like cfcli, cflib2 and cfclient.
| impl From<crazyflie_lib::subsystems::memory::LighthouseWriteReport> for LighthouseWriteReport { | ||
| fn from(report: crazyflie_lib::subsystems::memory::LighthouseWriteReport) -> Self { |
There was a problem hiding this comment.
Before this PR is merged, crazyflie-lib-rs must get a new release that includes this PR, and the crazyflie-lib version needs to be bumped to that release.
…pens in the rust lib
|
Holding off on the review until bitcraze/crazyflie-lib-rs#71 is merged |

Connected to this crazyflie-lib-rs PR: bitcraze/crazyflie-lib-rs#71
This PR:
Adds new classes in cflib2.memory, matching the ones in cflib (
LighthouseBsGeometry,LighthouseCalibrationSweep,LighthouseBsCalibration,LighthouseWriteReport)Adds
LighthouseConfigbinding for loading and saving lighthouse configuration files.LighthouseConfig.from_yaml()checks the file type, version, system type and base station IDs (in crazyflie-lib-rs) and raisesInvalidArgumentErrorfor invalid files, before anything is written to the Crazyflie.to_yaml()saves a configuration.Adds new
Memorymethods (each opens the memory, runs, and closes it):read_lighthouse_geometries(),write_lighthouse_geometries(dict)read_lighthouse_calibrations(), that returns adict[int, ...]of valid BS slotswrite_lighthouse_calibrations(dict), that returnsLighthouseWriteReport. BS slots the Crazyflie doesn't support are skipped and listed inrejected.report.writtencan be passed topersist_lighthouse_data()to persist only the slots that were written.Adds the lighthouse-matched-angle-data binding.
Replaces
lighthouse_persist.pywithlighthouse_config.py, which allows you to read, write and persist lighthouse configurations.