-
Notifications
You must be signed in to change notification settings - Fork 26
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
IMU quaternion v4 #79
IMU quaternion v4 #79
Conversation
implemented static gyro noise integration lock trough standard deviation modulus phase out rmat (use quaternion) improved gyro Integration (PCDM Acta Mech 224, 3091–3109 (2013)) separated from Mahony PI corrected acc corrected gyro increased default dcm_ki dcm_kp for faster convergence removed ATTITUDE task rescheduling
Sweet 😁 Have flown this a bit on your betaflight fork with my whoop (an older version) and loved it. |
@brucesdad13 it still needs beta testing. |
@adrianmiriuta Thanks for your contribution. We are in the process of reviewing it still. Could you tell me a little more about how much testing has gone into this so far? |
it is indoor tested (working) on: Because of the manifold improvements in It was submitted here about 2 months ago: |
@adrianmiriuta Ok, I will enlist some beta testers to do some thorough testing of your PR |
adrian, |
PI controller response with minimal overshoot. set debug_mode = IMU debug[0] = gyro absolute rotation speed tested with a non mounted LUX_RACE |
@adrianmiriuta - We have been conducting some testing all day. Results are promising so far, no issues reported - some users reported better feel in the air but hard to say if its something quantifiable. CPU usage seems largely unchanged for most users as well. Will report back when testing is fully concluded. |
yes, that was my thinking. for example flying through a turbulent zone and the controller goes crazy. |
@kidBrazil |
@robert-b |
adrian, |
@robert-b @adrianmiriuta I had multiple users test this branch specifically today - They all tested with outdoor flying and I told them to really push the limits as much as they felt comfortable. All have reported positive results, no one complained of issues with tune or feel. Most of them used Diff from previous build too so no retuning. EDIT - Found a few more willing participants.. will update after they test as wsell. |
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 found some places where minor optimizations could be done or just code cleanup. If you have time could you fix those?
src/main/common/maths.c
Outdated
} | ||
|
||
void quaternionNormalize(quaternion *q) { | ||
float modulus = sqrtf(q->w * q->w + q->x * q->x + q->y * q->y + q->z * q->z); |
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.
Could be just float modulus = quaternionModulus(q);
src/main/common/maths.c
Outdated
} | ||
|
||
void quaternionInverse(quaternion *i, quaternion *o) { | ||
float norm = i->w * i->w + i->x * i->x + i->y * i->y + i->z * i->z; |
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.
Could be just float norm = quaternionNorm(i)
src/main/common/maths.c
Outdated
} | ||
|
||
float quaternionModulus(quaternion *q) { | ||
return(sqrtf(q->w * q->w + q->x * q->x + q->y * q->y + q->z * q->z)); |
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.
return(sqrtf(quaternionNorm(q)));
qPout->zz = qIn->z * qIn->z; | ||
} | ||
|
||
void quaternionMultiply(quaternion *l, quaternion *r, quaternion *o) { |
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.
We should skip the const floats and go for direct set:
o->w = l->w * r->w - l->x * r->x - l->y * r->y - l->z * r->z;
o->x = l->w * r->x + l->x * r->w + l->y * r->z - l->z * r->y;
o->y = l->w * r->y - l->x * r->z + l->y * r->w + l->z * r->x;
o->z = l->w * r->z + l->x * r->y - l->y * r->x + l->z * r->w;
Same thing, just more clear code.
@LexioTech |
doesn't make much sense. |
@robert-b |
@adrianmiriuta Thank you! 👍 Yes, the compiler is smart and will optimize this, but we also need to optimize the code for reading and coding friendliness. |
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.
Nice! Thank you for taking the time to do these minor cleanups 👍
and above there is a medianfilter template. |
you mean ?
sorry I don't understand what you mean. |
@LexioTech @adrianmiriuta but the re-viewers and you did not recognize that the quaternions aft the assigment 'explodes ...
my 2 cents on a code review. |
How would you do that ?
Now I understand. this is only a zero division avoidance . (not my best implementation ...) this function is also used to normalize vectors In a quaternion typeset storage. |
hmm, |
No ! I use quaternionNormalize() also on vectors in quaternion storage. If a unit quaternion is that degraded, If you want to monitor that you should write a extra function to do that ! |
:-) |
@adrianmiriuta - We have decided to include this feature as a Release Candidate following our next release so that we can get even more testers on board. One of the things that has been mentioned to me a couple of times is that this feature breaks Black Box Explorer functionality. I have not confirmed this myself but will look into it. |
Ok ! I used blackbox log pretty extensive to debug the code, |
@adrianmiriuta - I was sent this screenshot from the user who complained about BBE being broken. He says the LPF and notch frequencies are not showing up properly. Could be entirely unrelated to this branch so I will investigate as well. EDIT -To get testing to work we took your branch, merged it with Master and the IMU 104 so we could test on HELIOSPRING as well. So something might have introduced the bug outside of your work. I will check to make sure. If you want to investigate as well I have a branch called TEST-imuquaternion-104-master |
@kidBrazil @LexioTech this change is forbidden. sorry I overlooked that. |
I am not able to replicate the BBE issue. |
@adrianmiriuta I was not able to replicate the issue either. And so far only 2 people piped up so might be nothing. I will get a diff for you so we can go over it. We will be making an RC version with quaternions soon so we can get even more testing done. So far all feedback has been positive or "no change" which I believe is fine also. |
@adrianmiriuta I managed to get the BB log in question here and will paste the DIFF below diffversionButterFlight / HELIOSPRING (HESP) 3.5.0 | IMUF: 1.0.4 Mar 28 2018 / 16:42:18 (235529c) MSP API: 1.39namename Hazak 6S featurefeature -LED_STRIP serialserial 1 2048 115200 57600 0 115200 auxaux 0 0 0 1700 2100 0 masterset acc_hardware = AUTO profileprofile 0 set dterm_lowpass = 90 rateprofilerateprofile 0 set roll_rc_rate = 170 HELIO 3_5.zip |
Take your time, tough testing is a good thing.
That's not very comforting ! From the "diff" i take most of your testers fly FPV ?
Do you have testers who fly LOS ? |
I looked over the logs
but my javascript is too poor to deepen this. |
@kidBrazil |
@adrianmiriuta So, looks like after some investigation this issue with BBE only affects HELIOSPRING - Ornery has disabled the notch filtering ENTIRELY on that target which is why it doesn't show up.. sorry I missed that completely and sorry if I wasted any of your time. That said I will look into the parser as well for BBE just to make sure. Unfortunately I would say that 99% of my test pilots are doing FPV flights at the moment, I should be able to find some people willing to test LOS. I will mention specifically that testers should try it in one of the other Attitude modes as well. Thanks again for the collab. |
phase out rmat (use quaternion)
implemented static gyro noise integration lock trough standard deviation modulus
improved gyro Integration (PCDM Acta Mech 224, 3091–3109 (2013))
separated from Mahony PI
corrected acc
corrected gyro
increased default dcm_ki dcm_kp for faster convergence
removed ATTITUDE task rescheduling