24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

steeringConstraints.m 1.01 KB
Newer Older
Markus Koschi's avatar
Markus Koschi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
function steeringVelocity = steeringConstraints(steeringAngle,steeringVelocity,p)
% steeringConstraints - adjusts the steering velocity based on steering
% constraints
%
% Syntax:  
%    steeringVelocity = steeringConstraints(steeringAngle,steeringVelocity,p)
%
% Inputs:
%    steeringAngle - steering angle
%    steeringVelocity - steering velocity
%    p - steering parameter structure
%
% Outputs:
%    steeringVelocity - steering velocity
%
% Example: 
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also: ---

% Author:       Matthias Althoff
% Written:      15-December-2017
% Last update:  ---
% Last revision:---

%------------- BEGIN CODE --------------

%steering limit reached?
if (steeringAngle<=p.min && steeringVelocity<=0) || (steeringAngle>=p.max && steeringVelocity>=0)
    steeringVelocity = 0;
elseif steeringVelocity<=p.v_min
    steeringVelocity = p.v_min;
elseif steeringVelocity>=p.v_max
    steeringVelocity = p.v_max; 
end

%------------- END OF CODE --------------