Skip to content

Lighthouse memory bindings - #17

Open
ArisMorgens wants to merge 3 commits into
mainfrom
Aris/lighthouse_memory
Open

ArisMorgens wants to merge 3 commits into
mainfrom
Aris/lighthouse_memory

Conversation

@ArisMorgens

@ArisMorgens ArisMorgens commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

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 LighthouseConfig binding 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 raises InvalidArgumentError for invalid files, before anything is written to the Crazyflie. to_yaml() saves a configuration.

  • Adds new Memory methods (each opens the memory, runs, and closes it):

    • read_lighthouse_geometries(), write_lighthouse_geometries(dict)
    • read_lighthouse_calibrations(), that returns a dict[int, ...] of valid BS slots
    • write_lighthouse_calibrations(dict), that returns LighthouseWriteReport. BS slots the Crazyflie doesn't support are skipped and listed in rejected. report.written can be passed to persist_lighthouse_data() to persist only the slots that were written.
  • Adds the lighthouse-matched-angle-data binding.

  • Replaces lighthouse_persist.py with lighthouse_config.py, which allows you to read, write and persist lighthouse configurations.

@ArisMorgens
ArisMorgens requested review from gemenerik and a balanced review from Copilot October 6, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The locked dependency lacks required APIs, and unvalidated YAML can clear existing Lighthouse configuration.

Review effort: Balanced
Findings: 2 High severity

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.

Comment thread examples/lighthouse_config.py Outdated
Comment on lines +109 to +110
file_geos: dict[int, Any] = config.get("geos", {})
file_calibs: dict[int, Any] = config.get("calibs", {})

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +559 to +560
impl From<crazyflie_lib::subsystems::memory::LighthouseWriteReport> for LighthouseWriteReport {
fn from(report: crazyflie_lib::subsystems::memory::LighthouseWriteReport) -> Self {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gemenerik

Copy link
Copy Markdown
Member

Holding off on the review until bitcraze/crazyflie-lib-rs#71 is merged

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants