Main Content

recordedSensorData

Create sensor data object from recorded sensor data

Since R2024b

Description

Create GPSData Object

gpsData = recordedSensorData("gps") creates an empty GPSData object, gpsData.

gpsData = recordedSensorData("gps",timestamps,latitude,longitude,altitude) creates a GPSData object, gpsData, with the Timestamps, 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.

example

Create Trajectory Object

trajectory = recordedSensorData("trajectory") creates an empty Trajectory object, trajectory.

trajectory = recordedSensorData("trajectory",timestamps,x,y,z) creates a Trajectory object, trajectory, using the specified timestamps timestamps and the xyz-coordinates of the corresponding waypoints. x, y, and z specify the first, second, and third columns of the Position property, respectively.

trajectory = recordedSensorData("trajectory",timestamps,waypoints) creates a trajectory object, trajectory, using the specified timestamps timestamps and the corresponding waypoints waypoints. The waypoints argument specifies the Position property.

Create CameraData Object

camData = recordedSensorData("camera") creates an empty CameraData object, camData.

camData = recordedSensorData("camera",timestamps,frames) creates a CameraData object, camData, with the Timestamps and Frames properties set by the timestamps and frames arguments, respectively. Additionally, this syntax sets the SampleRate, SampleTime, Duration, and NumSamples properties.

camData = recordedSensorData("camera",video) creates a CameraData object, camData, containing image data extracted from the specified video video.

Create LidarData Object

lidarData = recordedSensorData("lidar") creates an empty LidarData object, lidarData.

lidarData = recordedSensorData("lidar",timestamps,pointClouds) creates a LidarData object, lidarData, with the Timestamps and PointClouds properties set by the timestamps and pointClouds arguments, respectively. Additionally, this syntax sets the SampleRate, SampleTime, Duration, and NumSamples properties.

Create ActorTrackData Object

Since R2025a

trackData = recordedSensorData("actorTrack") creates an empty ActorTrackData object, trackdata.

trackData = recordedSensorData("actorTrack",timestamps,trackID,position) creates an ActorTrackData object with the Timestamps, TrackID, and Position properties set by the timestamp, trackID, and position arguments, respectively. Additionally, this syntax sets the SampleRate, SampleTime, Duration, NumSamples, and UniqueTrackIDs properties.

Specify Property Values

[___] = recordedSensorData(___,varargin) sets properties of the output sensor data object, in addition to any combination of arguments from previous syntaxes. varargin represents a variable-length name-value argument list for the corresponding sensor data object. For example, Name="sensor1" specifies the Name property of the output sensor as "sensor1".

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.

example

Examples

collapse all

Load recorded GPS data into the workspace.

load("recordedGPSData.mat","latitudes","longitudes","altitudes","timestamps")

Create an empty GPSData object to store GPS data.

gpsData = recordedSensorData("gps",Name="GPSSensor")
gpsData = 
  GPSData with properties:

          Name: "GPSSensor"

    NumSamples: 0
      Duration: 0
    SampleRate: 0
    SampleTime: 0
    Timestamps: []

      Latitude: []
     Longitude: []
      Altitude: []

    Attributes: []

Add data samples to the GPS data object.

add(gpsData,timestamps,latitudes,longitudes,altitudes)

Display the GPSData object.

