Files
PX4-Autopilot/test
Jacob Dahl e192036345 fix(commander): ack calibration cancels once and stop promptly (#29514)
* feat(simulator_sih): add orient command to pose the vehicle for calibration

Accel and mag calibration need the vehicle held still on each side and
rotated, which SIH could not do, so neither could be tested in
simulation. `simulator_sih orient` sets the attitude kinematically,
keeping the IMU and the simulated mag consistent with it, and `orient
all` runs every side in turn so a calibration started from a GCS
completes on its own.

Assisted-by: Claude:claude-opus-5-5

* fix(commander): hand a calibration cancel to the running calibration

A cancel got TEMPORARILY_REJECTED from Commander and ACCEPTED from the
calibration, in either order. The calibration polled for it with a
fresh vehicle_command subscription that only saw the newest command,
filtered it by a per-side start time, and did not poll while waiting
for the vehicle to be still or while measuring a side. Baro and level
calibration never polled. A cancel could be lost or take until the
vehicle was held still.

Commander now hands the cancel to the running calibration, which acks
it once when it stops, or rejects it if it ends without stopping.
Every calibration loop checks for it, and accel calibration no longer
reports a failure after a cancel.

Fixes #29424

Assisted-by: Claude:claude-opus-5-5

* test(mavsdk_tests): run accel and mag calibration and cancels on SIH

Covers a full accel and mag calibration, and a cancel in each place it
used to be missed or delayed, checking it gets exactly one ack.

Assisted-by: Claude:claude-opus-5-5

* perf(simulator_sih): build the orient command for SITL only

Commander denies sensor calibration when SIH runs on flight controller
hardware, so orient was about 1.8 KB of unusable code on every NuttX
board that builds SIH.

Assisted-by: Claude:claude-opus-5-5

* fix(commander): open calibration cancels before the worker thread starts

Commander handles one command per loop and the worker thread runs at
low priority, so a cancel queued right behind the start could be
rejected before the worker opened it, and the calibration kept running.

Assisted-by: Claude:claude-opus-5-5

* fix(commander): stop reporting a cancelled gyro calibration as failed

A cancel broke out of the retry loop into the failure report, as accel
calibration did before.

Assisted-by: Claude:claude-opus-5-5

* test(mavsdk_tests): cover gyro cancel and remove two calibration races

A retried start is rejected once the calibration runs, and that late
ack could be counted against the cancel, so the start is sent once.
The baro cancel landed 1 s into a 3 s calibration, about 200 ms of
host time at speed factor 10; it is now sent right after the start.

Assisted-by: Claude:claude-opus-5-5

* style(mavsdk_tests): wrap the calibration start assert for flake8

The 104-character line failed the Python CI checks.

Assisted-by: Claude:claude-opus-5-5

* fix(commander): require param7 zero for a calibration cancel

An ESC calibration (param7 = 1) or baro temperature calibration
(param7 = 3) sent while a calibration ran matched the cancel test. It
stopped the running calibration and was acked ACCEPTED, though the
requested calibration never started. `commander calibrate esc` did the
same.

Assisted-by: Claude:claude-fable-5-2
2026-11-11 14:38:01 -07:00
..