Closed GoogleCodeExporter closed 8 years ago
Thanks for the issue report.
Not sure I follow your explanation 100% but I believe this is a known issue in
the code. It is basically due to us using an approximation that the change in
the square root of a sum is approximated by the change in the sum of the square
roots (first order taylor approximation).
While true that our calculation is sloppy, it does save a lot of a square root
operation, which is why it was implemented that way. And in actual practice
for altitude hold one term significantly dominates the other (the airspeed if
my top of the head memory is correct).
I will prioritize this as a low priority and leave it open.
Original comment by dewei...@gmail.com
on 25 Sep 2010 at 4:33
Original comment by DrZip...@gmail.com
on 25 Sep 2010 at 6:07
I'm not sure how the current implementation saves a lot of square root
operation; my suggested correction involves just one more multiplication, one
more subtraction and no square roots.
My sign is wrong above, so here's the full, actual equation ready to be pasted
into the code:
energy_error = 0.00005 * (airspeed_cruise*airspeed_cruise - airspeed*airspeed)
- (float)altitude_error * 0.098f;
This isn't a small error; consider the difference in energy_error between the
current equation and my equation with no altitude error:
For airspeed_cruise = 2000 cm/s and airspeed = 1900 cm/s, airspeed_error = -100
cm/s
energy_error_current = 0.00005 * 100 * 100 = 0.5
energy_error_suggested = 0.00005 * (2000*2000 - 1900*1900) = 19.5
For airspeed_cruise = 1000 cm/s and airspeed = 900 cm/s, airspeed_error = -100
cm/s
energy_error_current = 0.00005 * 100 * 100 = 0.5
energy_error_suggested = 0.00005 * (1000*1000 - 900*900) = 9.5
So, practically speaking, the current code will provide the same throttle input
to accelerate from 9 m/s to 10 m/s as it would to accelerate from 19 m/s to 20
m/s when it actually should be providing a little more than twice the throttle
input at the higher speed. This will make for either very jerky slow-speed
throttle control, or sluggish throttle control at high speeds depending on how
the gains are set.
Original comment by bjpcalt...@gmail.com
on 25 Sep 2010 at 6:56
Please ignore my previous entry. I was in a hurry and thinking of the earlier
implementation (ArduPilot 2.6) where we used pressure units for airspeed, and
required more computation to move between variable units.
You are correct. More energy is required to accelerate from 10 to 20 than from
0 to 10.
From first principals
(1) E = F*d, Energy = Force * distance
(2) F = m*a, Force = mass * acceleration
(3) v = a*t, Velocity (change in) = acceleration * time
(4) d = v0*t + a*t*t
For the easy to analyze case of constant acceleration and force (and of course
mass) it is evident that an acceleration from 0 to 10 will take the same time
as an acceleration from 10 to 20, but the distance covered will be
significantly greater in the latter case, and from equation 1 the energy
required greater.
I will put this on the to do list with a higher priority. I'm trying to not
spend the day at the computer today ;)
Original comment by dewei...@gmail.com
on 25 Sep 2010 at 10:41
R944
Original comment by dewei...@gmail.com
on 27 Sep 2010 at 5:02
Original issue reported on code.google.com by
bjpcalt...@gmail.com
on 20 Sep 2010 at 9:34