Skip to content

Closed-loop HIL test system: simulator gateway, test runner, and scenario test folders#18

Open
toprakcelikel wants to merge 7 commits into
elcano:mainfrom
toprakcelikel:add-closed-loop-tests
Open

Closed-loop HIL test system: simulator gateway, test runner, and scenario test folders#18
toprakcelikel wants to merge 7 commits into
elcano:mainfrom
toprakcelikel:add-closed-loop-tests

Conversation

@toprakcelikel

Copy link
Copy Markdown
Contributor

Summary

Adds a hardware-in-the-loop (HIL) test harness for the DBW: CAN command
sequences are replayed against a simulated trike and checked with timed
assertions, so control-loop behavior can be regression-tested off-vehicle.

What's included

  • Simulator / router gateway (Non_grapic_simulator) - models the trike
    (steering slew, throttle ramp, braking, heading/position) and bridges CAN
    commands <-> DBW. Emits sim_speed_cmPs in the LOG line so throttle/brake
    tests can assert on simulated speed.
  • Test runner (tools/) - replays a CSV of timed CAN commands, resets to
    a known baseline before each test, evaluates timed assertions against the
    LOG stream, and reports pass/fail. Includes a batch runner.
  • Scenario test folders (tests/) - each pairs a test CSV with the run
    logs captured from the HIL runs:
    • steep-turn reversal
    • edge-case brake (gas + brake together)
    • negative-speed safe stop
    • whipsaw / large-angle command tracking
    • max-speed overflow clamp
    • sub-deadband hold
    • comms-loss behavior
    • brake release / re-accelerate
    • too-many-commands (command flood)
    • speed-burst and steering-response runs
  • Wire-test / motor bring-up sketches (WireTest_*, MotorTurn, MoveMotor).

Test CSV format

time_ms, CANID, nbytes, speed_cmPs, brake, mode, angle_tenths, with
# assert t=<ms>: <condition> lines; the runner checks LOG fields such as
actual_angle_tenths and sim_speed_cmPs.

Notes

  • Each scenario folder includes the captured run logs (.txt) documenting the
    observed pass/fail behavior.
  • Findings from these runs fed the companion DBW firmware PR
    (brake-over-throttle, wider steering deadband, USB-loop-freeze fix).

Steering (01-10), throttle (11-18), brake (19-25), and combined
driving (26-30) test scripts with embedded # assert lines for
tools/test_runner.py.
The closed-loop simulated speed (speed_mmPs, published on 0x4F0) was
computed but never logged, so throttle/brake tests asserting on
sim_speed_cmPs errored with NameError. Emit it as cm/s to match
cmd_speed_cmPs units.
…port

- test_runner.py: drive to a known baseline (centered + stopped + DBW alive) before each CSV's clock starts, so tests are independent regardless of order.

- 28_serpentine.csv: move the full-reversal assertions to the physically-required slew time (a 400-tenth reversal needs ~2000ms).

- New corner-case tests 31-38: steep-turn min-time, edge-case break (found the brake bug), negative speed, whipsaw tracking, turn-under-braking, overflow speed, throttle+brake conflict, sub-deadband hold.

- run_all_tests.py batch runner; DBW_corner_case_test_report.md summary.
… corner cases

Adds 16 corner-case CSVs (39-54):
- comms-loss watchdog + watchdog recovery
- malformed-frame and wrong-CAN-ID rejection
- boot safe state, soak/stability, command-flood stress
- throttle step response, brake release/re-accelerate
- speed-burst reversal/rapid-toggle, steering step response
- mode-gating checks (49-51) documenting that the 0x350 mode byte
  is informational (DBW arbitrates its own auto-mode)
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.

1 participant