Altitude - accelerometr and baro
Altitude - accelerometr and baro
Hi,
I want to use accelerometer and baro for computing altitude on my own DIY flight controller.
So my question is: How can I get distance (altitude) from accelerometer (probably oddouble integration of accel.)... SO what are the steps to get it?
1) Probably I have to get linear acceleration of all axes(without gravity), than make some deadband (for cancel noise) and there use some LPF.
2) Than use double integration of acc_Z
3) I should have a altitude (distance) in Z...
4) Use complementary filter with baro_alt to reduce drift form accelerometer.
But it could works only if my quadro will be align to the earth, is not it?
So how is the best prcess to make a functional solution?
Or are there any others solution? quaternion, roation matrix...?
Thank you very much for your help.
I want to use accelerometer and baro for computing altitude on my own DIY flight controller.
So my question is: How can I get distance (altitude) from accelerometer (probably oddouble integration of accel.)... SO what are the steps to get it?
1) Probably I have to get linear acceleration of all axes(without gravity), than make some deadband (for cancel noise) and there use some LPF.
2) Than use double integration of acc_Z
3) I should have a altitude (distance) in Z...
4) Use complementary filter with baro_alt to reduce drift form accelerometer.
But it could works only if my quadro will be align to the earth, is not it?
So how is the best prcess to make a functional solution?
Or are there any others solution? quaternion, roation matrix...?
Thank you very much for your help.
Re: Altitude - accelerometr and baro
If the ACC and baro you plan on using is in the independent sensors section of the config.h, all you will need to do is enable them and set their orientation. If you plan on using a non standard set of sensors then you will need to be writing code.
-
- Posts: 103
- Joined: Fri Dec 12, 2014 5:16 pm
Re: Altitude - accelerometr and baro
potentially you are talking about this:
https://github.com/multiwii/multiwii-fi ... U.cpp#L296
this is pretty much done the way you describe. AFAIK the default PID for acc_z integration are set to 0 so you might want to change them to see an effect
https://github.com/multiwii/multiwii-fi ... U.cpp#L296
this is pretty much done the way you describe. AFAIK the default PID for acc_z integration are set to 0 so you might want to change them to see an effect
Re: Altitude - accelerometr and baro
NOO, I just want to make my own software, own board (like naze32..)
I want to measure altitude as in multiwii, or cleanflight... But my question is - how to program this - what is an algorithm.
Is there any human who wrote the code for measure altitude?
Tahnk you
I want to measure altitude as in multiwii, or cleanflight... But my question is - how to program this - what is an algorithm.
Is there any human who wrote the code for measure altitude?
Tahnk you
Re: Altitude - accelerometr and baro
witc68 wrote:Hi,
So my question is: How can I get distance (altitude) from accelerometer (probably oddouble integration of accel.)... SO what are the steps to get it?
I do not think you can do that practically with the regular hardware. Acc is just too noisy to integrate twice. It works fine to augment baro input, but that is all, I think. In MW, Acc is being used to get a fast component of vertical velocity for altitude hold mode but that only feeds into D-term and only in combination with barometric velocity, which keeps it reasonable.
But if you want to try, the IMU module of MW is very nicely written and straightforward to understand (and reuse for your own purposes if you so desire). The algorithm is simple if you remember basic vector math:
1. Continuously calculate (incrementally) 3 components of Earth gravity vector in copter's coordinate frame using gyro data and a bit of accelerometer. This vector is called EstG.
2. Calculate (from scratch each time) scalar projection of smoothed Acc vector onto EstG vector (this is done by getting dot product of EstG vector and smoothed Acc vector first).
3. Subtract predetermined 1G. What's left is actual acceleration component directed down in Earth coordinate frame.
Re: Altitude - accelerometr and baro
exaxtly as happul3 wrote.
It was easy enough to do an integration over time and assign the result to the debug[] variable. Then at the end of the flight one could see the accumulated error. Repeat for numerous flights to learn and see it will likely resemble noise only -:(
It was easy enough to do an integration over time and assign the result to the debug[] variable. Then at the end of the flight one could see the accumulated error. Repeat for numerous flights to learn and see it will likely resemble noise only -:(
Re: Altitude - accelerometr and baro
Well in baseflight is
I do not understand why there is .... accAlt +=..... + vel * dt - why +vel*dt ? Can ynyone explain it?
Code: Select all
accZ_tmp = (float)accSum[2] / (float)accSumCount;
vel_acc = accZ_tmp * accVelScale * (float)accTimeSum;
// Integrator - Altitude in cm
accAlt += (vel_acc * 0.5f) * dt + vel * dt; // integrate velocity to get distance (x= a/2 * t^2)
accAlt = accAlt * cfg.baro_cf_alt + (float)BaroAlt * (1.0f - cfg.baro_cf_alt); // complementary filter for altitude estimation (baro & acc)
EstAlt = accAlt;
vel += vel_acc;
I do not understand why there is .... accAlt +=..... + vel * dt - why +vel*dt ? Can ynyone explain it?
Re: Altitude - accelerometr and baro
witc68 wrote:Well in baseflight is
I do not understand why there is .... accAlt +=..... + vel * dt - why +vel*dt ? Can ynyone explain it?
Seems straightforward: velocity multiplied duration produces distance traveled (=change in altitude in this case).
Re: Altitude - accelerometr and baro
I know what is velocity multiple by time, but... If quadro will increase in altitude, than stops, so acc_Alt will be still higher and higher because you impute vel*dt in every cycle.. understand me what i am meaning?
Re: Altitude - accelerometr and baro
witc68 wrote:I know what is velocity multiple by time, but... If quadro will increase in altitude, than stops, so acc_Alt will be still higher and higher because you impute vel*dt in every cycle.. understand me what i am meaning?
Words "increase in altitude, than stop" mean that initially vel is positive and so it will indeed add to altitude every cycle. And than vel becomes zero (in your words, stop) and that will add exactly zero to altitude every cycle.
-
- Posts: 103
- Joined: Fri Dec 12, 2014 5:16 pm
Re: Altitude - accelerometr and baro
In different terms altitude hold aims at having velocity at 0. The moment you have any Z velocity (combination of Baro and acc_z) this will result in speeding up or slowing up the motors respectively if this makes sense