# Simple Variable Mass 6DOF ECEF (Quaternion)

Implement quaternion representation of six-degrees-of-freedom equations of motion of simple variable mass in Earth-centered Earth-fixed (ECEF) coordinates

Libraries:
Aerospace Blockset / Equations of Motion / 6DOF

## Description

The Simple Variable Mass 6DOF ECEF (Quaternion) block implements a quaternion representation of six-degrees-of-freedom equations of motion of simple variable mass in Earth-centered Earth-fixed (ECEF) coordinates. It considers the rotation of an Earth-centered Earth-fixed (ECEF) coordinate frame (XECEF, YECEF, ZECEF) about an Earth-centered inertial (ECI) reference frame (XECI, YECI, ZECI). The origin of the ECEF coordinate frame is the center of the Earth. For more information on the ECEF coordinate frame, see Algorithms.

Aerospace Blockset™ uses quaternions that are defined using the scalar-first convention.

## Limitations

• This implementation assumes that the applied forces are acting at the center of gravity of the body.

• This implementation generates a geodetic latitude that lies between ±90 degrees, and longitude that lies between ±180 degrees. Additionally, the MSL altitude is approximate.

• The Earth is assumed to be ellipsoidal. By setting flattening to 0.0, a spherical planet can be achieved. The Earth's precession, nutation, and polar motion are neglected. The celestial longitude of Greenwich is Greenwich Mean Sidereal Time (GMST) and provides a rough approximation to the sidereal time.

• The implementation of the ECEF coordinate system assumes that the origin is at the center of the planet, the x-axis intersects the Greenwich meridian and the equator, the z-axis is the mean spin axis of the planet, positive to the north, and the y-axis completes the right-hand system.

• The implementation of the ECI coordinate system assumes that the origin is at the center of the planet, the x-axis is the continuation of the line from the center of the Earth toward the vernal equinox, the z-axis points in the direction of the mean equatorial plane's north pole, positive to the north, and the y-axis completes the right-hand system.

## Ports

### Input

expand all

Applied forces, specified as a three-element vector.

Data Types: double

Applied moments, specified as a three-element vector.

Data Types: double

One or more rates of change of mass (positive if accreted, negative if ablated), specified as a three-element vector.

Data Types: double

Greenwich meridian initial celestial longitude angle, specified as a scalar.

#### Dependencies

To enable this port

• Set Celestial longitude of Greenwich to External.

• set Planet model to Earth.

Data Types: double

Prime meridian initial celestial longitude angle, specified as a scalar.

#### Dependencies

To enable this port

• Set Celestial longitude of prime meridian to External.

• Set Planet model to Custom.

Data Types: double

One or more relative velocities at which the mass is accreted to or ablated from the body in body-fixed axes, specified as a three-element vector.

#### Dependencies

To enable this port, select Include mass flow relative velocity.

Data Types: double

### Output

expand all

Velocity of body with respect to ECEF frame, expressed in ECEF frame, returned as a three-element vector.

Data Types: double

Position in ECEF reference frame, returned as a three-element vector.

Data Types: double

Position in geodetic latitude, longitude, and altitude, in degrees, returned as a three-element vector or M-by-3 array, in selected units of length, respectively.

Data Types: double

Body rotation angles [roll, pitch, yaw], returned as a three-element vector, in radians. Euler rotation angles are those between body and NED coordinate systems.

Data Types: double

Coordinate transformation from ECI axes to body-fixed axes, returned as a 3-by-3 matrix.

Data Types: double

Coordinate transformation from NED axes to body-fixed axes, returned as a 3-by-3 matrix.

Data Types: double

Coordinate transformation from fixed-frame axes to NED axes, returned as a 3-by-3 matrix.

Data Types: double

Velocity of body with respect to fixed-frame, returned as a three-element vector.

Data Types: double

Relative angular rates of body with respect to NED frame, expressed in body frame and returned as a three-element vector, in radians per second.

Data Types: double

Angular rates of the body with respect to inertial frame, expressed in body frame and returned as a three-element vector, in radians per second.

Data Types: double

