Main Content

add

Add waypoints to trajectory object

Since R2024b

Description

add(trajectory,timestamps,x,y,z) adds the specified waypoint xyz-coordinates x, y, and z, with their corresponding timestamps timestamps, to the trajectory object trajectory.

example

add(___,Attributes=attributes) adds optional sensor attributes attributes to the trajectory object trajectory, in addition to the input arguments from the previous syntax.

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","X","Y","Z","timestamps")

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

idx = 100;
traj = scenariobuilder.Trajectory(timestamps(1:idx),X(1:idx),Y(1:idx),Z(1:idx))
traj = 
  Trajectory with properties:

               Name: ''

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

           Position: [100×3 double]
        Orientation: [100×3 double]
           Velocity: [100×3 double]
             Course: [100×1 double]
        GroundSpeed: [100×1 double]
       Acceleration: [100×3 double]
    AngularVelocity: [100×3 double]

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Plot the trajectory object.

plot(traj)

Add more waypoints to the trajectory object.

add(traj,timestamps(idx+1:end),X(idx+1:end),Y(idx+1:end),Z(idx+1:end))

Plot the trajectory object.

plot(traj)

Input Arguments

collapse all

Trajectory data, specified as a Trajectory object.

This property is read-only.

Timestamps of the trajectory 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. The data type of the timestamps and the data type of the Timestamps property of the input Trajectory object trajectory must be the same. If you specify an N-element numeric column vector, units must be in seconds. Each element in the timestamps argument specifies the time at which the trajectory data was collected.

The add function arranges the added GPS data points by their timestamps, in increasing order.

x-coordinates of the added waypoints in the world coordinate system, specified as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

Data Types: single | double

y-coordinates of the added waypoints in the world coordinate system, specified as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

Data Types: single | double

z-coordinates of the added waypoints in the world coordinate system, specified as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

Data Types: single | double

Optional trajectory attributes of the added waypoints, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the additional trajectory attributes recorded at the corresponding timestamp.

Data Types: cell

Version History

Introduced in R2024b