pheidlauf / AeroBenchVV

Simulation and analysis tools for autonomous F-16 maneuvers as a V&V benchmark
GNU General Public License v3.0
63 stars 22 forks source link

calculation of ps in new version #10

Open stanleybak opened 4 years ago

stanleybak commented 4 years ago

I'm trying to reproduce the v2 controller in python and ran into an issue where I think ps is being computed incorrectly in Matlab.

This is done in subf16_morelli.m. The comments say:

% ps= p*cos(alpha) + r*sin(alpha)

and the computation is done as:

ps = x_f16_dot(7)*cos(x_f16_dot(2)) + x_f16_dot(9)*sin(x_f16_dot(2));

I don't see why it's valid to use the x_f16_dot states here? These are derivatives not state variables. Previously we had code that extracted the state variables from x_delta, which was the difference between the current state and the trim state.

The Ny_r computation has a similar issue. The old computation was Ny_r = ay/g + x_ctrl(6), the new computation is Ny_r = ay/g + x_f16_dot(9);

stanleybak commented 4 years ago

note: using the earlier method to compute ps and Ny_r using x_ctrl makes the optimized gains work very poorly, where the aileron especially oscillates quickly between its limits. You can guess this would happen as the gains in some of the rows of the optimized LQR matrix are a few orders of magnitude larger than the gains in the old LQR matrix.

wuuuiYan commented 1 year ago

What you mean is I'd better use old LQR matrix, right?

stanleybak commented 1 year ago

I think there's a flag now to choose between the versions. See the code here.