Angular accelerations of the body with respect to inertial frame, expressed in body frame and returned as a three-element vector, in radians per second squared.

Data Types: double

Accelerations of the body with respect to the body-fixed axes with the body-fixed coordinate frame, returned as a three-element vector.

Data Types: double

Fuel tank status, returned as:

• 1 — Tank is full.

• 0 — Tank is neither full nor empty.

• -1 — Tank is empty.

Data Types: double

Accelerations in body-fixed axes with respect to fixed-frame, returned as a three-element vector.

#### Dependencies

To enable this point, Include inertial acceleration.

Data Types: double

## Parameters

expand all

### Main

Input and output units, specified as Metric (MKS), English (Velocity in ft/s), or English (Velocity in kts).

UnitsForcesMomentAccelerationVelocityPositionMassInertia
Metric (MKS) NewtonNewton-meterMeters per second squaredMeters per secondMetersKilogramKilogram meter squared
English (Velocity in ft/s) PoundFoot-poundFeet per second squaredFeet per secondFeetSlugSlug foot squared
English (Velocity in kts) PoundFoot-poundFeet per second squaredKnotsFeetSlugSlug foot squared

#### Programmatic Use

 Block Parameter: units Type: character vector Values: Metric (MKS) | English (Velocity in ft/s) | English (Velocity in kts) Default: Metric (MKS)

Mass type, specified according to the following table.

Mass TypeDescriptionDefault For
Fixed

Mass is constant throughout the simulation.

Simple Variable

Mass and inertia vary linearly as a function of mass rate.

Custom Variable

Mass and inertia variations are customizable.

The Simple Variable selection conforms to the equations of motion in Algorithms.

#### Programmatic Use

 Block Parameter: mtype Type: character vector Values: Fixed | Simple Variable | Custom Variable Default: Simple Variable

Initial location of the rigid body in the geodetic reference frame, specified as a three-element vector. Latitude and longitude values can be any value. However, latitude values of +90 and -90 may return unexpected values because of singularity at the poles.

#### Programmatic Use

 Block Parameter: xg_0 Type: character vector Values: '[0 0 0]' | three-element vector Default: '[0 0 0]'

Initial velocity of the body with respect to the ECEF frame, expressed in the body frame, specified as a three-element vector.

#### Programmatic Use

 Block Parameter: Vm_0 Type: character vector Values: '[0 0 0]' | three-element vector Default: '[0 0 0]'

Initial Euler orientation angles [roll, pitch, yaw], specified as a three-element vector, in radians. Euler rotation angles are those between the body and north-east-down (NED) coordinate systems.

#### Programmatic Use

 Block Parameter: eul_0 Type: character vector Values: '[0 0 0]' | three-element vector Default: '[0 0 0]'

Initial body-fixed angular rates with respect to the NED frame, specified as a three-element vector, in radians per second.

#### Programmatic Use

 Block Parameter: pm_0 Type: character vector Values: '[0 0 0]' | three-element vector Default: '[0 0 0]'

Initial mass of the rigid body, specified as a double scalar.

#### Programmatic Use

 Block Parameter: mass_0 Type: character vector Values: '1.0' | double scalar Default: '1.0'

Empty mass of the body, specified as a double scalar.

#### Programmatic Use

 Block Parameter: mass_e Type: character vector Values: double scalar Default: '0.5'

Full mass of the body, specified as a double scalar.

#### Programmatic Use

 Block Parameter: mass_f Type: character vector Values: double scalar Default: '2.0'

Inertia tensor matrix for the empty inertia of the body, specified as 3-by-3 matrix.

#### Programmatic Use

 Block Parameter: inertia_e Type: character vector Values: 'eye(3)' | 3-by-3 matrix Default: 'eye(3)'

Inertia tensor matrix for the full inertia of the body, specified as 3-by-3 matrix.

#### Programmatic Use

 Block Parameter: inertia_f Type: character vector Values: '2*eye(3)' | 3-by-3 matrix Default: '2*eye(3)'

Select this check box to add a mass flow relative velocity port. This is the relative velocity at which the mass is accreted or ablated.

