# Custom Variable Mass 6DOF ECEF (Quaternion)

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

• Library:
• Aerospace Blockset / Equations of Motion / 6DOF

## Description

The Custom Variable Mass 6DOF ECEF (Quaternion) block implements a quaternion representation of six-degrees-of-freedom equations of motion of custom variable mass in Earth-centered Earth-fixed (ECEF) coordinates. It considers the rotation of a 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 act 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-handed 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-handed system.

## Ports

### Input

expand all

Applied forces, specified as a three-element vector, in body axes.

Data Types: `double`

Applied moments, specified as a three-element vector, in body axes.

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`

Mass, specified as a scalar.

#### Dependencies

To enable this port, set Mass type to ```Custom Variable```.

Data Types: `double`

Rate of change of inertia tensor matrix, specified as a 3-by-3 matrix.

#### Dependencies

To enable this port, set Mass type to ```Custom Variable```.

Data Types: `double`

Inertia tensor matrix, specified as a 3-by-3 matrix.

#### Dependencies

To enable this port, set Mass type to ```Custom Variable```.

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`.

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 ECEF axes to NED axes, returned as a 3-by-3 matrix.

Data Types: `double`

Velocity of body with respect to ECEF 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 ECI 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 ECI 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 ECEF coordinate frame, returned as a three-element vector.

Data Types: `double`

Accelerations in body-fixed axes with respect to ECEF 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)`

Select the type of mass to use:

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 `Custom Variable` selection conforms to the previously described equations of motion.

#### Programmatic Use

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

Initial location of the aircraft 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]'`

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 Abe 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

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

#### 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 ECI frame, specified as a double scalar.

#### Dependencies

To enable this parameter, set Celestial longitude of Greenwich source to `Internal`.

#### Programmatic Use

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

### State Attributes

Assign a unique name to each state. Use state names instead of block paths throughout the linearization process.

• 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: `posECEF_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: `posECI_statename` Type: character vector Values: `''` | comma-separated list surrounded by braces Default: `''`

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

#### Programmatic Use

 Block Parameter: `LG_statename` Type: character vector Values: `''` | scalar Default: `''`

## Algorithms

The origin of the ECEF coordinate frame is the center of the Earth. In addition, 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)).

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 in body-fixed 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}$ 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

`$\begin{array}{l}{\overline{V}}_{b}=\left[\begin{array}{c}u\\ v\\ w\end{array}\right],{\overline{\omega }}_{rel}=\left[\begin{array}{c}p\\ q\\ r\end{array}\right],{\overline{\omega }}_{e}=\left[\begin{array}{c}0\\ 0\\ {\omega }_{e}\end{array}\right],{\overline{\omega }}_{b}={\overline{\omega }}_{rel}+DC{M}_{bf}{\overline{\omega }}_{e}+DC{M}_{be}{\overline{\omega }}_{ned}\\ {\overline{\omega }}_{ned}=\left[\begin{array}{c}\stackrel{˙}{l}\mathrm{cos}\mu \\ -\stackrel{˙}{\mu }\\ -\stackrel{˙}{l}\mathrm{sin}\mu \end{array}\right]=\left[\begin{array}{c}{V}_{E}/\left(N+h\right)\\ -{V}_{N}/\left(M+h\right)\\ -{V}_{E}•\mathrm{tan}\mu /\left(N+h\right)\end{array}\right]\end{array}$`

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 rate of change of the inertia tensor is defined by the following equation.

`$\stackrel{˙}{I}=\left[\begin{array}{ccc}{\stackrel{˙}{I}}_{xx}& -{\stackrel{˙}{I}}_{xy}& -{\stackrel{˙}{I}}_{xz}\\ -{\stackrel{˙}{I}}_{yx}& {\stackrel{˙}{I}}_{yy}& -{\stackrel{˙}{I}}_{yz}\\ -{\stackrel{˙}{I}}_{zx}& -{\stackrel{˙}{I}}_{zy}& {\stackrel{˙}{I}}_{zz}\end{array}\right]$`

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 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.

## Extended Capabilities

### C/C++ Code GenerationGenerate C and C++ code using Simulink® Coder™.

Introduced in R2006a

Get trial now