disp(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: []

Plot the GPS data object.

plot(gpsData)

Load recorded GPS data into the workspace.

load("recordedGPSData.mat","latitudes","longitudes","altitudes","timestamps")

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

gpsData = recordedSensorData("gps",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: []

Display the GPS data object.

disp(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: []

Plot the GPS data object.

plot(gpsData)

Load recorded GPS trajectory data into the workspace.

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

Create an empty Trajectory object to store the GPS trajectory data.

traj = recordedSensorData("trajectory",Name="EgoTrajectory")
traj = 
  Trajectory with properties:

               Name: "EgoTrajectory"

         NumSamples: 0
           Duration: 0
         SampleRate: 0
         SampleTime: 0
         Timestamps: []

           Position: []
        Orientation: []
           Velocity: []
             Course: []
        GroundSpeed: []
       Acceleration: []
    AngularVelocity: []

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Add trajectories to the trajectory object.

add(traj,timestamps,X,Y,Z)

Display the trajectory object.

disp(traj)
  Trajectory with properties:

               Name: "EgoTrajectory"

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

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

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Plot the trajectory object.

plot(traj)

Create an empty CameraData object to store camera data.

camData = recordedSensorData("camera",Name="CameraSensor")
camData = 
  CameraData with properties:

                Name: "CameraSensor"

          NumSamples: 0
            Duration: 0
          SampleRate: 0
          SampleTime: 0
          Timestamps: []

              Frames: []
    SensorParameters: []

          Attributes: []

Specify the path of a video file.

filePath = fullfile(toolboxdir("driving"),"drivingdata","udacity","drive_segment_09_29_16","centerCamera.avi");

Add data samples from the video to the camera data object.

add(camData,filePath)

Play the camera data object.

play(camData)

Create an empty LidarData object to store point clouds.

lidarData = recordedSensorData("lidar",Name="LidarSensor")
lidarData = 
  LidarData with properties:

                Name: "LidarSensor"

          NumSamples: 0
            Duration: 0
          SampleRate: 0
          SampleTime: 0
          Timestamps: []

         PointClouds: []
    SensorParameters: []

          Attributes: []

Specify a path containing a sequence of point cloud files.

files = dir(fullfile(toolboxdir("vision"),"visiondata","pcdmapseq","*.pcd"));
pcds = strcat({files.folder},filesep,{files.name})';

Specify timestamps for each point cloud in the point cloud data.

timestamps = (1:4)';

Add the point cloud data samples to the lidar data object.

add(lidarData,timestamps,pcds);

Visualize the lidar data object.

play(lidarData)

Since R2025a

Load recorded actor track data into the workspace.

load("trackedActorData.mat")

Create an empty ActorTrackData object to store actor tracks.

trackData = recordedSensorData("actorTrack",Name="ActorTracks")
trackData = 
  ActorTrackData with properties:

                Name: "ActorTracks"

          NumSamples: 0
            Duration: 0
          SampleRate: 0
          SampleTime: 0
          Timestamps: []

             TrackID: []
            Category: []
            Position: []
           Dimension: []
         Orientation: []
            Velocity: []
               Speed: []
                 Age: []

          Attributes: []

      UniqueTrackIDs: []
    UniqueCategories: []

Add the actor track samples to the actor track data object.

timestamps = trackedActorData.Timestamps;
trackID = trackedActorData.TrackID;
position = trackedActorData.Position;
add(trackData,timestamps,trackID,position)

Play the actor track data object.

play(trackData)

Input Arguments

collapse all

Timestamps of the sensor 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 sensor data was collected. If you specify an N-element numeric column vector, units must be in seconds.

When you initialize an object with timestamps and sensor data, the object arranges the data in increasing order of the input timestamps.

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

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.

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.

Data Types: double

x-coordinates of the waypoints in the world coordinate system in ENU (East-North-Up) frame of reference, 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 waypoints in the world coordinate system in ENU frame of reference, 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 waypoints in the world coordinate system in ENU frame of reference, specified as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

Data Types: single | double

Trajectory waypoints, specified as a real-valued N-by-3 matrix. N is the number of waypoints. Each row represents the x-, y-, and z-coordinates of a waypoint.

Waypoints are in the world coordinate system in ENU frame of reference. Units are in meters.

Data Types: single | double

Sequence of image frames, specified as an N-by-1 string array, N-by-1 cell array of character vectors, P-by-Q-by-R-by-N array, a string scalar, or an ImageDatastore object. N is the number of timestamps.

If you specify an N-by-1 string array or an N-by-1 cell array of character vectors, each element in the array represents an image filename, an absolute or relative path of an image file.

If you specify a P-by-Q-by-R-by-N array, P and Q are the height and width of the image, R is the number of color channels, and N is the number of image frames.

If you specify a string scalar, the string must specify an absolute or relative path to a folder containing image files.

Video filename, specified as a character vector or string scalar.

You can specify video as the absolute or relative path to your file. For example, if the file myFile.mp4 is in your current folder, C:\myFolder, you can specify video as "myFile.mp4" or "C:\myFolder\myFile.mp4".

For more information, see Supported Video and Audio File Formats.

This argument sets the Frames and Timestamps properties of the returned CameraData object.

Data Types: char | string

Lidar point cloud data, specified as an N-by-1 array of pointCloud objects, N-by-1 string array, N-by-1 array of character vectors, or a string scalar. N is the number of timestamps.

If you specify an N-by-1 string array or an N-by-1 array of character vectors, each element in the array represents a point cloud filename, an absolute or relative path of a point cloud file. The point cloud file must be of PLY or PCD format.

If you specify a string scalar, the string must specify an absolute or a path to a folder containing point cloud files.

Since R2025a

Track IDs of the actors, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the track IDs of the actors detected at the corresponding timestamp, specified as an M-by-1 string array. M is the number of actors at the timestamp.

Data Types: cell

Since R2025a

Positions of the actors with respect to the ego frame, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the positions of the actors detected at the corresponding timestamp, specified as an M-by-3 numeric matrix. M is the number of actors at the timestamp. Each row specifies the position of an actor in the form [x y z]. Units are in meters.

Data Types: cell

Variable-length name-value argument list, specified as one or more valid name-value arguments of the output sensor data object.

The valid name-value arguments differ depending on which properties of the output object you can set at object creation.

Output Arguments

collapse all

GPS data, returned as a GPSData object.

Trajectory data, returned as a Trajectory object.

Camera data, returned as a CameraData object.

Lidar data, returned as a LidarData object.

Since R2025a

Actor track data, returned as an ActorTrackData object.

Version History

Introduced in R2024b

expand all