Skip to content

feat(sitl): bring latest upstream SITL updates from am32-firmware#394#37

Open
AlexKlimaj wants to merge 6 commits into
ark-releasefrom
pr-sitl-update
Open

feat(sitl): bring latest upstream SITL updates from am32-firmware#394#37
AlexKlimaj wants to merge 6 commits into
ark-releasefrom
pr-sitl-update

Conversation

@AlexKlimaj

Copy link
Copy Markdown
Member

Summary

Update the SITL port already on ark-release (merged via #34) with the latest work from upstream am32-firmware/AM32#394 (tridge).

The earlier ARK port stopped at an earlier revision of that PR. This brings in motor-model calibration, physics fixes, tones/fourway, measurement tools, and related DroneCAN/SITL CAN updates while keeping ARK-specific pieces (pytest harness, macOS hardening, Makefile/VERSION_TAG toolchain).

Brought from upstream

  • Motor physics — persistent diode states, inertial comparator propagation, progress lease (host-timing immunity), energy ledger, saturating supply sink, improved blanking/filtering exercise
  • Calibrated models + bench data — SEQURE G431 + GT2215, VimDrones L431 + 1404, Nano + AIR 2216 II; expected.json gates; run_calibration_tests.py + SITL-calibration.yml
  • Toolsscripts/esc_{measure,chirp,square,plot,report,analyze}.py, CALIBRATION.md, sitl_tones.py, sitl_fourway.py, TIMING-DESIGN notes
  • GUI / CI tooling — audio stream, DNA server mode for passive bus, bootloader handoff path (--bootloader)
  • DroneCAN — FlexDebug v2 (duty/input/ADC/flags); fix 1 kHz keep-alive so it no longer resets last_raw_command_us (was masking the 250 ms command-loss timeout)
  • SITL CAN — filter own TX loopbacks; RTC backup file renamed to <eeprom>.bkup

Preserved ARK integration

  • Pytest suite under Mcu/SITL/tests/ + sitl_harness.py + requirements-ci.txt / SITL.yml entrypoint
  • macOS SIGPIPE ignore, SO_NOSIGPIPE, SO_REUSEPORT, INADDR_ANY bind for mcast
  • CURRENT_AUTO_OFFSET on AM32_SITL_CAN
  • ARK Makefile / GCC 15 pin / VERSION_TAG / HWCI (untouched)

Verification

  • make AM32_SITL_CAN builds
  • Smoke start binds PWM/DShot + state UDP ports
  • Pytest: 18/18 non-DroneCAN tests pass locally (DShot/PWM/boot/safety/models)
  • make ARK_4IN1_F051 still builds
  • DroneCAN pytest cases need pydronecan mcast driver (local 1.0.19 lacks it; CI installs a package with mcast)
  • Optional: full calibration suite (~25 min)

Upstream source

am32-firmware#394

Test plan

  • CI: SITL Tests workflow (sitl-tests + gui-test)
  • CI: SITL Calibration Tests (path-filtered; may take ~25 min)
  • Confirm non-SITL targets still green in existing CI

Port the latest SITL work from am32-firmware#394
onto ark-release. Highlights:

- Calibrated motor models and bench captures (SEQURE GT2215, VimDrones
  L431/1404, Nano 2216) with expected.json regression gates
- Physics improvements: persistent diodes, inertial comparator, progress
  lease, energy ledger, saturating supply sink, tone/audio support
- Four-way bootloader protocol helpers, calibration CI workflow and
  esc_*.py measurement/plot/report tools
- DroneCAN FlexDebug v2 fields and heartbeat keep-alive fix so the 1 kHz
  inject no longer resets the RawCommand timeout
- SITL CAN: drop own TX loopbacks; file-backed RTC backup as .bkup
- Keep ARK pytest harness/CI, macOS SIGPIPE/SO_REUSEPORT hardening, and
  CURRENT_AUTO_OFFSET on AM32_SITL_CAN
Upstream gui_ci_test imported fixed INPUT_PORT/STATE_PORT and Sitl from
run_ci_tests; ARK's runner re-exports harness Sitl (dynamic free ports)
and no longer defines those constants. Point the GUI test at sitl_harness
and wire the allocated ports into the GUI process.
pydronecan only parses a single bus number after "mcast:". A URI of
mcast:7:lo is treated as bus 0 (239.65.82.0), while SITL correctly
joins bus 7 (239.65.82.7). The tools and simulator never shared a bus,
so every calibration check saw no esc.Status (no-data / missing /
err=1e9) and the ESC soft-reset every 2s on signaltimeout.

Use mcast:7 for both sides. Require dronecan>=1.0.20 so the mcast
driver is present on CI.
CI runners often run wall-paced SITL at ~0.2x realtime. The ESC needs
~1 s of sim-time zero throttle to arm, but the tools only slept a fixed
wall arm-time, so throttle never latched and every steady/square check
saw rpm=0 (no-data / missing).

Poll FlexDebug.armed until the arming window completes, require
dronecan>=1.0.27 for FlexDebug DSDL, skip square (timing-sensitive)
when sim/wall ratio is low, and treat a never-started chirp as a skip
or fail instead of a false desync pass.
esc_measure clamps demand to --max-throttle (default 0.6). The nano
dataset checks 0.70/0.80/0.90, so those steps were silently held at
0.6 and the comparison reported no-data. Pass a cap derived from the
expected steady levels.
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