# cvmeasmsc

Measurement based on constant velocity (CV) model in MSC frame

## Syntax

## Description

provides the angular measurement (azimuth and elevation) of the state in the sensor frame
described by the `measurement`

= cvmeasmsc(`state`

)`state`

.

Tracking filters require a definition of the `MeasurementFcn`

property. The `cvmeasmsc`

function can be used as the
`MeasurementFcn`

. To use this `MeasurementFcn`

with
`trackerGNN`

and
`trackerTOMHT`

, you
can use the `trackingMSCEKF`

filter.

provides the measurement in the frame specified. The allowed values for
`measurement`

= cvmeasmsc(`state`

,`frame`

)`frame`

are `'rectangular'`

and
`'spherical'`

.

specifies the axes of the sensor's coordinate system. The `measurement`

= cvmeasmsc(`state`

,`frame`

,`laxes`

)`laxes`

input
is a 3-by-3 matrix with each column specifying the direction of local *x*,
*y* and *z* axes in the observer's Cartesian frame. The
default for `laxes`

is [`1 0 0;0 1 0;0 0 1`

].

specifies the measurement parameters as a scalar struct or an array of struct.`measurement`

= cvmeasmsc(`state`

,`measurementParameters`

)

`[`

returns the measurement bounds, used by a tracking filter (`measurement`

,`bounds`

] = cvmeasmsc(___)`trackingEKF`

, `trackingUKF`

, `trackingCKF`

,`trackingIMM`

, `trackingMSCEKF`

, or `trackingGSF`

) in residual
calculations.

## Examples

### Obtain Measurements in MSC Frame

Using the `cvmeasmsc`

function, you can obtain measurements of the state in the spherical and the rectangular frames.

**Spherical Frame**

Obtain the azimuth and elevation measurements from an MSC state.

mscState = [0.5;0;0.3;0;1e-3;1e-2]; cvmeasmsc(mscState)

`ans = `*2×1*
28.6479
17.1887

**Rectangular Frame**

Obtain the position measurement from an MSC state. Specify the frame as a second input.

`cvmeasmsc(mscState,'rectangular')`

`ans = `*3×1*
838.3866
458.0127
295.5202

Alternatively, you can specify the frame using `measurementParameters`

.

cvmeasmsc(mscState,struct('Frame','rectangular'))

`ans = `*3×1*
838.3866
458.0127
295.5202

### Display Residual Wrapping Bounds for `cvmeasmsc`

Specify a 3-D state and specify a measurement structure such that the function outputs azimuth and elevation measurements.

state = [pi/2 .3 pi/6 0.1 1 0]'; % [az omega el elRate 1/r vr/r] mp = struct("Frame","Spherical", ... "HasAzimuth",true, ... "HasElevation",true);

Output the measurement and wrapping bounds using the `cvmeasmsc`

function.

[measure,bounds] = cvmeasmsc(state,mp)

`measure = `*2×1*
90
30

`bounds = `*2×2*
-180 180
-90 90

## Input Arguments

`state`

— Relative state

vector | matrix

State that is defined relative to an observer in modified spherical coordinates,
specified as a vector or a 2-D matrix. For example, if there is a constant velocity
target state, *xT*, and a constant velocity observer state,
*xO*, then the `state`

is defined as *xT -
xO* transformed in modified spherical coordinates.

The two-dimensional version of modified spherical coordinates (MSC) is also referred to as the modified polar coordinates (MPC). In the case of:

2-D space –– State is equal to [

*az**azRate*1/*r**vr*/*r*].3-D space –– State is equal to [

*az**omega**el**elRate*1/*r**vr*/*r*].

The variables used in the convention are:

*az*–– Azimuth angle (rad)*el*–– Elevation angle (rad)*azRate*–– Azimuth rate (rad/s)*elRate*–– Elevation rate (rad/s)*omega*––*azRate*× cos(*el*) (rad/s)1/

