cu-rp-balancebot 0.14.0

This is a full robot example for the Copper project. It runs on the Raspberry Pi with the balance bot hat to balance a rod.
cu-rp-balancebot-0.14.0 is not a library.

BalanceBot: this is a full Copper demo robot

with:

  • a physical robot implementation
  • a simulation implementation
  • a resimulation demoing the deterministic replay
  • a log export

To run the simulation

$ cd examples/cu_rp_balancebot
$ cargo run

See the UI help for the navigation.

To run the simulation with the monitor embedded in Bevy

$ cd examples/cu_rp_balancebot
$ just bevy

This keeps the Bevy sim on the left and the live Copper monitor on the right.

To run the simulation in the browser

$ cd examples/cu_rp_balancebot
$ just web

This serves the Bevy sim and the live Copper monitor through Trunk. The first run downloads the scene assets into assets/ so the browser can load them from the same origin. The browser path now uses the same asset filenames as the native sim: balancebot.glb, skybox.ktx2, and diffuse_map.ktx2.

To build a static browser bundle

$ cd examples/cu_rp_balancebot
$ just web-dist

This writes a relocatable static Trunk bundle into dist/balancebot/ with hashed asset filenames.

To run the resimulation

(you need at least a log in logs for example from a simulation run).

$ cd examples/cu_rp_balancebot
$ cargo run --bin balancebot-resim --release

It will recreate the logs from only the inputs of the previous run in logs/balancebot_resim*.copper.

To run on the real robot

You will need to cross compile for Arm:

cargo build --target armv7-unknown-linux-musleabihf --release --no-default-features

Be sure you save your log string index:

cp -rv ../../target/armv7-unknown-linux-musleabihf/release/cu29_log_index .  # or anywhere you want

Deploy on the target:

scp ../../target/armv7-unknown-linux-musleabihf/release/balancebot copperconfig.ron copper7:copper/  # change to match your target

To export logs

$ cd examples/cu_rp_balancebot
$ cargo run --bin balancebot-logreader --release

Justfile commands

  • just bevy — run the split-view Bevy sim with cu_bevymon.
  • just web — serve the split-view wasm demo with Trunk.
  • just web-dist — build a deployable static wasm bundle into dist/balancebot/.
  • just balancebot-dump-text-logs — extract human-readable logs from logs/balance.copper into ../../target/debug/cu29_log_index/strings.bin.
  • just balancebot-fsck — integrity check of logs/balance.copper.
  • just balancebot-set-pwm-permissions — fix PWM sysfs permissions on the target (requires appropriate privileges).
  • just dag-logstats — generate logstats and open an annotated DAG SVG for the current copperconfig.ron.