%
%----------ODYSSEY Parameters---------------
%
% Lets try it with Odyssey numbers:
%
  disp(' ')
  disp(' Using Odyssey Parameters:')
  vel = 3.0*kph2mps;        % speed in m/s.  
  Tp  = 52;                 % Thrust in Newtons
  mass= 339;                % Mass; kg
  len = 4.19/2;             % Length; meters  ????
  dia = 21*in2m;            % Diameter; meters
  xG  = 0;                  % Longitudinal CG offset, meters
  Decouple = 0;             % Decouple the Surge EOM from Sway/Yaw
  Ts = .2;                  % Control System sampling rate, sec.    
  Stall = 30*d2r;           % Stall angle of the strut; Deg -> rad.
  vel_C_N_N_x = 0;          % Vel of the Current (C) wrto an Earth-Fixed 
  vel_C_N_N_y = 1*kph2mps;  %% Newtonian frame (N), coord in the N frame.
  vel_C_N_N_y = 0*kph2mps;  % No cross current
  r_No_WP1_N_x = 500;       % Dist from Earth-Fixed origin to first way point
  r_No_WP1_N_y = .85;       % Heading of .1 deg = .0017*500
  r_No_WP1_N_y = 500;       % 45 Deg.
  r_No_WP1_N_y = 10;        % 

  xR  = -1.069;             % Distance from CG to rudder; m
  xPR = 0*in2m;             % Dist from the elevator pivot to the rudder pivot.
  xPcp= 0*in2m;             % Distance from pivot to ring CP in tailcone coords
  r_Ro_S1_R=[0 .012 -.1524]';% Dist from Ro to S1 in R,  m.
  r_Ro_S2_R=[0 -.1524   0 ]';% Dist from Ro to S2 in R,  m.
  r_Ro_S3_R=[0 .012  .1524]';% Dist from Ro to S3 in R,  m.
  r_Ro_S4_R=[0  .1524   0 ]';% Dist from Ro to S4 in R,  m.
  aR  = 2.50*in2m;          % Dist from c.l. to rudder actuator base
  rR1 = 1.00*in2m;          % See notes 99/4/20 p.13.  Values from Mark's 
  rR2 = 2.50*in2m;          % diagrams, p.16-17.                          
  xRR = 11.5*in2m;          % Center-hole to center-hole act. dist. in P.  zz
  maxDeltaR = pi/12;        % Max rudder deflection; 15 degrees.        
% maxDeltaRDot = 3*pi/180;  % Max tailcone deflection rate; 5 deg/sec.    
% deltaRDead = .01*in2m/rR2;% Rudder deadband; 10 "mils"; actu. & pin.    
% deltaRDead = maxDeltaRDot*Ts;% Max rudder displacement in one sample interval
  maxActDisp = 1*in2m*m2c;  % One inch max displacement; counts
  maxActRate = .5*in2m*m2c; % Max actuator rate; counts/sec.
  maxActDispTs = maxActRate*Ts;% Max actuator disp. in one sample interval
  iSB  =0;                  % Current to power stepper controller board.
%
  StrutArea  = 0.0299;      % Odyssey fin area; m^2
  ControlArea= StrutArea*2; % Total rudder area (m^2). 
  TotalArea  = StrutArea*2; % For drag calc in the Surge Eqn. 
%
% Hydrodynamic coefficients for Odyssey Fins:
%
  Ar  = 4.26;               % Aspect ratio
  Cdc = 0.723;              % Crossflow Cd
  Cd0 = 0.0065;             % Cd from NACA 0015 section; PNA p. 503, 2nd Ed.
  Ef  = 0.90;               % "Oswald" efficiency factor; PNA p. 503, 2nd Ed.
  dCl = 3.392;              % Lift coefficient slope 
%
% Hydrodynamic coefficients for Altex Ring
%
  ArR  = 4.26;              % Aspect ratio
  CdcR = 0.723;             % Crossflow Cd
  Cd0R = 0.0065;            % Cd from NACA 0015 section; PNA p. 503, 2nd Ed.
  EfR  = 0.90;              % "Oswald" efficiency factor; PNA p. 503, 2nd Ed.
  dClR = 3.392;             % Lift coefficient slope 
  RingArea = 0;             % Set to zero for Odyssey simulation
%
% Sim Parameters:
  tStop = 1*60;             % Stop time, sec
  Npts  = 600;              % Number of points; MUST be tStop/Ts for the 
                            % linear analysis (LinFlg=1) to match.
  Npts  = tStop/Ts;         % Number of points
%
% Open loop rudder commands:
  deltaR = 1*d2r;
  deltaR = 10*d2r;
  tdeltaR= 2;               % Rudder slew time
  tdur= 20;                 % Rudder slew time
%
% Control System:
  Kph = .7;                 % Unitless
  Krh = 2;                  % Sec; w/o integrator
  Kvh = 0;                  % sway rate feedback gain, rad/(meters/sec).
  MaxRate = .2 * Krh;       % Rad/sec
  Kwp = 0;                  % Rad/meter; should be > 0.
  Kwp = .05;                % Rad/meter; should be > 0.
  Kiwp= 0;                  % Rad/sec/meter; should be > 0. For integrator ver.
  Kiwp= .003;               % Rad/sec/meter; should be > 0. For integrator ver.
  WpMode = 0;               % 0=> Waypoint control; 1 => heading control; 
  Heading = .1*d2r;         % This is overridden if WpMode=0.
  WpMode = 0;               % 0=> Waypoint control; 1 => heading control; 
  Heading = 179*d2r;        % This is overridden if WpMode=0.
%
  if 1
%
% Gains from Acker:
%
%PP1 =  0.7683    0.9800    0.9800    0.9900    0.9900
%
  Kph = 0.814585;
  Krh = 2.051892;      
  Kvh = 0.078132;      
  Kwp = 0.061713;      
  Kiwp = 0.002108;    
%
  end

  ControlArea = StrutArea*2; % Equivalent rudder/elevator area (m^2). 
  Izz = 71.95;              % kg-m^2
  Ixx = 10.59;              % kg-m^2
  Nr  = -74.9;              % Deriv of N wrto r; kg-m^2/sec (*1/sec=Nm), L&J
  Nv  = -167.3;             % kg-m/sec
  Yr  = 112.6;              % kg-m/sec
  Yv  = -117.5;             % kg/sec
  Yvdot = -313.6;           % kg
  Nrdot = -50.7;            % kg-m^2
  Yvabsr = 0;               
  Yvabsv = -4930;           % Deriv of Y wrto v|v|; kg/m; sim.c
  Nrabsv = 0;               
  Nvabsv = 0;               % Deriv of N wrto v|v|; kg; sim.c
  Nrabsr = -150;            % Deriv of N wrto r|r|; kg-m^2; sim.c
