2026 sim: drive the Unity simulation with the real remote over the radio

Dongle (app):
- bridge mode: stands in for the robot's radio (ch 96 / 250k / HXPD1,
  auto-ack, dynamic payloads, ack payloads). Received packets go to the PC
  as A5-framed 'R' frames; the PC's 'A' frames become the ack payload of
  the next packet, like robot/Comms.cpp; dropped after ~0.5 s without a
  refresh. 'S' status once a second.
- USART RX through circular DMA into a ring buffer, overrun stall
  disabled, error flags cleared: a burst (e.g. SignalRGB probing the port)
  used to deafen the app until a replug.
- RX test mode ('x') accepts protocol v4's dynamic-length packets.
- safeboot_flash.py --knock: keeps knocking across a replug to catch
  safeboot's cold-boot window when the app doesn't answer.

Unity:
- SimRemote sources: Keyboard, or the real remote via the dongle
  (DongleLink.cs: kernel32 serial, auto-finds the CH340, all port I/O on
  one background thread). Packets go into the firmware byte for byte, the
  robot's telemetry goes back on the ack, so the remote's display shows
  the sim. Tested end to end with the real remote.
- Dropped the USB joystick and robot-serial-harness inputs and the old
  Serial/Serial2/Serial3/HandleHoystick scripts (and their components in
  Main.unity): no USB links to remote or robot any more.
- Test panel: dongle status; no sideways scroll bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-17 22:48:41 +01:00
1 parent 6b3b2629cd
commit 2b4750f8f4
24 files changed
+682 -710

No files matched your search

+16 -10
View File
@@ -188,8 +188,10 @@ Remote stick-frame convention: logical X + = right, Y + = forward, twist +
`Knie.x = −(tibia + 90)`.
- **Unity (`Assets/HexapodSim/`):**
- `HexapodSimBootstrap` auto-adds `HexapodSimulation` in any scene and
disables the old scripts (`Walk`, `RotationControl`, `Leg`,
`HandleHoystick`). Those are kept for reference only.
disables the old scripts (`Walk`, `RotationControl`, `Leg`). Those are
kept for reference only. The old USB serial / joystick scripts
(`Serial*`, `HandleHoystick`) were removed (owner, 2026-11-17: no USB
links to remote or robot any more, everything goes over the radio).
- `OpenScadModel` replaces the old scene's robot with the OpenSCAD model
(meshes from `hardware/openscad/export_unity.py` in
`Resources/OpenScadModel/`): it builds a new rig with the same names at
@@ -198,9 +200,16 @@ Remote stick-frame convention: logical X + = right, Y + = forward, twist +
- `HexapodSimNative` loads a temp copy of the DLL via
LoadLibrary/GetProcAddress, so there's no file lock and each Play is a
fresh power-on.
- `SimRemote` stands in for the remote (Joystick axes "1"–"6" as in the
old project, Keyboard, or the robot's own serial harness) and mirrors
`remote/PacketBuilder.cpp` + `RemoteState.cpp` rules. Keep them in sync.
- `SimRemote` has two sources. **Keyboard** stands in for the remote and
mirrors `remote/PacketBuilder.cpp` + `RemoteState.cpp` rules (keep them
in sync). **Real remote** takes the real remote's packets over the air
from the USB nRF24 dongle (`DongleLink.cs`, the dongle's bridge mode,
see `dongle/README.md`), feeds them to the firmware unchanged
(`HexapodSimNative.RadioSend(byte[])`) and returns the robot's
telemetry as the ack payload, so the remote's display shows the sim.
`DongleLink` opens the port through kernel32 (no `System.IO.Ports`),
auto-finds the CH340 (VID 1A86 PID 7523), and does all port I/O on one
background thread.
- `SimTestPanel` is the IMGUI panel (F1).
- Body motion is kinematic and lives **in the DLL** (`sim/SimBody.cpp`,
`hxsim_get_body`), so Unity shows exactly what `sim_smoke` checks.
@@ -225,8 +234,8 @@ Remote stick-frame convention: logical X + = right, Y + = forward, twist +
stand → walk. The harness does not exercise the right stick or remote
tilt. Add keys if needed.
- **Robot firmware in simulation:** `sim/build/sim_smoke.exe` (headless,
scripted checks), or Unity Play mode with Keyboard / Joystick / Robot
serial input.
scripted checks), or Unity Play mode with Keyboard input or the real
remote over the radio (USB nRF24 dongle).
- **Remote without robot or display:** the USB serial console (see
`remote/README.md`). `p` shows raw/mapped sticks, IMU, link and state.
`d` dumps packets at 10 Hz. With no robot, the link shows DOWN and
@@ -441,9 +450,6 @@ Remote (`remote/README.md` has detail):
- USB serial at 250000. It received 18 servo bytes + checksum + `0xFE`
from the old Unity `Serial.cs` (servo passthrough, forwarded over RF
to the robot) and printed `i_value,...` stick lines.
- The Unity remote stand-in's joystick axis assignment (which of axes 4/6
is forward) couldn't be recovered from the old code. Check it with the
panel's raw-axis readout.
- Radio retry timing (`RADIO_RETRY_*`) is untested under real link loss.
## Working rules for this repo