Roads sensor

Overview

The ‘Roads Info Sensor’ packages information about the road, locally. This comes from the internal navigation graph. Some post-processing has been applied to the data to produce more meaningful quantities.

The following data is returned:

_Lateral distances to; road centerline, road left edge, road right edge, and their world-space positions, _Local road radius and curvature (κ), _Heading (angle in degrees), _Local road half-width, _Local road polyline (raw, from navigation graph), _Fitted parametric cubic polynomials (fitted to the local polyline), _Some common navigation graph metadata (drivability, speed limit, one-way)

Usage

The roads sensor code is written in Lua code and has an API similar to the other sensors in our suite.


sensorId = extensions.tech_sensors.createRoadsSensor(vid, args)

Args:

vid(int): An id that leads to the vehicle id

GFXUpdateTime(float): How often the roads sensor should update its readings in the simulator (in seconds). This determines how often the user will be able to retrieve a new reading from the sensor.

physicsUpdateTime(float): How often in the simulator’s physics step, we should update the roads sensor readings (in seconds).

Returns: sensorId(int): The unique Id number of this sensor, useful to refer to it hereafter, for example when closing it.


extensions.tech_sensors.setRoadsSensorUpdateTime(sensorId, vid, updateTime)

Args:

sensorId(int): The ID number of the roads sensor.

vid(int): the id number which leads to the vehicle id.

updateTime(float): The new update time for this sensor.

Returns: nil


readings = extensions.tech_sensors.getRoadsSensorReadings(sensorId)

Args:

sensorId(int): The ID number of the roads sensor.

Returns: readings(table): The latest readings from the sensor


The following three functions can be used to send ad-hoc polling requests to a roads sensor. This is for when we need to first send a request using sendRoadsSensorRequest, then wait for it. We can check it is complete using isVluaRequestComplete then retrieve it using collectRoadsSensorRequest.

requestId = extensions.tech_sensors.sendRoadsSensorRequest(sensorId, vid)

Args:

sensorId(int): The ID number of the roads sensor.

vid(int): id number that helps get the vehicle id.

Returns: The unique Id number of the ad-hoc sensor polling request which is being sent.


isComplete = extensions.tech_sensors.isVluaRequestComplete(requestId)

Args:

requestId(int): The ID number of the ad-hoc sensor polling request to check on.

Returns: isComplete(bool): True if the ad-hoc polling request has been completed, otherwise false.


data = extensions.tech_sensors.collectRoadsSensorRequest(requestId)

Args:

requestId(int): The ID number of the ad-hoc sensor polling request.

Returns: data(table): The roads sensor readings


extensions.tech_sensors.removeRoadsSensor(vid, sensorId)

Args:

vid(int): The id used to get the vehicle id. sensorId(int): The ID number of the roads sensor to remove.

Returns: nil.

Last modified: June 18, 2024
On this page:

Any further questions?

Join our discord
Our documentation is currently incomplete and undergoing active development. If you have any questions or feedback, please visit this forum thread.