Roads sensor

Overview

The ‘Roads Sensor’ outputs information about the road geometry and road metadata, within a range on the road. The sensor processes road data which comes from the internal navigation graph; it samples discrete points of the graph and post-processes them into cubic parametric splines. For context, cubic spline fitting is used to create smooth curves, ensuring the road data is continuous and realistic. Other meaningful quantities (such as road speed limit) are inherited from the graph data and are included in the sensor’s output.

The following data is returned:

  • Distances from the vehicle front-axle-midpoint to : road centerline, road left edge, road right edge;
  • the world-space coordinates (X, Y, Z) of the navigation graph points;
  • Local road radius and curvature (κ);
  • Heading angle between the vehicle forward direction and the road reference line;
  • Local road half-width;
  • Local road polyline (raw, from navigation graph);
  • Fitted parametric cubic polynomials (fitted to the local polyline). The format and parametrisation of the polynomials are the same as used in ASAM OpenDRIVE standard;
  • Number of lanes in the current travel direction;
  • 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: January 25, 2025

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.