Main Content

findNearest

Find lane information nearest to specified timestamps in lane data object

Since R2023a

Description

example

data = findNearest(lanedata,timestamps) finds the lane information nearest to the specified timestamps timestamps in the laneData object lanedata.

data = findNearest(lanedata,timestamps,"lessThanEqual") finds the lane information nearest to and less than the specified timestamps timestamps.

data = findNearest(lanedata,timestamps,"greaterThanEqual") finds the lane information nearest and greater than the specified timestamps timestamps.

data = findNearest(___,SortLanes=sortLanes) specifies whether to sort the lanes in the output table data.

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 an initialized laneData object into the workspace.

data = load("laneDataObject.mat");
ld = data.ld;

Specify a timestamp for which to find data in the laneData object.

t = 10;

Find the data nearest to the specified timestamp in the laneData object.

nd = findNearest(ld,t);

Display the data.

disp(nd)
    TimeStamp           LaneBoundary1                  LaneBoundary2           LaneBoundary1_Info    LaneBoundary2_Info
    _________    ___________________________    ___________________________    __________________    __________________

     9.9998      {1x1 parabolicLaneBoundary}    {1x1 parabolicLaneBoundary}       {1x1 struct}          {1x1 struct}   

Input Arguments

collapse all

Recorded lane data, specified as a laneData object.

This property is read-only.

Timestamps near which to read lane information, specified as a scalar or an N-element vector. N is the number of timestamps for which to read data from the input lanedata. Units are in seconds. The data in the output table retains the order you specify to this argument.

Data Types: double

Sort lanes flag, specified as a logical 1 (true) or 0 (false). Specify 1 to sort the lane boundaries in the output table data. Otherwise, specify 0. If you specify 1, the function sorts the lane boundaries in left-to-right order, with respect to the travel direction of the ego vehicle.

Output Arguments

collapse all

Lane detection data, returned as an 1-by-P table. (P–1) is the greatest number of detected lane boundaries across all samples. This table shows an example of the data organization.

TimeStampLaneBoundary1LaneBoundary2LaneBoundary3
01x1 parabolicLaneBoundary1x1 parabolicLaneBoundary1x1 parabolicLaneBoundary

  • The first column of the table is the recorded timestamp, in seconds, for each detection in the corresponding row. All other columns contain data for the detected lane boundaries as parabolicLaneBoundary objects, cubicLaneBoundary objects, or clothoidLaneBoundary objects. All lane boundaries in a table are of the same object type.

  • Empty cells represent missing lane boundary detections.

  • The detected lane boundaries are in left-to-right order with respect to the travel direction of the ego vehicle.

  • When you use lessThanEqual or greateThanEqual input arguments, and you specify values in the timestamps argument that do not correspond to timestamps present in the laneData object, the function returns NaN for every column in the corresponding row of the output table data.

Data Types: table

Version History

Introduced in R2023a

expand all