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.

example

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

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

example

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

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

    2.4359
    2.2191
    2.1330
    2.2405
    2.3099
    2.0573
    2.0494

satPos = 7×3
107 ×

    1.5016    0.7613    2.0542
   -0.3217   -2.6142    0.3415
   -0.6335   -1.3948    2.1697
    1.9364   -0.3751    1.7787
   -1.5784   -1.7819    1.1779
    1.2702   -1.3868    1.8755
    0.7616   -2.2499    1.1884

status = struct with fields:
    LOS: [7x1 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.4234
    2.1864
    2.4585
    2.1641
    2.2088
    2.3450
    2.0484
    2.0694

satPos = 8×3
107 ×

    1.6525    0.6642    1.9703
   -0.3411   -2.5739    0.5592
    2.4087   -1.0724   -0.3200
   -0.8008   -1.2974    2.1748
    1.7993   -0.4655    1.8974
   -1.6708   -1.8145    0.9849
    1.2582   -1.5484    1.7531
    0.7437   -2.3471    0.9961

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.4234
    2.1864
    2.4585
    2.1641
    2.2088
    2.3450
    2.0484
    2.0694

satPos = 8×3
107 ×

    1.6525    0.6642    1.9703
   -0.3411   -2.5739    0.5592
    2.4087   -1.0724   -0.3200
   -0.8008   -1.2974    2.1748
    1.7993   -0.4655    1.8974
   -1.6708   -1.8145    0.9849
    1.2582   -1.5484    1.7531
    0.7437   -2.3471    0.9961

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   85.3831

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2023a