-
Notifications
You must be signed in to change notification settings - Fork 31
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
Feature: error correction offsets. #48
base: master
Are you sure you want to change the base?
Conversation
The example works as the following pseudo-code.
|
@juliangaal Please, can you still look at this PR? |
I can and will, but am short for time atm |
I understand. Thank you in advance for your time. |
Thank you for your effort. In the mean time (maybe you didn't know) you can use a link to a github repository (your fork in this case) in your |
just as an idea: why not put the calibration logic into the lib either as a dedicated |
That might be a good option for bigger projects. |
maybe offer two APIs?
then the consumer can decide:
|
I'll have a serious look after my thesis is completed, great suggestion @rursprung |
@juliangaal I have time at the end of next week to write the basis for this feature and incorporate it into this PR. |
perfect. As soon as I can test on my hardware, I'll merge. Please take your time, my thesis deadline is Dec 02. |
What exactly do you mean with "the previous data"? I've searched the datasheet and register map for any references of calibration registers or something similar, but found nothing |
Work has begun in branch dev. Please also change the base of this request to dev for further changes @HeikoRibberink |
sorry if i didn't make this clear |
ah ok, that makes sense. Regarding your suggested |
my suggestion before was this API (i've just added in
so a consumer could do something like this (pseudocode): let i2c = ...;
let mut mpu = Mpu6050::new(i2c);
mpu.init(&mut delay).unwrap();
if let Some(calibration_data) = load_calibration_data() { // some function of the consumer to get the data somewhere
mpu.load_calibration_data(&calibration_data)?;
} else {
let calibration_data = mpu.calibrate()?;
store_calibration_data(&calibration_data); // some function of the consumer to persist the data for future usage
} |
@HeikoRibberink two questions regarding your calibration code:
Thanks for your help and excuse my long, long delay |
No, the fact that the default
Delta is the difference between the expected reading and the actual reading and the algorithm tries to minimize this difference. In the part where the offsets are calculated, it doesn't really make sense to square it, as you can minimize the difference linearly, and squaring might lead to overshooting.
The errors are averaged by multiplying with (Side note: it is probably better to divide by |
Couldn't this achievement/non-achievement be detected at runtime and returned to the user? Or detect an error that is too large and abort? |
Good idea; it would take a lot of hassle away from the user of this library. However; how would we implement this without it having the chance to loop infinitely, but keeping a high accuracy? |
I guess convergence can be measured in two ways:
The latter is more indirect, but combining both metrics is a reasonable approximation, I would think. Infinite loop would simply be prevented with a maximum allowed loops. If the maximum is reached without 1. and 2., the calibration has "officially" failed and parameters will need to be adjusted. |
Adds offsets for error correction, and an example that can automatically generate offsets.