% ============================================================================
% InitLandingController.m
% Author: Brent Dingle, Ph.D.
% Creation Date: 2020
%
% Originally intent was to achieve a desired velocity after intial burn.
% This allowed for hovering at trajectory apex.
% Functions have now been altered to allow a height to be hovered at.
%
% ASSUMPTION: initial burn puts us ABOVE the desired hover height
%
% Additional background can be found at the end of this file 
% ============================================================================
function lander = InitLandingController(sim, rock)
% --- improved GetThrustForDescent
  lander.heightDesired = 0.0;    % m -> height that desired velocity will be 0

  lander.farDistance   = 25;     % m -> if we are greater than this distance what do we do?
  lander.farVelMax     = -30;    % m/s -> max velocity (to deactivate: choose > terminal vel?)
  lander.farVelTarget  = -10;    % m/s -> target velocity (to deactivate: choose terminal vel?)
  lander.farGain       = 1.9;    % how aggressively to get to farVelTarget
  lander.farCorrectionEnabled = false;
  
  lander.medDistance   = 15;     % m -> mostly in free fall until rocket is between medium and far distance
  lander.medVelocity   = -10;    % m/s -> desired velocity if between medium and far distance
  lander.medGain       = 2.0;    % how aggressively to get to medVelocity

  lander.shortDistance = 7;      % m
  lander.shortVelocity = -4;     % m/s -> desired velocity if between short and medium distance
  lander.shortGain     = 2.0;    % how aggressively to get to shortVelocity

  lander.smallDistance = 2;      % m
  lander.smallVelocity = -2;     % m/s -> desired velocity if between short and medium distance
  lander.smallGain     = 2.5;    % how aggressively to get to smallVelocity

  lander.hoverDistance = 0;      % m
  lander.hoverVelocity = 0;      % m/s -> desired velocity if between hover and short distance
  lander.hoverGain     = 3.0;    % how aggressively to get to hoverVelocity

  
endfunction