Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

accelerationConstraints.m 1.13 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 41 42 43 44 45 46 47
function acceleration = accelerationConstraints(velocity,acceleration,p)
% accelerationConstraints - adjusts the acceleration based on acceleration
% constraints
%
% Syntax:  
%    acceleration = accelerationConstraints(velocity,acceleration,p)
%
% Inputs:
%    acceleration - acceleration in driving direction
%    velocity - velocity in driving direction
%    p - longitudinal parameter structure
%
% Outputs:
%    acceleration - acceleration in driving direction
%
% 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 --------------

%positive acceleration limit
if velocity>p.v_switch
    posLimit = p.a_max*p.v_switch/velocity;
else
    posLimit = p.a_max;
end

%acceleration limit reached?
if (velocity<=p.v_min && acceleration<=0) || (velocity>=p.v_max && acceleration>=0)
    acceleration = 0;
elseif acceleration<=-p.a_max
    acceleration = -p.a_max;
elseif acceleration>=posLimit
    acceleration = posLimit; 
end

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