Skip to content
Browse files

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

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

0 comments on commit 3f0cf9b

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