Main Content

normalizeTimestamps

Normalize timestamps of sensor data object

Since R2024b

Description

normalizeTimestamps(sensorDataObj) normalizes timestamps by subtracting the first timestamp from all timestamps in the input sensor data object sensorDataObj, and updates the sensor data object sensorDataObj.

example

normalizeTimestamps(sensorDataObj,timeOrigin) normalizes timestamps by subtracting the specified reference time timeOrigin from all timestamps in the input sensor data object sensorDataObj, and updates the sensor data object sensorDataObj.

timeOrigin = normalizeTimestamps(___) returns the subtracted reference time timeOrigin.

Note

This function 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.

Examples

collapse all

Load recorded GPS data into the workspace.

load("recordedGPSData.mat")

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

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

          Name: "GPSSensor"

    NumSamples: 392
      Duration: 19.5498
    SampleRate: 20.0513
    SampleTime: 0.0500
    Timestamps: [392×1 double]

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

    Attributes: []

Normalize the timestamps of the created GPS data object.

normalizeTimestamps(traj)

Display the timestamps

Load recorded GPS data into the workspace.

load("recordedGPSData.mat","X","Y","Z","timestamps")

Create a trajectory object by using the loaded timestamps and xyz-coordinates.

traj = scenariobuilder.Trajectory(timestamps,X,Y,Z);

Normalize the timestamps of the created trajectory object.

normalizeTimestamps(traj)

Smooth the trajectory.

smooth(traj)

Specify the path to your local RoadRunner installation folder. This code shows the path for the default installation location on Windows®.

rrAppPath = "C:\Program Files\RoadRunner " + matlabRelease.Release + "\bin\win64";

Specify the path to your RoadRunner project. This code shows the path to a sample project folder on Windows.

rrProjectPath = "C:\RR\MyProject";

Open RoadRunner using the specified path to your project.

rrApp = roadrunner(rrProjectPath,InstallationFolder=rrAppPath);

Export the trajectory to RoadRunner using the open RoadRunner instance rrApp.

exportToRoadRunner(traj,rrApp)
Connection status: 1
Connected to RoadRunner Scenario server on localhost:60729, with client id {3c191baf-8c50-4639-bf64-ce9b078522e3}

Visualize the trajectory exported to RoadRunner.

Trajectory exported to RoadRunner.

Input Arguments

collapse all

Sensor data, specified as a GPSData object, Trajectory object, CameraData object, or a LidarData object.

Reference time of the trajectory, specified as a nonnegative scalar. The data type of the TimeOrigin value and the data type of the Timestamps property must be the same. If you specify a nonnegative scalar, units must be in seconds.

The function subtracts the TimeOrigin value from all timestamps and updates the Timestamps property with the subtracted timestamps.

Data Types: single | double

Output Arguments

collapse all

Reference time of the trajectory, returned as a nonnegative scalar. Units are in seconds.

Data Types: single | double

Version History

Introduced in R2024b