-
Notifications
You must be signed in to change notification settings - Fork 16.9k
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
Force compasses to use SI units #2599
Conversation
8c13b00
to
19d9eed
Compare
What's our policy on the PR reviewing once again? I can update this commit with a rebase but it'll purge all our comment. (This is where |
The problem is with github, not git ;-). The final patch set should be clean with no fixups on top, i.e. a rebase should be done. You can do now opening a new pr and linking to this one, or you can put the fixups on top, wait for others to comment and then do the final rebase. |
Another option if opening a new pr is too troublesome: do a push -f and update the description of this pr with a link to the last commit of the previous version. Github doesn't actually remove the comments, the problem is that the comments are "attached" to the commits and since their hashes change when you rebase we lose their reference. Example: for this pr even if you force push I'd still be able to see the comments by going to |
19d9eed
to
5b98344
Compare
Thanks for the clarification! I've updated the PR accordingly. |
The Travis PX4 build fail is unrelated. |
I think naming the variable "scaling" makes more sense.
This way we don't mix two different conditionals: settling and data validation.
The new variable name is suitable for the purpose it's used i.e. adding all the measurements.
This commit will require all users to recalibrate the compasses. The change is essestially is a trivial fix of an old bug that has lived until now. The only thing that has changed is scaling. From now on we HMC driver operates with proper units (i.e. milligauss).
Use uT (SI) instead of mG. The change has been discussed. In order to make people recalibrate their compasses we might need to introduce a new parameter for compass offsets in SI.
AK8963 is configured in 16-bit ADC mode which implies sensitivity of 0.15 uT/LSb. Knowing this fact we can convert the measurements to the proper units. The change will make users recalibrate their compasses.
In order to notify users to recalibrate their compasses we need to add these new parameters. They imply that Compass public API uses uT (Microtesla). Using common units will make our life easier eventually. Especially if one needs to add a new compass driver in the future. I suggest enforcing this policy from now on. The naming for parameters is ugly. In fact there's reason to it: the maximum parameter name's length used now is 16. We can either increase the maximum length a bit or come up with a better name for this parameter.
Use SI units (uT) from now. This commit requires compass recalibration.
Get rid of some of the trailing spaces while I'm at it.
5b98344
to
3b23bca
Compare
@tridge @rmackay9 @lucasdemarchi I've updated the PR and would like to get a comment on this. Too many Navio users complain about failing pre-arm check that verifies that offsets are in a range suitable for HMC5883 rather than performing a more generic check. |
I made some comments on the individual patches I cherry-picked from this pr to mine. I did this in order not to cause headache with conflicts. For the pr, I think we could do it in 2 steps because it's a long time already and I don't think @rmackay9 wants to push this to 3.3. It would be much easier to accept if it was done like:
So we could convert the values to the same range HMC5883 is using (let's call it hmc-unit). This already fixes the bug. After 3.3 is out we convert all sensors to SI and deal with all the drivers, PX4, changes to params, etc. @staroselskii @rmackay9 do you agree? |
Thanks for the review and bug fixes! If I understand correctly, we need to introduce a new method for converting compass-specific units to common I'd been hoping to get it done before AC3.3 but I understand that this is a vast change that needs to be tested thoroughly. The major concern for me is getting compass pre-arm checks working for Navio without making code more coupled. I also encourage to use |
So... after the call yesterday we decided to go a little beyond that. It's not hmc-units, but milligauss. It's still not SI, but better than hmc-units. So the idea is that there's a public API in the AP_Compass library to get the measurements in milligauss. The pre-arm check uses this API. The saved parameter with offsets however uses the sensor-specific data. This way we don't worry about previously saved values, units, etc. When we get the compass calibration inside ardupilot (and would be great if someone volunteers for this effort), then we are allowed to change the unit we save and publish (maybe microtesla, dunno).
It's a big pullrequest that maybe has to wait a little bit to be merged. Don't wait that pullrequest. I pushed a branch with only the patches that would conflict with yours. You can use that one to work on top: https://github.com/lucasdemarchi/ardupilot/commits/hmc-cleanup
yep... if we can make these changes quickly I think it can still go to 3.3... or at least would be easy to cherry-pick for an eventual 3.3.1. That's up to @rmackay9 though.
we can do that after the compass calibration.... Right now it won't be visible to the user and the saved values will be in sensor-specific units, so it doesn't really matter. |
Thanks, Lucas!
I'd like to get everything right before starting to implement it once more. So, everything is converted to milligauss. To sum up, the only thing we need to add to the public compass backend API is the This way the AK8963's problem will be also solved. |
I think it would be easier to add The constants in motors.cpp can be updated, as long as you update compass.get_offsets() to be compas.get_offsets_milligauss(). |
Closed in favor of #2748. |
A replacement for #2397. This one needs extensive testing.
The code for HMC was slightly refactored. Nothing fancy, just extracted a couple of methods. If that's not needed, let me know!) . There's a couple of places in the HMC's code that I don't entirely understand. Especially this:
Why do we do such a thing?
And also this one:
Is it absolutely necessary to rotate on the low level? Cannot it be done on the higher one?
Magnetometer offsets also need to be adjusted (I suggest using something like 50 uT. That's the magnetic field vector around the Earth's surface).
I also need some insight on PX4 compass driver.
Updated (9d9068d is the previous HEAD):
Rebased on master (9391266 is the previous HEAD)