%% Control Vehicle Velocity
% This model uses a
% <docid:driving_ref#mw_96bd4718-f217-425b-93c1-4989f270f415 Longitudinal
% Controller Stanley> block to control the velocity of a vehicle in forward
% motion. In this model, the vehicle accelerates from 0 to 10 meters per
% second.
%
% The Longitudinal Controller Stanley block is a discrete
% proportional-integral controller with integral anti-windup. Given the
% current velocity and driving direction of a vehicle, the block outputs
% the acceleration and deceleration commands needed to match the specified
% reference velocity.
%
open_system('ControlVehicleVelocity')
%%
% Run the model. Then, open the scope to see the change in velocity and the
% corresponding acceleration and deceleration commands.
%
sim('ControlVehicleVelocity')
open_system('ControlVehicleVelocity/Scope')
%%
% The Longitudinal Controller Stanley block saturates the acceleration
% command at a maximum value of 3 meters per second. The *Maximum
% longitudinal acceleration (m/s^2)* parameter of the block determines this
% maximum value. Try tuning this parameter and resimulating the model.
% Observe the effects of the change on the scope. Other parameters that you
% can tune include the gain coefficients of the proportional and integral
% components of the block, using the *Proportional gain, Kp* and *Integral
% gain, Ki* parameters, respectively.
%
close_system('ControlVehicleVelocity')
%%
% Copyright 2018 The MathWorks, Inc.