Overview
The Mesh Info Sensor provides the distribution of the various scalar and vector quantities across the vehicle, including mass, force, velocity, and stress. The data is time-stamped and also includes positional data for the nodes.
Usage
The Mesh Info Sensor code is written in Lua directly, rather than C++ (like some other sensors). It has a very similar API to the other sensors in our suite.
The sensor readings are typically polled from vlua.
For other usage examples with this sensor, please look at the beamNGpy scripts.
sensorId = extensions.tech_sensors.createMeshSensor(vehicleId, args)
Args:
vehicleID(int): The vehicle ID. This cannot be nil - the mesh sensor must be attached to a vehicle.
The args parameter is a Lua table containing as many of the following properties as required. If any property is not set manually then a default value is used, so it is entirely possible to create the mesh sensor with args being an empty table. What follows is a complete list of these arguments:
GFXUpdateTime(float): How often the mesh 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 mesh readings (in seconds). This parameter should be smaller than GFXUpdateTime, and can be as small as 1/2000 seconds, since this is currently the rate at which the physics steps cycles. This value determines how often we poll the mesh to get a snapshot of data at a given time, so the smaller this is, the more accurate the readings will be.
Returns: sensorId(int): The unique Id number of this sensor, in order to refer to it later eg when closing it.
readings = getMeshReading()
The Mesh Info Sensor belongs in vlua, and to poll it, the mesh.lua extension is used. This extension is where the getMeshReading() function is found.
Returns: readings(table): A table containing all the latest Mesh Info Sensor readings.
extensions.tech_sensors.setMeshUpdateTime(sensorId, updateTime)
Args:
sensorId(int): The ID number of the mesh sensor.
updateTime(float): The new update time for this sensor.
Returns: nil
The following three functions can be used to send ad-hoc polling requests to a mesh sensor. This is for when we just want an
occasional reading. We need to first send a request using sendMeshRequest
, then wait for it. We can check it is complete using
isVluaRequestComplete
(see below), then retrieve it using collectMeshRequest
.
requestId = extensions.tech_sensors.sendMeshRequest(sensorId)
Args:
sensorId(int): The ID number of the mesh sensor.
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.collectMeshRequest(requestId)
Args:
requestId(int): The ID number of the ad-hoc sensor polling request.
Returns: data(vec3): The mesh sensor readings.
extensions.tech_sensors.removeMeshSensor(sensorId)
Args:
sensorId(int): The ID number of the mesh sensor to remove.
Returns: nil.