*r*–– 1/range (1/m)*vr*/*r*–– range-rate/range or inverse time-to-go (1/s)

If the input state is specified as a matrix, states must be concatenated along columns, where each column represents a state following the convention specified above. The output is a matrix with the same number of columns as the input, where each column represents the measurement from the corresponding state.

If the motion model is in 2-D space, values corresponding to elevation are assumed to be zero if elevation is requested as an output.

**Data Types: **`single`

| `double`

`frame`

— Measurement frame

`'spherical'`

(default) | `'rectangular'`

Measurement frame, specified as `'spherical'`

or
`'rectangular'`

. If using the `'rectangular'`

frame,
the three elements present in the measurement represent *x*,
*y*, and *z* position of the target in the
observer's Cartesian frame. If using the `'spherical'`

frame, the two
elements present in the measurement represent azimuth and elevation measurement of the
target. If not specified, the function provides the measurements in
`'spherical'`

frame.

`laxes`

— Direction of local axes

`[1 0 0;0 1 0;0 0 1]`

(default) | 3-by-3 matrix

Direction of local *x*, *y*, and
*z* axes in the scenario, specified as a 3-by-3 matrix. If not
specified, `laxes`

is equal to ```
[1 0 0;0 1 0;0 0
1]
```

.

**Data Types: **`double`

`measurementParameters`

— Measurement parameters

structure | array of structure

Measurement parameters, specified as a structure or an array of structures. The fields of the structure are:

Field | Description | Example |
---|---|---|

`Frame` | Frame used to report measurements, specified as one of these values: `'Rectangular'` — Detections are reported in rectangular coordinates.`'Spherical'` — Detections are reported in spherical coordinates.
In Simulink, when you create an object detection Bus, specify
| `'spherical'` |

`OriginPosition` | Position offset of the origin of the frame relative to the parent frame, specified as an `[x y z]` real-valued vector. | `[0 0 0]` |

`OriginVelocity` | Velocity offset of the origin of the frame relative to the parent frame, specified as a `[vx vy vz]` real-valued vector. | `[0 0 0]` |

`Orientation` | Frame rotation matrix, specified as a 3-by-3 real-valued orthonormal matrix. | `[1 0 0; 0 1 0; 0 0 1]` |

`HasAzimuth` | Logical scalar indicating if azimuth is included in the measurement. This
field is not relevant when the | `1` |

`HasElevation` | Logical scalar indicating if elevation information is included in the measurement. For
measurements reported in a rectangular frame, and if
`HasElevation` is false, the reported measurements assume 0
degrees of elevation. | `1` |

`HasRange` | Logical scalar indicating if range is included in the measurement. This
field is not relevant when the | `1` |

`HasVelocity` | Logical scalar indicating if the reported detections include velocity measurements. For a
measurement reported in the rectangular frame, if `HasVelocity`
is `false` , the measurements are reported as ```
[x y
z]
``` . If `HasVelocity` is `true` ,
the measurement is reported as `[x y z vx vy vz]` . For a
measurement reported in the spherical frame, if `HasVelocity`
is `true` , the measurement contains range-rate
information. | `1` |

`IsParentToChild` | Logical scalar indicating if `Orientation` performs a frame rotation from the parent coordinate frame to the child coordinate frame. When `IsParentToChild` is `false` , then `Orientation` performs a frame rotation from the child coordinate frame to the parent coordinate frame. | `0` |

If you only want to perform one coordinate transformation, such as a transformation from the body frame to the sensor frame, you only need to specify a measurement parameter structure. If you want to perform multiple coordinate transformations, you need to specify an array of measurement parameter structures. To learn how to perform multiple transformations, see the Convert Detections to objectDetection Format example.

**Data Types: **`struct`

## Output Arguments

`measurement`

— Measurement from MSC state

vector

Target measurement in MSC frame, returned as a:

One-element vector –– When

`HasElevation`

is set to`false`

, the vector contains azimuth as the only measurement.Two-element vector –– When the

`frame`

is set to`'spherical'`

, the function measures the azimuth and elevation measurements from an MSC state.Three-element vector –– When the

`frame`

is set to`'rectangular'`

, the function measures the position measurement from an MSC state.

`bounds`

— Measurement residual wrapping bounds

*M*-by-2 real-valued matrix

Measurement residual wrapping bounds, returned as an *M*-by-2
real-valued matrix, where *M* is the dimension of the measurement. Each
row of the matrix corresponds to the lower and upper bounds for the specific dimension
in the `measurement`

output.

The function returns different bound values based on the `frame`

input.

If the

`frame`

input is specified as`'Rectangular'`

, each row of the matrix is`[-Inf Inf]`

, indicating the filter does not wrap the measurement residual in the filter.

If the

`frame`

input is specified as`'Spherical'`

, the returned`bounds`

contains at least one row of the azimuth bounds as`[-180 180]`

, indicating the filter wraps the azimuth residual in the range of`[-180 180]`

in degrees. Optionally, when`HasElevation`

=`true`

, the matrix includes a second row of`[-90 90]`

, indicating the filter wraps the elevation residual in the range of`[-90 90]`

in degrees.

The filter wraps the measurement residuals based on this equation:

$${x}_{wrap}=mod(x-\frac{a-b}{2},b-a)+\frac{a-b}{2}$$

where *x* is the residual to wrap,
*a* is the lower bound, *b* is the upper bound,
*mod* is the modules after division function, and
*x*_{wrap} is the wrapped residual.

**Data Types: **`single`

| `double`

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

## Version History

**Introduced in R2018b**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)