function dxdt = vppblock_StateFcn(x, u, wb)
%#codegen
% State equations for Vehicle Path Planner (VPP) block using multistage
% nonlinear mpc.
%
% state variables: x, y and yaw angle theta.
% control variables: speed v and steering angle delta.
%
% To customize the Vehicle Path Planner (VPP) block, specify a state
% function for the nonlinear mpc object (nlobj). For example:
%
%       dxdt = myStateFcn(x, u, p)
%       nlobj.Model.StateFcn = "myStateFcn";
%
% To use different vehicle dynamics, specify the dynamics in the state
% function.
%
% see also: vppblock_CreateNonlinearMPC

% Copyright 2022 The MathWorks, Inc.

%%
% Variables
theta = x(3);
v = u(1);
delta = u(2);

% State equations
dxdt = zeros(3,1);
dxdt(1) = v*cos(theta);
dxdt(2) = v*sin(theta);
dxdt(3) = v/wb*tan(delta);