#### Programmatic Use

 Block Parameter: vre_flag Type: character vector Values: off | on Default: off

Select this check box to add an inertial acceleration port.

#### Dependencies

To enable the Ab ff port, select this parameter.

#### Programmatic Use

 Block Parameter: abi_flag Type: character vector Values: 'off' | 'on' Default: off

### Planet

Planet model to use, Custom or Earth (WGS84).

#### Programmatic Use

 Block Parameter: ptype Type: character vector Values: 'Earth (WGS84)' | 'Custom' Default: 'Earth (WGS84)'

Radius of the planet at its equator, specified as a double scalar, in the same units as the desired units for the ECEF position.

#### Dependencies

To enable this parameter, set Planet model to Custom.

#### Programmatic Use

 Block Parameter: R Type: character vector Values: double scalar Default: '6378137'

Flattening of the planet, specified as a double scalar.

#### Dependencies

To enable this parameter, set Planet model to Custom.

#### Programmatic Use

 Block Parameter: F Type: character vector Values: double scalar Default: '1/298.257223563'

Rotational rate of the planet, specified as a scalar, in rad/s.

#### Dependencies

To enable this parameter, set Planet model to Custom.

#### Programmatic Use

 Block Parameter: w_E Type: character vector Values: double scalar Default: '7292115e-11'

Source of Greenwich meridian initial celestial longitude, specified as:

 Internal Use celestial longitude value from Celestial longitude of Greenwich. External Use external input for celestial longitude value.

#### Dependencies

• To enable this parameter, set Planet model to Earth.

• Setting this parameter to External enables the LG(0) port.

• If Planet model is set to Custom, the parameter name changes to Celestial longitude of prime meridian source.

#### Programmatic Use

 Block Parameter: angle_in Type: character vector Values: 'Internal' | 'External' Default: 'Internal'

Initial angle between Greenwich meridian and the x-axis of the inertial frame, specified as a double scalar.

#### Dependencies

• To enable this parameter, set:

• Celestial longitude of Greenwich source to Internal.

• Planet model to Earth (WGS84).

• If Planet model is set to Custom, the parameter name changes to Celestial longitude of prime meridian [deg].

#### Programmatic Use

 Block Parameter: LPM0 Type: character vector Values: double scalar Default: '0'

Source of prime meridian initial celestial longitude, specified as:

 Internal Use celestial longitude value from Celestial longitude of prime meridian. External Use external input for celestial longitude value.

#### Dependencies

• To enable this parameter, set Planet model to Custom.

• Setting this parameter to External enables the LPM(0) port.

• If Planet model is set to Earth (WGS84), the parameter name changes to Celestial longitude of Greenwich source.

#### Programmatic Use

 Block Parameter: angle_in Type: character vector Values: 'Internal' | 'External' Default: 'Internal'

Initial angle between prime meridian and the x-axis of the ECI frame, specified as a double scalar.

#### Dependencies

• To enable this parameter, set:

• Celestial longitude of prime meridian source to Internal.

• Planet model to Custom.

• If Planet model is set to Earth (WGS84), the parameter name changes to Celestial longitude of Greenwich [deg].

#### Programmatic Use

 Block Parameter: LPM0 Type: character vector Values: double scalar Default: '0'

### State Attributes

Assign a unique name to each state. You can use state names instead of block paths during linearization.

• To assign a name to a single state, enter a unique name between quotes, for example, 'velocity'.

• To assign names to multiple states, enter a comma-separated list surrounded by braces, for example, {'a', 'b', 'c'}. Each name must be unique.

• If a parameter is empty (' '), no name is assigned.

• The state names apply only to the selected block with the name parameter.

• The number of states must divide evenly among the number of state names.

• You can specify fewer names than states, but you cannot specify more names than states.

For example, you can specify two names in a system with four states. The first name applies to the first two states and the second name to the last two states.

• To assign state names with a variable in the MATLAB® workspace, enter the variable without quotes. A variable can be a character vector, cell array, or structure.

