Main Content

GPSData

Store GPS data

Since R2024b

Description

The GPSData object stores GPS data.

Creation

Description

gpsData = scenariobuilder.GPSData creates an empty GPSData object, gpsData.

gpsData = scenariobuilder.GPSData(timestamps,latitude,longitude,altitude) creates a GPSData object, gpsData, with the Timestamp, Latitude, Longitude, and Altitude properties set by the timestamps, latitude, longitude, and altitude arguments, respectively. Additionally, this syntax sets the SampleRate, SampleTime, Duration, and NumSamples properties.

gpsData = scenariobuilder.GPSData(timestamps,latitude,longitude,altitude,Name=Value) sets writable properties using one or more name-value arguments. For example, Attributes=attributes specifies the optional GPS attributes attributes.

Note

This object requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

example

Input Arguments

expand all

Timestamps of the GPS data, specified as an N-element numeric column vector, an N-element datetime array, or an N-element duration array. N is the number of timestamps. Each element in the timestamps argument specifies the time at which the corresponding GPS data was collected. If you specify an N-element numeric column vector, units must be in seconds.

When you initialize the object with timestamp, latitude, and longitude data, the object arranges the data by the input timestamps in increasing order.

This argument sets the Timestamps property.

Latitude coordinates of the GPS data, specified as an N-element numeric column vector. N is the number of timestamps. Units are in degrees.

This argument sets the Latitude property.

Data Types: double

Longitude coordinates of the GPS data, specified as an N-element numeric column vector. N is the number of timestamps. Units are in degrees.

This argument sets the Longitude property.

Data Types: double

Altitude coordinates of the GPS data, specified as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

This argument sets the Altitude property.

Data Types: double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: scenariobuilder.GPSData(Name="GPS1") specifies the name of the GPS sensor as "GPS1".

Name of the GPS sensor, specified as a string scalar or character vector.

This argument sets the Name property.

Data Types: char | string

Optional GPS attributes, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the additional GPS attributes, such as velocity and speed values, recorded at the corresponding timestamp.

This argument sets the Attributes property.

Data Types: cell

Properties

expand all

Name of the GPS sensor, specified as a string scalar or character vector.

Data Types: char | string

This property is read-only.

Number of waypoint samples of the GPS data, represented as a nonnegative integer.

Data Types: uint8 | uint16 | uint32 | uint64

This property is read-only.

Time duration for which the GPS data was acquired, represented as a nonnegative scalar. Units are in seconds.

Data Types: double

This property is read-only.

Mean sample rate of the GPS data, represented as a nonnegative scalar. This value defines the number of GPS samples per second. Units are in hertz.

Data Types: double

This property is read-only.

Mean sample time of the GPS data, represented as a nonnegative scalar. This value defines the mean time interval between two consecutive GPS samples. Units are in seconds.

Data Types: double

This property is read-only after object creation. To set this property, use the timestamps argument when calling the scenarioBuilder.GPSData function.

Timestamps of the GPS data, represented as an N-element numeric column vector, an N-element datetime array, or an N-element duration array. N is the number of timestamps. Each element in the Timestamps property specifies the time at which the corresponding GPS data was collected. If you specify an N-element numeric column vector, units must be in seconds.

When you initialize the object with timestamp, latitude, and longitude data, the object arranges the data by the input timestamps in increasing order.

This property is read-only after object creation. To set this property, use the latitude argument when calling the scenarioBuilder.GPSData function.

Latitude coordinates of the GPS data, represented as an N-element numeric column vector. N is the number of timestamps. Units are in degrees.

Data Types: double

This property is read-only after object creation. To set this property, use the longitude argument when calling the scenarioBuilder.GPSData function.

Longitude coordinates of the GPS data, represented as an N-element numeric column vector. N is the number of timestamps. Units are in degrees.

Data Types: double

This property is read-only after object creation. To set this property, use the altitude argument when calling the scenarioBuilder.GPSData function.

Altitude coordinates of the GPS data, represented as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

Data Types: double

Optional GPS attributes, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the additional GPS attributes, such as velocity and speed values, recorded at the corresponding timestamp.

Data Types: cell

Object Functions

addAdd data to GPS data object
removeRemove data from sensor data object
readRead data from sensor data object
copyCreate copy of sensor data object
cropCrop data from sensor data object
synchronizeSynchronize sensor data with reference sensor information
plotPlot GPS data
distanceCompute total distance traveled for data stored in GPS data object
normalizeTimestampsNormalize timestamps of sensor data object
trajectoryCreate trajectory from GPS data object

Examples

collapse all

Load recorded GPS data into the workspace.

load("recordedGPSData.mat")

Initialize a GPSData object using the information from the GPS data.

idx = 100;
gpsData = scenariobuilder.GPSData(timestamps(1:idx), ...
                latitudes(1:idx),longitudes(1:idx),altitudes(1:idx), ...
                Name="GPSSensor")
gpsData = 
  GPSData with properties:

          Name: "GPSSensor"

    NumSamples: 100
      Duration: 4.9492
    SampleRate: 20.2054
    SampleTime: 0.0500
    Timestamps: [100×1 double]

      Latitude: [100×1 single]
     Longitude: [100×1 single]
      Altitude: [100×1 single]

    Attributes: []

Plot the GPS data object.

plot(gpsData)

Add additional data samples to the GPS data object.

add(gpsData,timestamps(idx+1:end),latitudes(idx+1:end), ...
        longitudes(idx+1:end),altitudes(idx+1:end))

Plot the GPS data object, and observe the added waypoints.

figure
plot(gpsData)

Version History

Introduced in R2024b