stacywu / ardupilot-mega

Automatically exported from code.google.com/p/ardupilot-mega
0 stars 0 forks source link

FBW_B does not work with airspeed on #183

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. set FBW_B and airspeed enabled
2. compile and run under real plane and Xplane
3. throttle goes 0 to 100% constantly 

What is the expected output? What do you see instead?
throttle to be steady

What version of the product are you using? On what operating system?
r1243

Please provide any additional information below.

since airspeed is now and integer this function does not work anymore
airspeed_energy_error = (long)(0.00005f * airspeed_error*airspeed_error - 
airspeed*airspeed);

I tried with the following formula with some success but as I do not understand 
it (0.00005 ??), I do not think that this is the proper way to do it.

airspeed_energy_error = (long)(0.00005f * (airspeed_error*airspeed_error - 
(float)airspeed*(float)airspeed));

Original issue reported on code.google.com by mbada...@gmail.com on 11 Oct 2010 at 9:52

GoogleCodeExporter commented 8 years ago
looks like sensors.pde as the same issue
in void read_airspeed(void)
the above was for ArduPilotMega.pde at line 806

Original comment by mbada...@gmail.com on 11 Oct 2010 at 10:35

GoogleCodeExporter commented 8 years ago
I had problems similar to your qualitative description last time I flew my real 
airframe and you're right about airspeed changing to an integer recently; that 
seems like a likely culprit.  For some background, see Issue 124.  From a quick 
glance, it looks like there is a parenthesis bug in the current code; the 
0.00005 constant should be applied to the difference between airspeed_error^2 
and airspeed^2, not just to airspeed_error^2.  However, your correction looks 
fine; that's close to how I would have tried to fix it.  You say you had some 
success; what is still wrong after making that change?

As a side note, airspeed_energy_error shouldn't be calculated by two different 
formulas in the code; I'll see about changing that.

Original comment by bjpcalt...@gmail.com on 12 Oct 2010 at 1:14

GoogleCodeExporter commented 8 years ago
Well nothing wrong but the formula looks like FBW_B with it would never have 
worked then with the energy error computation and I was looking for something 
simpler. Happy to see that I was not too far off.
Just for my info what is this formula ?
Is this dynamic energy ? : 
http://www.experimentalaircraft.info/flight-planning/aircraft-lift-formula.php

Original comment by mbada...@gmail.com on 12 Oct 2010 at 5:51

GoogleCodeExporter commented 8 years ago
I don't think FBWB is used very much (I've never used it; I use FBWA instead) 
which is probably why it wasn't caught before now.  The formula is just simple 
kinetic energy: 1/2*m*v^2, except that mass is the same in all terms so we 
ignore that.  velocity is in cm/s rather than m/s, so we divide by (1/100)^2 to 
get more manageable units that are compatible with potential energy (m*g*h).  
The airspeed energy error is the difference between the kinetic energy at the 
current speed and the kinetic energy at the target speed.

Just to be clear, FBWB didn't work before you made the above change and it does 
now?

Original comment by bjpcalt...@gmail.com on 12 Oct 2010 at 6:39

GoogleCodeExporter commented 8 years ago
Thanks for the explanation it makes more sense now. Indeed it was not working 
and it works now. I want to use fbw_b when i am flying fpv, it makes it simpler.

Original comment by mbada...@gmail.com on 12 Oct 2010 at 6:52

GoogleCodeExporter commented 8 years ago
bjpcaltech, are you Benjamin Pelletier?

Original comment by dewei...@gmail.com on 12 Oct 2010 at 2:31

GoogleCodeExporter commented 8 years ago
Yep, that's me :)  And thanks mbadaire; I'll make your change part of the 
repository.

Original comment by bjpcalt...@gmail.com on 12 Oct 2010 at 5:31

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1247.

Original comment by bjpcalt...@gmail.com on 12 Oct 2010 at 7:21