Quaternion vector state names, specified as a comma-separated list surrounded by braces.

#### Programmatic Use

 Block Parameter: quat_statename Type: character vector Values: '' | comma-separated list surrounded by braces Default: ''

Body rotation rate state names, specified comma-separated list surrounded by braces.

#### Programmatic Use

 Block Parameter: pm_statename Type: character vector Values: '' | comma-separated list surrounded by braces Default: ''

Velocity state names, specified as comma-separated list surrounded by braces.

#### Programmatic Use

 Block Parameter: Vm_statename Type: character vector Values: '' | comma-separated list surrounded by braces Default: ''

ECEF position state names, specified as a comma-separated list surrounded by braces.

#### Programmatic Use

 Block Parameter: posfixedframe_statename Type: character vector Values: '' | comma-separated list surrounded by braces Default: ''

Inertial position state names, specified as a comma-separated list surrounded by braces.

Default value is ''.

#### Programmatic Use

 Block Parameter: posinertial_statename Type: character vector Values: '' | comma-separated list surrounded by braces Default: ''

Celestial longitude of Greenwich state name, specified as a character vector.

#### Dependencies

• To enable this parameter, set:Planet model to Earth (WGS84).

• If Planet model is set to Custom, the parameter name changes to Celestial longitude of prime meridian: e.g., 'LPM'.

#### Programmatic Use

 Block Parameter: LPM_statename Type: character vector Values: '' | scalar Default: ''

Celestial longitude of prime meridian state name, specified as a character vector.

#### Dependencies

• To enable this parameter, set:Planet model to Custom.

• If Planet model is set to Earth (WGS84), the parameter name changes to Celestial longitude of Greenwich: e.g., 'LG'.

#### Programmatic Use

 Block Parameter: LPM_statename Type: character vector Values: '' | scalar Default: ''

Mass state name, specified as a character vector.

#### Programmatic Use

 Block Parameter: mass_statename Type: character vector Values: '' | character vector Default: ''

## Algorithms

The origin of the ECEF coordinate frame is the center of the Earth. The body of interest is assumed to be rigid, an assumption that eliminates the need to consider the forces acting between individual elements of mass. The representation of the rotation of ECEF frame from ECI frame is simplified to consider only the constant rotation of the ellipsoid Earth (ωe) including an initial celestial longitude (LG(0)). This excellent approximation allows the forces due to the Earth complex motion relative to the fixed stars to be neglected.

The translational motion of the ECEF coordinate frame is given below, where the applied forces [Fx Fy Fz]T are in the body frame. Vreb is the relative velocity in the wind axes at which the mass flow ($\stackrel{˙}{m}$) is ejected or added to the body axes.

$\begin{array}{c}{\overline{F}}_{b}=\left[\begin{array}{c}{F}_{x}\\ {F}_{y}\\ {F}_{z}\end{array}\right]=m\left({\stackrel{˙}{\overline{V}}}_{b}+{\overline{\omega }}_{b}×{\overline{V}}_{b}+DC{M}_{bf}{\overline{\omega }}_{e}×{\overline{V}}_{b}+DC{M}_{bf}\left({\overline{\omega }}_{e}×\left({\overline{\omega }}_{e}×{\overline{X}}_{f}\right)\right)\right)\\ -\stackrel{˙}{m}\left(\overline{V}r{e}_{b}-DC{M}_{bf}\left({\overline{\omega }}_{e}×{\overline{X}}_{f}\right)\right)\\ \\ {A}_{bb}=\left[\begin{array}{c}{\stackrel{˙}{u}}_{b}\\ {\stackrel{˙}{v}}_{b}\\ {\stackrel{˙}{w}}_{b}\end{array}\right]=\frac{{\overline{F}}_{b}+\stackrel{˙}{m}\left({\overline{V}}_{r{e}_{b}}-DC{M}_{bf}\left({w}_{e}×{X}_{f}\right)\right)}{m}\\ -\left[{\overline{\omega }}_{{}_{b}}×{\overline{V}}_{b}+DCM{\overline{\omega }}_{e}×{\overline{V}}_{b}+DC{M}_{bf}\left({\overline{\omega }}_{e}\left({\overline{\omega }}_{e}×{X}_{f}\right)\right)\right]\\ \\ {A}_{b}{\text{​}}_{ecef}=\frac{{\overline{F}}_{b}+\stackrel{˙}{m}\left({\overline{V}}_{r{e}_{b}}-DC{M}_{bf}\left({\omega }_{e}×{X}_{f}\right)\right)}{m}\end{array}$

