Main Content

gnssMeasurementGenerator

Simulate GNSS measurements for scenarios

Since R2023a

Description

The gnssMeasurementGenerator System object™ simulates global navigation satellite system (GNSS) receiver measurements. The object calculates pseudoranges based on the sensor time and data that specifies the satellite orbital parameters. The object uses only the Global Positioning System (GPS) constellations for calculations. To set the starting positions of the satellites, set the InitialTime property.

To simulate GNSS measurements in a driving scenario:

  1. Create the gnssMeasurementGenerator object and set its properties.

  2. Add the GNSS receiver to the host vehicle using addSensors (Automated Driving Toolbox).

  3. Call the object with arguments, as if it were a function.

To simulate GNSS measurements in a UAV scenario:

  1. Create the gnssMeasurementGenerator object and set its properties.

  2. Attach the GNSS receiver to the UAV platform using uavSensor (UAV Toolbox)

  3. Gather the reading from the GNSS receiver using read (UAV Toolbox)

To learn more about how System objects work, see What Are System Objects?

Creation

Description

GNSS = gnssMeasurementGenerator returns a gnssMeasurementGenerator System object GNSS that simulates raw global navigation satellite system receiver measurements.

GNSS = gnssMeasurementGenerator(Name=Value) specifies properties using one or more name-value arguments.

example

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Sample rate of the GNSS receiver, specified as a positive scalar in Hz.

Initial time of the GNSS receiver, specified as a datetime object. The object accounts for leap seconds in the conversion between the UTC and the GNSS time.

Origin of the local navigation reference frame, specified as a three-element row vector in geodetic coordinates of the form [latitude longitude altitude]. Specify latitude in degrees, longitude in degrees, and altitude in meters. Altitude is the height above the reference ellipsoid model WGS84.

Elevation mask angle, specified as a scalar in the range [0, 90], in degrees. The object does not use satellites that are in view, but below the mask angle, in estimating the position of the receiver.

Tunable: Yes

Standard deviation of the pseudorange measurement noise, specified as a nonnegative scalar in meters.

Tunable: Yes

Random number source, specified as one of these options::

  • "Global stream" –– Generate random numbers using the current global random number stream.

  • "mt19937ar with seed" –– Generate random numbers using the mt19937ar algorithm with the seed specified by the Seed property.

Data Types: char | string

Initial seed of the mt19937ar random number generator algorithm, specified as a nonnegative integer.

Dependencies

To enable this property, specify RandomStream property as "mt19937ar with seed".

Usage

Description

[pseudorangeMeasurements,satellitePositions,status] = GNSS computes the GNSS receiver measurements.

example

Output Arguments

expand all

Pseudorange measurements of the GNSS receiver, returned as an N-element vector, in meters. N is the number of satellites in view.

Satellite positions in Earth-centered Earth-fixed coordinate system, returned as an N-by-3 matrix. N is the number of satellites in view. Each row is a Cartesian coordinate in meters.

Status of the satellite measurements, returned as a structure containing the field:

  • LOS — Line of sight for each satellite, returned as a logical N-element vector. N is the number of satellites in view. A status of 1 or true indicates that there is line of sight from the receiver to the satellite, and a status of 0 or false indicates there is no line of sight from the receiver to the satellite.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

cloneCreate duplicate System object
stepRun System object algorithm
isLockedDetermine if System object is in use
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create variables for the sample rate and the geodetic reference location. Set the sample rate to 1 Hz, and set the reference location to Natick, Massachusetts.

Fs = 1;
refLocNatick = [42.2825 -71.343 53.0352]; 

Create a driving scenario with the reference location set to Natick, and add a car to the scenario.

scene = drivingScenario(GeoReference=refLocNatick);
car = vehicle(scene);

Create a GNSS measurement generator System object with the previously specified sample rate and reference location.

gnss = gnssMeasurementGenerator(SampleRate=Fs,ReferenceLocation=refLocNatick);

