-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
[WIP] Pr compasscal offdiag #9136
Conversation
src/drivers/hmc5883/hmc5883.cpp
Outdated
/* flip axes and negate value for y */ | ||
new_report.y = ((yraw_f * _range_scale) - _scale.y_offset) * _scale.y_scale; | ||
new_report.y += ((xraw_f * _range_scale) - _scale.x_offset) * _scale.x_offdiag; | ||
new_report.z += ((zraw_f * _range_scale) - _scale.z_offset) * _scale.z_offdiag; |
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.
This should be new_report.y += ((zraw_f * _range_scale) - _scale.z_offset) * _scale.z_offdiag;
Thanks @AlexisTM. I left this open as a reminder to review the entire magnetometer calibration. |
Is this PR in a workable state? I have an application which needs compensation for soft iron distortions, and was wondering if it is safe to carefully start using this. |
I doubt it, but we could use this as a starting point. |
OK, I updated this locally and fixed a few things. Should be in a working state now, but I haven't tested yet. I also want to switch the application of the calibration into vector/matrix math, something like :
versus currently :
|
a1bff22
to
bcf665f
Compare
PR updated and rebased. General TODOs for sensor calibration pipeline :
|
@dagar I flew this a few times. Seems fine. Also gets rid of MAG SENSORS INCONSISTENT on a particular vehicle for me. Without the soft iron compensation, my GPS compass and the onboard compasses had some offsets between then. |
@@ -1656,8 +1659,17 @@ LSM303D::mag_measure() | |||
rotate_3f(_rotation, xraw_f, yraw_f, zraw_f); | |||
|
|||
mag_report.x = ((xraw_f * _mag_range_scale) - _mag_scale.x_offset) * _mag_scale.x_scale; | |||
mag_report.x += ((yraw_f * _mag_range_scale) - _mag_scale.y_offset) * _mag_scale.x_offdiag; |
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.
This ends up being a lot of verbose duplicated code. Why don't we just start using Matrix?
Does anyone know the history here? I'm wondering why it wasn't already done. |
@priseborough could you review this as well? Any specific suggestions for testing/validation? |
@@ -56,10 +56,13 @@ | |||
struct mag_calibration_s { |
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.
I believe we could add member initializers here instead of doing it manually in every driver's constructor (if it's no longer used in any C code).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. |
Completed in #15235. |
Opening this so we don't lose track of it.