function [xdot,U] = container(x,ui

)
% [xdot,U] = container(x,ui) returns the speed U in m/s (optionally) and the
% time derivative of the state vector: x = [ u v r x y psi p phi delta n ]'
for
% a container ship L = 175 m, where
%
% u
= surge velocity
(m/s)
% v
= sway velocity
(m/s)
% r
= yaw velocity
(rad/s)
% x
= position in x-direction (m)
% y
= position in y-direction (m)
% psi
= yaw angle
(rad)
% p
= roll velocity
(rad/s)
% phi
= roll angle
(rad)
% delta = actual rudder angle
(rad)
% n
= actual shaft velocity
(rpm)
%
% The input vector is :
%
% ui
= [ delta_c n_c ]' where
%
% delta_c = commanded rudder angle
(rad)
% n_c
= commanded shaft velocity (rpm)
%
% Reference: Son og Nomoto (1982). On the Coupled Motion of Steering and
%
Rolling of a High Speed Container Ship, Naval Architect of Ocean
Engineering,
%
20: 73-83. From J.S.N.A. , Japan, Vol. 150, 1981.
%
% Author:
Trygve Lauvdal
% Date:
12th May 1994
% Revisions: 18th July 2001 (Thor I. Fossen): added output U, changed order of
x-vector
%
20th July 2001 (Thor I. Fossen): changed my = 0.000238 to my =
0.007049
% ________________________________________________________________
%
% MSS GNC is a Matlab toolbox for guidance, navigation and control.
% The toolbox is part of the Marine Systems Simulator (MSS).
%
% Copyright (C) 2008 Thor I. Fossen and Tristan Perez
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% E-mail: contact@marinecontrol.org
% URL:
<http://www.marinecontrol.org>

0000075. Iz = Jx = 0.0000034.00003569.05. x(9).007049.0000176. % length of ship (m) % service speed (m/s) % Check service speed if U <= 0.0000793. 21222.end if (length(ui) ~= 2).009325.0004226. = -0. Yr Yvvv Yvrr Yrrphi = 0.81. = -0. U = sqrt(x(1)^2 + x(2)^2). 0.0001424.00.end % Normalization variables L = 175.end delta_max = 10.39.0313.0000176. 33. = -0.8219.error('The ship must have speed greater than zero'). 0. 8.0010565.3/L.00792. = 0. 9. = 0. Yp Yrrr Yvvphi Yrphiphi = 0. = -0.0116.40. u p phi delta = = = = x(1)/U.000238. = -0. = -0. Nr Nvvv = -0.00242. = -0.0000462. .000456. 1.error('u-vector must have dimension 2 !').0405.00. = 0. = -0. Kv Kphi Kvvr Kvphiphi = 0. Jz = 0.00177.00311.109. = -0. Kr Kvvv Kvrr Krrphi = -0. Nv Nphi = -0. lx = ly = 0. x(7)*L/U. 9. mx = 0.002843. alphay = 0. Yv Yphi Yvvr Yvphiphi = -0.00222. x(10)/60*L/U.0376.000243. v r psi n = = = = x(2)/U.00304. % max rudder angle (deg) % max rudder rate (deg/s) % max shaft velocity (rpm) % Non-dimensional states and inputs delta_c = ui(1).000021. Ix = 0. 0.0012012. x(3)*L/U.04605. n_max = 160.175.00386.% Check of input and state dimensions if (length(x) ~= 10). x(8). = -0. Xuu Xphiphi = -0. xG = B dA KM Delta rho = = = = = 25. my = Ix = 0. n_c = ui(2)/60*L/U. 0. = 0. = -0.0005.00020.001492. 0. 1025. = 0. 6.0313. 10.50.000213. g nabla AR GM T W = rho*g*nabla/(rho*L^2*U^2/2). hydrodynamic derivatives and m = 0. = 0. x(6).00229. = 0.000419.error('x-vector must have dimension 10 !').000588. = = = = = main dimensions 0.00020. % Parameters. Kp Krrr Kvvphi Krphiphi = -0.6154.0214.000063. 4.0003026. Xrr = 0. Ddelta_max = 5. Xvr Xvv = -0.001368.000063.0038545.end if x(10) <= 0.error('The propeller rpm must be greater than zero'). Np Nrrr = 0. = -0. dF d KB D t = = = = = 8. = -0. = 0.533. 0. = 0. = -0.

