04.06., 9:00 - 12:00: GitLab will be migrated to a new server environment and upgraded to Enterprise Edition Ultimate. The estimated downtime will be 2-3 hours. Please see https://doku.lrz.de/display/PUBLIC/GitLab+Ultimate+Migration for more details about changes related to the migration.

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 --------------