function dx=TECFunc_vmodel_bicycle_openloop_cor(t,x,u,err)
% vmodel_bicycle_openloop_cor - UnCoVerCPS open loop vehicle model with absolute coordinates
% For more information, please contact: Daniel.Hess@DLR.de
%x = [Xr,Yr,PSI,vx,vyr,dPSI], state: contains Position/Velocities of COG
%u,err = [ax,delta],[e_ax,e_fyf,e_fyr], control and error inputs


    %parameters: p.47, tab. 5
    [~, Iz_m, L, b_L, ~, cf, cr, h, g, mu, ~, ~, ~, ~, ~] = TECFunc_VehicleParameters();
    b = b_L*L;
    a = (1-b_L)*L;


    % velocities
    vx    = x(4);
    vy    = x(5) + b*x(6);
    omega = x(6);

    % slipangles
    alpha_f = atan( (vy + a * omega) / vx) - u(2);	
    alpha_r = atan( (vy - b * omega) / vx);

    % vehicle model
    ax      = u(1) 			     					    + err(1);
    Fyf_Fzf = cos(u(2)) * mu * (b/L*g-h/L*0)*cf*alpha_f + err(2); % tire load independent from acceleration 
    Fyr_Fzr = mu * (a/L*g+h/L*0)*cr*alpha_r             + err(3); % tire load independent from acceleration 
    ay      = Fyf_Fzf + Fyr_Fzr;
    domega  = ( a*Fyf_Fzf - b*Fyr_Fzr ) / Iz_m;


    %state derivative
    dx    = x; %same size and type
    %integrator chain/position
    dx(1) = cos(x(3))*x(4) - sin(x(3))*x(5);
    dx(2) = sin(x(3))*x(4) + cos(x(3))*x(5);
    dx(3) = x(6);
    %input level
    dx(4) = ax;  
    dx(5) = ay - vx*omega - b*domega;
    dx(6) = domega;
end

