Flight Controller: sim / bevy bindings#863
Conversation
This is missing to run end to end in sim the new stacks built on bridges.
There was a problem hiding this comment.
Pull request overview
Adds a host-side (std) simulation entrypoint for the flight controller, including Bevy integration and “sim-safe” task/bridge bindings so the example can run without embedded hardware resources.
Changes:
- Introduces a Bevy-based
quad-simbinary andsim_supportimplementations for sensors, battery ADC, LED state, and placeholder bridges. - Updates flight-controller tasks/config to compile and run in
simmode (including sim/firmware backend selection andrun_in_simconfig usage). - Extends the runtime/config/derive pipeline with
BridgeConfig.run_in_simand aCuSimBridge<Tx,Rx>placeholder to avoid compiling/instantiating real bridges in simulation.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/cu_flight_controller/src/tasks/mod.rs | Selects firmware vs sim sensor source types via cfgs. |
| examples/cu_flight_controller/src/tasks/battery.rs | Adds firmware/sim battery ADC backend abstraction and sim voltage support. |
| examples/cu_flight_controller/src/tasks/activity_led.rs | Adds firmware/sim LED backend abstraction and sim LED state hook. |
| examples/cu_flight_controller/src/sim_support.rs | Adds sim implementations for sensors, battery ADC, LED, and bridge shims. |
| examples/cu_flight_controller/src/sim.rs | New Bevy app wiring Copper sim runtime into an update loop + smoke test. |
| examples/cu_flight_controller/src/logreader.rs | Aligns crate aliasing for reflect/type-path expectations. |
| examples/cu_flight_controller/justfile | Adds just sim helper target. |
| examples/cu_flight_controller/copperconfig.ron | Enables tasks in sim and disables real bridges via run_in_sim: false. |
| examples/cu_flight_controller/Cargo.toml | Enables quad-sim bin, sim deps/features, and sets default-run. |
| core/cu29_runtime/tests/sim_bridge_config.ron | Adds run_in_sim: false coverage in runtime tests. |
| core/cu29_runtime/tests/sim_bridge.rs | Ensures real bridge is not instantiated when run_in_sim: false. |
| core/cu29_runtime/src/simulation.rs | Adds CuSimBridge placeholder + empty channel set types. |
| core/cu29_runtime/src/config.rs | Adds BridgeConfig.run_in_sim with default-true semantics. |
| core/cu29_derive/src/lib.rs | Generates placeholder bridge types/channel sets when run_in_sim: false; adds ignore_resources. |
| components/payloads/cu_sensor_payloads/src/imu.rs | Adds Reflect to magnetometer-related payloads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| struct BatteryAdcCalibration { | ||
| vref_mv: u32, | ||
| vbat_scale: u32, | ||
| vbat_res_div_val: u32, | ||
| vbat_res_div_mult: u32, | ||
| } | ||
|
|
There was a problem hiding this comment.
BatteryAdcSource derives Reflect and contains calib: BatteryAdcCalibration, but BatteryAdcCalibration itself does not implement/derive Reflect. This will break builds that enable the cu29/reflect feature (where Reflect is backed by bevy_reflect and requires field types to be reflectable). Consider deriving Reflect for BatteryAdcCalibration (or marking calib with #[reflect(ignore)] if it should not be part of reflection).
Summary
enables sim for the flight controller.
(empty world right now, just all the tasks compile in std mode + loop etc...)
Related issues
Changes
Testing
just fmtjust lintjust testjust std-ci(if std/runtime paths are impacted)just nostd-ci(if embedded/no_std paths are impacted)pro-tip:
justwith no parameters in the root defaults tojust fmt,just lint, andjust test.Checklist
Breaking changes (if any)
Additional context