-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP_Compass: avoid saving device IDs if not calibrated #25058
Conversation
Could this be fixed with documentation? Or in mission planner before the calibration? We could pre-arm if using a internal compass when there is a calibrated external. There was extreme hesitance about messing with compass stuff in #23706 and this is a much more major re-work. |
it is perfectly valid to use the internal as primary and on some vehicles that is actually the right thing to do
the compass ordering is already documented. It didn't save this vehicle, and I have noticed that quite a few logs I review have the internal as first compass. Now we know why. I think this was just a bug. If when you unwrap your shiny new flight controller and plug it in on USB to see the blinky lights (which I bet nearly everyone does) then it locks in your internal as the first compass. That is not desired behaviour. |
I think we can actually simulate the user story outlined above reasonably well, actually. We should be able to
The toughest bit in there is working out how to start the |
@peterbarker it doesn't have to actually be a DroneCAN compass. The original issue was with I2C internal and external compasses. |
Seems like this is two different changes that should be in two different PR's |
39feab5
to
a7ea68d
Compare
the GPS changes are actually already in master, I've rebased and now it doesn't show them in this PR. Sorry for the confusion |
a7ea68d
to
51ea0ba
Compare
this controls whether SITL saves device IDs for compasses on startup so the compasses always appear calibrated
this fixes an issue with the following sequence: - new board (or board with FORMAT_VERSION reset) starts up with only internal compasses - internal compasses are detected and devids saved - an external compass is added and the board is rebooted - the external compass will not be the first compass - user then calibrates and flies, but has internal as primary this can lead to a very bad experience for new users. At least one vehicle has crashed due to this sequence. The fix is to not save device IDs during the Compass::init() if we have never been calibrated. This means that when an external compass is added it will come up as the first compass. This also removes the saving of the extra device ID. It was never intended that these be saved (there is a comment to that effect in the code), but actually they were saved.
this is a NFC to make the PR clearer
it is highly likely that a user with a DroneCAN compass will want it to be earlier in the dev list than i2c or spi compasses
51ea0ba
to
afdd049
Compare
the init process. | ||
*/ | ||
suppress_devid_save = true; | ||
for (uint8_t i=0; i<COMPASS_MAX_INSTANCES; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (uint8_t i=0; i<COMPASS_MAX_INSTANCES; i++) { | |
for (uint8_t i=0; i<ARRAY_SIZE(_state._priv_instance); i++) { |
Kinda feels like this should also be backported to as many releases as possible? |
this fixes an issue with the following sequence:
this can lead to a very bad experience for new users. At least one vehicle has crashed due to this sequence.
The fix is to not save device IDs during the Compass::init() if we have never been calibrated. This means that when an external compass is added it will come up as the first compass.
@peterbarker I'd like to discuss how we could add a CI test for this. I think we would need to use AP_Param/tools/eedump_apparam to look for saved IDs for key 147 (compass)
edit: updated to move DroneCAN probing for compasses earlier in the detection list