Lidar

Lidar Visualization Lidar Visualization

Overview

BeamNG.tech ships with a simulated Lidar sensor which extracts point clouds from a customisable point on the vehicle. The horizontal angle, rotational radius, frequency, etc. and how it is attached to a vehicle/fixed spot can be customized by the user.

Usage

Lidar sensors are exposed to Lua through the sensors extension in the tech folder. Using this API, a Lidar sensor can be created with various desired properties, and either attached to a vehicle or to a fixed point on the map.


sensorId = extensions.tech_sensors.createLidar(vehicleId, sensorPosition, sensorDirection, verticalResolution, verticalAngle, raysPerSecond, frequency, horizontalAngle, maxDistance, isVisualised, isAnnotated, isStatic, isSnappingDesired, isForceInsideTriangle)

Args:

vehicleID(int): The vehicle ID.

sensorPosition(Point3F): The position of the Lidar sensor either in vehicle space (if attached to vehicle) or in world space (if fixed to the map).

sensorDirection(Point3F): The direction in which the Lidar sensor points.

verticalResolution(int): The vertical resolution of the Lidar sensor.

verticalAngle(float): The vertical angle (field of view), in radians.

raysPerSecond(float): Number of laser measurements per second.

frequency(float): The frequency (refresh rate).

horizontalAnglefloat): The horizontal angle (field of view), in radians.

maxDistance(float): The maximum distance at which the Lidar sensor can detect, in metres.

isVisualised(bool): A flag which indicates if the Lidar sensor should be visualised.

isAnnotated(bool): A flag which indicates if the Lidar sensor should be annotated (must also be visualised).

isStatic(bool): True if the Lidar sensor is fixed to a point on the map, false if it is attached to a vehicle.

isSnappingDesired(bool): True if the Lidar sensor position should be forced onto the surface of the vehicle, at its closest vehicle point. This is useful if finding it hard to have the Lidar on the vehicle itself. False, otherwise, eg if the Lidar should be suspended at a fixed point relative to the vehicle.

isForceInsideTriangle(bool): Used with isSnappingDesired. True, if the Lidar should be forced to be inside its nearest vehicle triangle. Otherwise false.


points = extensions.tech_sensors.getLidarPointCloud(sensorId)

Args:

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

Returns: table(Point3F): The most-recent point cloud data from the Lidar sensor.


sensorPosition = extensions.tech_sensors.getLidarSensorPosition(sensorId)

Args:

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

Returns: sensorPosition(Point3F): The current world-space position of the Lidar sensor.


sensorDirection = extensions.tech_sensors.getLidarSensorDirection(sensorId)

Args:

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

Returns: sensorDirection(Point3F): The current direction of the Lidar sensor.


verticalResolution = extensions.tech_sensors.getLidarVerticalResolution(sensorId)

Args:

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

Returns: verticalResolution(int): The vertical resolution of the Lidar.


raysPerSecond = extensions.tech_sensors.getLidarRaysPerSecond(sensorId)

Args:

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

Returns: raysPerSecond(float): The number of rays per second of the Lidar.


frequency = extensions.tech_sensors.getLidarFrequency(sensorId)

Args:

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

Returns: frequency(float): The frequency (refresh rate) of the Lidar.


isVisualised = extensions.tech_sensors.getLidarIsVisualised(sensorId)

Args:

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

Returns: isVisualised(bool): A flag which indicates if the Lidar is being visualised or not.


isAnnotated = extensions.tech_sensors.getLidarIsAnnotated(sensorId)

Args:

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

Returns: isAnnotated(bool): A flag which indicates if the Lidar has annotations switched on or not.


extensions.tech_sensors.setLidarVerticalResolution(sensorId, verticalResolution)

Args:

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

verticalResolution(int): The new vertical resolution of the Lidar.

Returns: nil.


extensions.tech_sensors.setLidarRaysPerSecond(sensorId, raysPerSecond)

Args:

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

raysPerSecond(float): The new number of rays per second which the Lidar should use.

Returns: nil.


extensions.tech_sensors.setLidarFrequency(sensorId, frequency)

Args:

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

frequency(float): The new frequency of the Lidar.

Returns: nil.


extensions.tech_sensors.setLidarMaxDistance(sensorId, maxDistance)

Args:

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

maxDistance(float): The new maximum distance at which the Lidar can detect.

Returns: nil.


extensions.tech_sensors.setLidarIsVisualised(sensorId, isVisualised)

Args:

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

isVisualised(bool): True if the Lidar should be visualised, otherwise false.

Returns: nil.


extensions.tech_sensors.setLidarIsAnnotated(sensorId, isAnnotated)

Args:

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

isAnnotated(bool): True if the Lidar should be annotated, otherwise false.

Returns: nil.


extensions.tech_sensors.removeLidar(sensorId)

Args:

sensorId(int): The ID number of the Lidar sensor to remove.

Returns: nil.


Last modified: 27/6/2022 17:43
On this page:

Any further questions?

Join our discord