= 0.5.96. J = uP*U/(n*D).0024195.65/n.48..0. cRX*FN*sin(delta) + (m + my)*v*r. if abs(delta_dot) >= Ddelta_max*pi/180.921. = 0. m22 = (m+my). xR xp ga cRrrv zR Nvvphi = -0.0424.527 .((6. % Masses and moments of inertia m11 = (m+mx). = 0. Nvphiphi = -0. m44 = (Iz+Jz).184. uR = uP*epsilon*sqrt(1 + 8*kk*KT/(pi*J^2))..Tm=5. delta_dot = sign(delta_dot)*Ddelta_max*pi/180. Nrphiphi = 0.033.delta. T = 2*rho*D^4/(U^2*L^2*rho)*KT*n*abs(n). KT = 0. Nrrphi = -0. = -0.25))*(AR/L^2)*(uR^2 + vR^2)*sin(alphaR).526.00156.0..13*Delta)/(Delta + 2..237. % Rudder saturation and dynamics if abs(delta_c) >= delta_max*pi/180. if abs(n_c) >= n_max/60. = 0.088..else. uP = cos(v)*((1 . end delta_dot = delta_c .156.Tm=18. = Yv*v + Yr*r + Yp*p + Yphi*phi + Yvvv*v^3 + Yrrr*r^3 + Yvvr*v^2*r + Yvrr*v*r^2 + Yvvphi*v^2*phi + Yvphiphi*v*phi^2 + Yrrphi*r^2*phi + . = 0. FN = .83. n_c = sign(n_c)*n_max/60. = -0. end if n > 0. delta_c = sign(delta_c)*delta_max*pi/180.0038592.end n_dot = 1/Tm*(n_c-n)*60. alphaR = delta + atan(vR/uR). Nvrr = 0.631. % Calculation of state derivatives vR = ga*v + cRr*r + cRrrr*r^3 + cRrrv*r^2*v. .0.275.0053766. = 1. = -0.09. m42 = my*alphay. n = n*U/L.Nvvr = -0. Y .wp) + tau*((v + xp*r)^2 + cpv*v + cpr*r)). = -0. kk wp cpv cRr cRX xH = 0. m32 = -my*ly.3. = 0. end % Shaft velocity saturation and dynamics n_c = n_c*U/L.71. epsilon tau cpr cRrrr aH = 0. = 0. = -0. % Forces and moments X = Xuu*u^2 + (1-t)*T + Xvr*v*r + Xvv*v^2 + Xrr*r^2 + Xphiphi*phi^2 + .455*J.019058. m33 = (Ix+Jx). = 1..

. % Dimensional state derivatives xdot = [ u v r x y psi p phi delta n ]' detM = m22*m33*m44-m32^2*m44-m42^2*m33... = Nv*v + Nr*r + Np*p + Nphi*phi + Nvvv*v^3 + Nrrr*r^3 + Nvvr*v^2*r + Kvrr*v*r^2 + Kvvphi*v^2*phi + Kvphiphi*v*phi^2 + Krrphi*r^2*phi + .. = Kv*v + Kr*r + Kp*p + Kphi*phi + Kvvv*v^3 + Krrr*r^3 + Kvvr*v^2*r + N .. .. Nvrr*v*r^2 + Nvvphi*v^2*phi + Nvphiphi*v*phi^2 + Nrrphi*r^2*phi + .W*GM*phi..(1 + aH)*zR*FN*cos(delta) + mx*lx*u*r .. K . xdot =[ X*(U^2/L)/m11 -((-m33*m44*Y+m32*m44*K+m42*m33*N)/detM)*(U^2/L) ((-m42*m33*Y+m32*m42*K+N*m22*m33-N*m32^2)/detM)*(U^2/L^2) (cos(psi)*u-sin(psi)*cos(phi)*v)*U (sin(psi)*u+cos(psi)*cos(phi)*v)*U cos(phi)*r*(U/L) ((-m32*m44*Y+K*m22*m44-K*m42^2+m32*m42*N)/detM)*(U^2/L^2) p*(U/L) delta_dot n_dot ]. Nrphiphi*r*phi^2 + (xR + aH*xH)*FN*cos(delta).Yrphiphi*r*phi^2 + (1 + aH)*FN*cos(delta) . Krphiphi*r*phi^2 .(m + mx)*u*r.