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 = 6×1
107 ×

    2.2533
    2.0206
    2.1302
    2.3044
    2.1120
    2.3612

satPos = 6×3
107 ×

    0.1695   -2.6501   -0.0491
    0.5647   -1.7766    1.8919
   -0.7529   -1.9012    1.6949
    1.5148    0.1836    2.1739
    1.4581   -0.9394    2.0114
    2.4293   -1.0436    0.2524

status = struct with fields:
    LOS: [6x1 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 = 7×1
107 ×

    2.4225
    2.4319
    2.0445
    2.0632
    2.2279
    2.2875
    2.2568

satPos = 7×3
107 ×

   -1.5534   -0.2628    2.1383
    0.2580   -2.4886   -0.8914
    1.0703   -2.0380    1.3248
   -0.1423   -1.6301    2.0921
    1.5099   -0.2036    2.1756
   -0.3974   -2.6261   -0.0050
    2.2755   -0.8512    1.0732

status = struct with fields:
    LOS: [7x1 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 = 7×1
107 ×

    2.4225
    2.4319
    2.0445
    2.0632
    2.2279
    2.2875
    2.2568

satPos = 7×3
107 ×

   -1.5534   -0.2628    2.1383
    0.2580   -2.4886   -0.8914
    1.0703   -2.0380    1.3248
   -0.1423   -1.6301    2.0921
    1.5099   -0.2036    2.1756
   -0.3974   -2.6261   -0.0050
    2.2755   -0.8512    1.0732

status = struct with fields:
    LOS: [7x1 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   82.2349

Version History

Introduced in R2023a