Act on compass read return value#511
Conversation
|
Very interesting. I've just rebuilt the quad with the dodo to eliminate the GPS/compass, so it'll probably be Monday before I try this. |
|
Good catch!
HMC5883 is extremely picky. A few corrupt readings in self calibration and
compass will be totally off.
Next thing would be signalling this to IMU and navigation to take
appropriate action, but that's a task for another PR.
|
| mag.read(magADCRaw); | ||
| for (axis = 0; axis < XYZ_AXIS_COUNT; axis++) magADC[axis] = magADCRaw[axis]; // int32_t copy to work with | ||
| if (!mag.read(magADCRaw)) { | ||
| return; |
There was a problem hiding this comment.
We still need to return zero vector here so IMU can detect invalid compass and act accordingly.
|
I've updated to return a zero value in One other thought: in initialisation it tries to collect 10 samples, if any read fails there will be less than ten samples. Should I change it to collect 10 valid reads? And put in some protection so that if the reads continually fail it does not get stuck in the loop? |
|
Yes, I think we should collect ten valid readings and if it times out just
return false.
Or maybe (for safety reasons) if we got at least one failed read/write
during detection process - report no compass.
|
|
OK, I've improved the handling of invalid readings in initialisation. The |
|
I agree to both:
|
|
I think it's safe to merge this right away. @martinbudden is this ready to merge? |
|
See #514 for further discussion. |
|
Yes, you can merge this now. |
Stops ignoring the return value of the compass read function. Takes action if read returns false.