where the change of position in ECEF ${\stackrel{˙}{\overline{x}}}_{f}\left({\stackrel{˙}{\overline{x}}}_{i}\right)$ is calculated by

${\stackrel{˙}{\overline{x}}}_{f}=DC{M}_{fb}{\overline{V}}_{b}$

and the velocity of the body with respect to ECEF frame, expressed in body frame $\left({\overline{V}}_{b}\right)$, angular rates of the body with respect to ECI frame, expressed in body frame $\left({\overline{\omega }}_{b}\right)$. Earth rotation rate $\left({\overline{\omega }}_{e}\right)$, and relative angular rates of the body with respect to north-east-down (NED) frame, expressed in body frame $\left({\overline{\omega }}_{rel}\right)$ are defined as

The rotational dynamics of the body defined in body-fixed frame are given below, where the applied moments are [L M N]T, and the inertia tensor I is with respect to the origin O.

$\begin{array}{l}{\overline{M}}_{b}=\left[\begin{array}{c}L\\ M\\ N\end{array}\right]=\overline{I}{\stackrel{˙}{\overline{\omega }}}_{b}+{\overline{\omega }}_{b}×\left(\overline{I}{\overline{\omega }}_{b}\right)+\stackrel{˙}{I}{\overline{\omega }}_{b}\\ \\ I=\left[\begin{array}{ccc}{I}_{xx}& -{I}_{xy}& -{I}_{xz}\\ -{I}_{yx}& {I}_{yy}& -{I}_{yz}\\ -{I}_{zx}& -{I}_{zy}& {I}_{zz}\end{array}\right]\end{array}$

The inertia tensor is determined using a table lookup which linearly interpolates between Ifull and Iempty based on mass (m). The rate of change of the inertia tensor is estimated by the following equation.

$\stackrel{˙}{I}=\frac{{I}_{full}-{I}_{empty}}{{m}_{full}-{m}_{empty}}\stackrel{˙}{m}$

The integration of the rate of change of the quaternion vector is given below.

$\left[\begin{array}{c}{\stackrel{˙}{q}}_{0}\\ {\stackrel{˙}{q}}_{1}\\ {\stackrel{˙}{q}}_{2}\\ {\stackrel{˙}{q}}_{3}\end{array}\right]=-1}{2}\left[\begin{array}{cccc}0& {\omega }_{b}\left(1\right)& {\omega }_{b}\left(2\right)& {\omega }_{b}\left(3\right)\\ -{\omega }_{b}\left(1\right)& 0& -{\omega }_{b}\left(3\right)& {\omega }_{b}\left(2\right)\\ -{\omega }_{b}\left(2\right)& {\omega }_{b}\left(3\right)& 0& -{\omega }_{b}\left(1\right)\\ -{\omega }_{b}\left(3\right)& -{\omega }_{b}\left(2\right)& {\omega }_{b}\left(1\right)& 0\end{array}\right]\left[\begin{array}{c}{q}_{0}\\ {q}_{1}\\ {q}_{2}\\ {q}_{3}\end{array}\right]$

## References

[1] Stevens, Brian, and Frank Lewis. Aircraft Control and Simulation, 2nd ed. Hoboken, NJ: John Wiley & Sons, 2003.

[2] McFarland, Richard E. "A Standard Kinematic Model for Flight simulation at NASA-Ames" NASA CR-2497.

[3] "Supplement to Department of Defense World Geodetic System 1984 Technical Report: Part I - Methods, Techniques and Data Used in WGS84 Development." DMA TR8350.2-A.

## Version History

Introduced in R2006a

expand all