AP_Compass: report specific failure reason when fit rejected#32757
AP_Compass: report specific failure reason when fit rejected#32757christianpetri wants to merge 1 commit into
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
I think 950 is too low, that is within the range of offsets that we might see in normal operation. I think we might be better off to try and improve the reporting at the end of a calibration attempt rather than guessing at the beginning. |
f4e053b to
a428227
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
Hi @christianpetri, Thanks for this. One small thing is we don't accept merge commits so could you rebase on master to remove it? |
a6d793b to
b0f7dc6
Compare
peterbarker
left a comment
There was a problem hiding this comment.
Create an autotest
- want other compasses to keep calibrating if one of them gets a long field
- we have lots of autotests already doing calibration, steal code from there
- does this make calibration faster with a badly-affected compass?
Generally in favour of this at DevCallEU
What's the flash cost?
b0f7dc6 to
4b438b1
Compare
This comment was marked as outdated.
This comment was marked as outdated.
4b438b1 to
13e6f2d
Compare
13e6f2d to
93c2395
Compare
93c2395 to
560b8e1
Compare
|
Not keen on the short circuit stuff, but I like the improved reporting at the end of the calibration. To get the most out of this we might need some GCS changes, in mission planner you can't see messages on the compass calibration page, you would have to go and look manualy. |
560b8e1 to
09774b4
Compare
|
Dropped the early-abort in pull_sample() as requested. Kept and improved the fit_acceptable() diagnostics: each failure condition (fitness NaN, radius out of range, offsets too large, diagonal/offdiagonal out of range, fitness over tolerance) now emits its own GCS message with the actual values, so all failures are visible in a single calibration attempt rather than just the first hit. Removed const from fit_acceptable() since GCS_SEND_TEXT is a side effect. This is consistent with the pre-existing messages already in calculate_orientation() and fix_radius(). |
SITL Test PlanManual SITL verification for the
Related PRs
Setup sim_vehicle.py -v ArduCopter -f calibration --console --mapConnect Mission Planner via TCP Reset between tests Tests
Pass criteria
|
09774b4 to
4fbb08d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
4fbb08d to
774fc4c
Compare
774fc4c to
88799cf
Compare
IamPete1
left a comment
There was a problem hiding this comment.
I like this! And Thanks for doing the Mission Planner fix too!
|
After discussion at DevCall:
We think the way forward is to fix the ground control stations to more prominiently display the calibration error code and then to augment the enumeration to include more error codes. Not to say that this isn't actually a nice UI improvement, it's just we can't jsutify spending the resources on it |
2b28b3a to
cbfe725
Compare
|
Switched to the enum-only approach you described — no |
cbfe725 to
ce0a347
Compare
|
Upstream mavlink/mavlink PR opened for the 3 new enum entries: mavlink/mavlink#2478 Once that merges and pymavlink is bumped, the |
7ace6e0 to
f7e0a2e
Compare
|
Rebased and updated based on review feedback. Latest push includes one follow-up cleanup commit:
Validation on this branch:
Requesting re-review. If anything is still blocking, I can address it quickly. |
|
Follow-up question for maintainers on intent: For the latest cleanup commit, I clarified comments around two behavior points:
Could you please confirm this is the intended handling? If preferred, I can adjust to a different policy/wording before merge (for example: keep behavior but simplify wording, or adjust reboot policy expectations). |
|
Size re-check on latest branch head using ArduPilot size comparison script:
So current delta is +48 bytes for CubeOrange plane versus merge-base/origin master. |
553381f to
15aa6c5
Compare
Add three new failure reason enum values (8/9/10) to MAG_CAL_STATUS, and add descriptions to existing entries 6 and 7 for consistency. Implemented in ArduPilot firmware: ArduPilot/ardupilot#32757
Add three new failure reason enum values (8/9/10) to MAG_CAL_STATUS, and add descriptions to existing entries 6 and 7 for consistency. Implemented in ArduPilot firmware: ArduPilot/ardupilot#32757
15aa6c5 to
ff38025
Compare
Add three new failure reason enum values (8/9/10) to MAG_CAL_STATUS, and add descriptions to existing entries 6 and 7 for consistency. Implemented in ArduPilot firmware: ArduPilot/ardupilot#32757
…AL_STATUS Add three new failure reason enum values (8/9/10) to MAG_CAL_STATUS, and add descriptions to existing entries 6 and 7 for consistency.\n\nImplemented in ArduPilot firmware: ArduPilot/ardupilot#32757
…AL_STATUS Add three new failure reason enum values (8/9/10) to MAG_CAL_STATUS, and add descriptions to existing entries 6 and 7 for consistency. Implemented in ArduPilot firmware: ArduPilot/ardupilot#32757
4ce9557 to
399743b
Compare
…AL_STATUS Add three new failure reason enum values (8/9/10) to MAG_CAL_STATUS, and add descriptions to existing entries 6 and 7 for consistency. Implemented in ArduPilot firmware: ArduPilot/ardupilot#32757
9d73abb to
ddea6dc
Compare
ddea6dc to
15ec2b8
Compare
|
Aligned the AP_Compass MAG_CAL failure status naming with mavlink/mavlink#2478 (FAILED_* names), including compatibility fallbacks in autotest until pymavlink catches up. |
|
Hi @peterbarker, quick status update on your requested changes:
Could you please re-review and let me know if anything is still blocking from your side? |
|
Hi @christianpetri, I've also added this to the weekly dev call so it will be reviewed then if not before, txs! |