Mount the GNSS measurement generator, as a sensor, on the car in the scene.

mountingPosition = [0 0 1.5];
addSensors(scene,{gnss},car.ActorID,mountingPosition)

Initialize and advance the scenario.

advance(scene);

Get the raw GNSS measurements.

[pr,satPos,status] = gnss()
pr = 8×1
107 ×

    2.0838
    2.2161
    2.1017
    2.2946
    2.2942
    2.1451
    2.0848
    2.4701

satPos = 8×3
107 ×

   -0.0003   -2.4032    1.1309
    0.8448   -2.5176    0.0451
   -0.4216   -1.4684    2.1726
    1.8095    0.0140    1.9441
   -1.2769   -2.2235    0.6926
    1.6833   -0.8328    1.8781
    1.5414   -1.7670    1.2473
   -2.0580   -0.8095    1.4709

status = struct with fields:
    LOS: [8x1 logical]

Create variables for the GNSS sample rate and the geodetic reference location. Set the sample rate to 10 Hz, and set the reference location to Natick, Massachusetts.

Fs = 10;
refLocNatick = [42.2825 -71.343 53.0352]; 

Create a UAV scenario using the specified reference location set to Natick, and set the update rate to match the GNSS sample rate.

scene = uavScenario(ReferenceLocation=refLocNatick,UpdateRate=Fs);

Create a UAV platform using the default NED reference frame.

plat = uavPlatform("UAV",scene,InitialPosition=[0 0 -30]);

Create a gnssMeasurementGenerator object with the previously specified GNSS sample rate and reference location.

gnssSensor = gnssMeasurementGenerator(ReferenceLocation=refLocNatick, ...
    SampleRate=Fs);

Attach a GNSS sensor to the UAV platform using the uavSensor object, and specify gnssSensor as the sensor model.

gnss = uavSensor("GNSS",plat,gnssSensor,MountingLocation=[0 0 -0.5]);

Set up the scenario, and get the initial pseudoranges, satellite positions, and satellite status measurements.

setup(scene)
[~,~,pr,satPos,status] = gnss.read
pr = 8×1
107 ×

    2.4347
    2.4105
    2.0379
    2.0688
    2.4557
    2.2116
    2.3072
    2.2654

satPos = 8×3
107 ×

   -1.5430   -0.1777    2.1544
    0.2454   -2.5209   -0.7993
    1.0231   -2.0099    1.4027
   -0.2201   -1.6590    2.0624
    1.5236    0.8342    2.0092
    1.4978   -0.2896    2.1741
   -0.4057   -2.6227   -0.1050
    2.3032   -0.8825    0.9852

status = struct with fields:
    LOS: [8x1 logical]

Advance the scene simulation time. The simulation advances a single step based on the specified update rate of 10 Hz, to 0.1 seconds.

advance(scene);

Update the sensors and get the pseudoranges, satellite positions, and satellite status measurements at the new timestep.

updateSensors(scene)
[isUpdated,timestamp,pr,satPos,status] = gnss.read
isUpdated = logical
   1

timestamp = 
0.1000
pr = 8×1
107 ×

    2.4347
    2.4105
    2.0379
    2.0688
    2.4557
    2.2116
    2.3072
    2.2654

satPos = 8×3
107 ×

   -1.5430   -0.1777    2.1544
    0.2454   -2.5209   -0.7993
    1.0231   -2.0099    1.4027
   -0.2201   -1.6590    2.0624
    1.5236    0.8342    2.0092
    1.4978   -0.2896    2.1741
   -0.4057   -2.6227   -0.1050
    2.3032   -0.8825    0.9852

status = struct with fields:
    LOS: [8x1 logical]

Use the pseudoranges and satellite positions to estimate the UAV position. This result shows that the UAV is hovering 30 meters above the reference location.

recPos = receiverposition(pr(status.LOS,:),satPos(status.LOS,:))
recPos = 1×3

   42.2825  -71.3433   83.6139

Version History

Introduced in R2023a