dir_sim

PURPOSE ^

DIR_SIM - Direct control allocation simulation.

SYNOPSIS ^

function [u,W,time] = dir_sim(B,v,plim,varargin)

DESCRIPTION ^

 DIR_SIM - Direct control allocation simulation. 

  [u,W,time] = dir_sim(B,v,plim,[rlim,T],options)

 Performs direct control allocation for a sequence of virtual
 control commands stored in v. For each value of v, the control
 signal u is determined by solving

   max a   subj. to  Bu = av
   a,u               u in U

 If a > 1,  u = u/a.

 Here, U is the set of feasible controls only with respect to
 the position limits. Rate limiting is (optionally) performed
 on the allocated control vector.

  Inputs:
  -------
 B     control effectiveness matrix (k x m)
 v     commanded virtual control trajectory (k x N)
 plim  position limits [min max] (m x 2)
 rlim  rate limits [min max] (m x 2) ([] --> no rate limits)
 T     sampling time [1]

  Options: options = option_1,value_1,option_2,value_2,...
  --------
 'ui'  initial control signal
 'rep' no. of repetitions [1]

  Outputs:
  -------
 u     optimal control
 W     active constraints in u (+/- : max/min, 1/2 : position/rate)
 time  average computation time per sample
 
  Example:

   load f18data
   u=dir_sim(B,v,plim,rlim,T2);
   figure(1),plot(tn,u*180/pi),ylabel('Controls (deg)')
   figure(2),plot(tn,B*u,tn,v,'k--'),legend('roll','pitch','yaw')

 See also: DIR_ALLOC, QP_SIM, DYN_SIM.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [u,W,time] = dir_sim(B,v,plim,varargin)
0002 
0003 % DIR_SIM - Direct control allocation simulation.
0004 %
0005 %  [u,W,time] = dir_sim(B,v,plim,[rlim,T],options)
0006 %
0007 % Performs direct control allocation for a sequence of virtual
0008 % control commands stored in v. For each value of v, the control
0009 % signal u is determined by solving
0010 %
0011 %   max a   subj. to  Bu = av
0012 %   a,u               u in U
0013 %
0014 % If a > 1,  u = u/a.
0015 %
0016 % Here, U is the set of feasible controls only with respect to
0017 % the position limits. Rate limiting is (optionally) performed
0018 % on the allocated control vector.
0019 %
0020 %  Inputs:
0021 %  -------
0022 % B     control effectiveness matrix (k x m)
0023 % v     commanded virtual control trajectory (k x N)
0024 % plim  position limits [min max] (m x 2)
0025 % rlim  rate limits [min max] (m x 2) ([] --> no rate limits)
0026 % T     sampling time [1]
0027 %
0028 %  Options: options = option_1,value_1,option_2,value_2,...
0029 %  --------
0030 % 'ui'  initial control signal
0031 % 'rep' no. of repetitions [1]
0032 %
0033 %  Outputs:
0034 %  -------
0035 % u     optimal control
0036 % W     active constraints in u (+/- : max/min, 1/2 : position/rate)
0037 % time  average computation time per sample
0038 %
0039 %  Example:
0040 %
0041 %   load f18data
0042 %   u=dir_sim(B,v,plim,rlim,T2);
0043 %   figure(1),plot(tn,u*180/pi),ylabel('Controls (deg)')
0044 %   figure(2),plot(tn,B*u,tn,v,'k--'),legend('roll','pitch','yaw')
0045 %
0046 % See also: DIR_ALLOC, QP_SIM, DYN_SIM.
0047   
0048 % Different example:
0049 %   B = [2 1]; t = 0:.2:10; v = 4*sin(t); plim = [-1 1;-2 1];
0050 %   u = dir_sim(B,v,plim);
0051 %   plot(tn,u)
0052 %   plot(tn,v,'k',tn,B*u)
0053 
0054 % Number of variables
0055   [k,m] = size(B);
0056 
0057   % Find no. of optional arguments (excluding options)
0058   iopt = length(varargin)+1;
0059   for i = 1:length(varargin)
0060     if ischar(varargin{i})
0061       iopt = i; % index of first option string
0062       break;
0063     end
0064   end
0065   narg = iopt-1;
0066 
0067   % Set default values of optional arguments
0068   rlim = [];
0069   T    = 1;
0070 
0071   % Set values of submitted optional arguments
0072   for i=1:narg
0073     switch i
0074      case 1, rlim = varargin{i};
0075      case 2, T      = varargin{i};
0076     end
0077   end
0078       
0079   % Call generic control allocation simulation subroutine.
0080   [u,W,time] = alloc_sim('dir',B,v,plim,rlim,T,'hot',0, ...
0081              varargin{iopt:end});
0082

Generated on Wed 25-Aug-2004 14:38:35 by m2html © 2003