Summary
Extend the
CompassCalibrator::Statusenum with three new terminal failure values (BAD_OFFSETS=8,BAD_DIAG_SCALING=9,BAD_FITNESS=10) and refactorfit_acceptable()to set the appropriate specific status instead of falling back to the genericFAILED.Classification & Testing (check all that apply and add your own)
Description
Previously
fit_acceptable()returned a silentfalse— the GCS and user had no way to know why calibration was rejected. This PR maps each rejection condition to a specificStatusvalue that is transmitted in theMAG_CAL_REPORT.cal_statusfield.New
Statusenum values (extendMAG_CAL_STATUSMAVLink enum):BAD_OFFSETSCOMPASS_OFFS_MAXBAD_DIAG_SCALINGBAD_FITNESS_fitness > sq(_tolerance)BAD_RADIUS(7) was already present. All four conditions were previously collapsed intoFAILED(5).Behaviour changes:
fit_acceptable()losesconst(it now callsset_status()).set_status(FAILED)is guarded against overwriting any of the five specificBAD_*statuses (previously onlyBAD_ORIENTATIONandBAD_RADIUSwere protected).update_cal_status(),failed(),is_calibrating(), andsend_cal_report()all handle the three new cases identically toBAD_RADIUS.GCS_SEND_TEXTcalls added; flash cost +48 bytes on CubeOrange plane (measured viaTools/scripts/size_compare_branches.py).Note: The new integer values (8/9/10) are transmitted immediately. GCS will display the raw number until a matching
MAG_CAL_STATUSentry is added in the upstream mavlink/mavlink XML and a pymavlink bump lands in ArduPilot. The autotest usesgetattr(mavutil.mavlink, 'MAG_CAL_BAD_FITNESS', 10)fallbacks pending that bump.Related
MAG_CAL_BAD_OFFSETS/BAD_DIAG_SCALING/BAD_FITNESSto common.xmlTesting
Builds clean on SITL and CubeOrange (
./waf configure --board CubeOrange && ./waf plane). Flash delta vs master: +48 bytes (measured on CubeOrange plane via official ArduPilot size_compare_branches.py tool).SITL autotest
SITLCompassCalibrationpasses:Two new subtests added:
COMPASS_CAL_FIT=0.001) — all compasses reportMAG_CAL_BAD_FITNESS (10)instead ofMAG_CAL_FAILED (5).SIM_MAG1_OFS_X/Y/Z=2000) — compass 0 reportsMAG_CAL_BAD_OFFSETS (8); remaining compasses still succeed.This contribution was AI-assisted (GitHub Copilot).