Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

remove observer; add steady-state & trim values to controller

  • Loading branch information...
commit 3f0cf9b9aade3dd6d031d5a4d3a790443091d872 1 parent 5726905
Andrew Cameron authored

Showing 3 changed files with 14 additions and 14 deletions. Show diff stats Hide diff stats

  1. +4 1 controller.m
  2. +3 6 runsim.m
  3. +7 7 sim3d.m
5 controller.m
... ... @@ -1,7 +1,10 @@
1 1 function d = controller(x, z)
2 2 % Cut and paste state variables into the form the linearized model expects.
3 3 % Ditto with the reference input.
4   - x3d = [ x(4) x(6) x(11) x(22) x(5) x(10) x(12) x(23) x(21) ]';
  4 + % Adjust the pitch by the steady-state value to get the disturbance pitch.
  5 + % Steady-state values for roll & yaw are zero.
  6 + % TODO: put disturbance pitch adjustment in localize_state
  7 + x3d = [ x(4) x(6) x(11) (x(8)+0.2621) x(5) x(10) x(12) x(9) x(7) ]';
5 8
6 9 persistent A B C H Kstate Kref;
7 10 if (isempty(A))
9 runsim.m
@@ -6,14 +6,11 @@
6 6 % initial output error
7 7 % initial state estimates (everything above, except for output error)
8 8 xinit = [ 2000 2000 2000 ...
9   - -8 0 0 ...
10   - 0 0 0 ...
  9 + -10.8 0 0 ...
  10 + 0 pi/8 0 ...
11 11 0 0 0 ...
12 12 0 0 ...
13   - ]';
14   - x = localize_state(xinit); % initial state, localized
15   - xhatinit = [ x(4) x(6) x(11) x(8) x(5) x(10) x(12) x(9) x(7) ]';
16   - xinit = [xinit; xhatinit];
  13 + ];
17 14 ts = linspace(0, 2, 1000);
18 15 sim = @(x,t)sim3d(t, x);
19 16 lsode_options('integration method', 'stiff');
14 sim3d.m
@@ -20,14 +20,14 @@
20 20 % -the state derivative is calculated by the aerodynamic simulation, plant()
21 21 % -the derivative of the integrated output error is the current output error.
22 22 function Xdot = sim3d(t, X)
23   - % P = planpath(X);
24   - P = [0 0]';
25   - x = [localize_state(X) X(13:23)'];
26   - z = X(13:14);
27   - d = controller(x, z);
28   - % Xdot = plant(X, [-3*pi/16 0]);
  23 + % P = planpath(X);
  24 + P = [0 0]';
  25 + x = localize_state(X);
  26 + z = X(13:14);
  27 + d = controller(x, z);
  28 + % Add steady-state trim to the controller's differential output.
  29 + d = d + [-0.83301 0];
29 30 Xdot = plant(X, d);
30   - Xdot(15:23) = observer(x, d);
31 31 Xdot(13:14) = P;
32 32 Xdot = Xdot';
33 33 end

0 comments on commit 3f0cf9b

Please sign in to comment.
Something went wrong with that request. Please try again.