Fixed Mass 6dof Motion
Fixed Mass 6dof Motion
Fixed Mass 6dof Motion
if nargin < 5
('.error('Less than the minimum 5 inputs
elseif nargin > 9
('.error('More than maximum 9 inputs
else
switch nargin
case 5
;[Ipos_i = [0 0 0
;[Ivel_b = [0 0 0
;[Irates_b = [0 0 0
;[Ieuler = [0 0 0
case 6
;{Ipos_i = varargin{1
;[Ivel_b = [0 0 0
;[Irates_b = [0 0 0
;[Ieuler = [0 0 0
case 7
;{Ipos_i = varargin{1
;{Ivel_b = varargin{2
;[Irates_b = [0 0 0
;[Ieuler = [0 0 0
case 8
;{Ipos_i = varargin{1
;{Ivel_b = varargin{2
;{Irates_b = varargin{3
;[Ieuler = [0 0 0
case 9
;{Ipos_i = varargin{1
;{Ivel_b = varargin{2
;{Irates_b = varargin{3
;{Ieuler = varargin{4
convert Ipos_i into body coordinates %
;((cph = cos(Ieuler(1
;((sph = sin(Ieuler(1
;((cth = cos(Ieuler(2
;((sth = sin(Ieuler(2
;((cps = cos(Ieuler(3
;((sps = sin(Ieuler(3
if Mass <= 0
('.error('Mass should be a positive non-zero value
else
;[y0 = [Irates_b Ivel_b Ipos_i
options = odeset('MaxStep',1/50); % set max step size to Simulink's
;(t,y] = ode45(@f,tarray,y0,options,Forces,Mass,Moments,Inertia]
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%
(function dydt = f(t,y,Forces,Mass,Moments,Inertia
dydt(1:3) = rates_dot %
dydt(4:6) = accel %
dydt(7:9) = vel %
y(1:3) = rates %
y(4:6) = vel %
y(7:9) = pos %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%