Inertial Measurement Units

Deprecation Notice

This sensor is to be deprecated. Please instead use the more comprehensive Advanced IMU sensor instead.

Overview

Inertial Measurement Units provide data about rotational acceleration of and forces acting on the unit. BeamNG Tech provides a simulated version of such units that can be attached at arbitrary points of the vehicle. Contrary to their real life equivalent, these units are weight- and formless, meaning they have no impact on the driving behavior and are invisible. For debugging purposes, they can be visualized, however.

Usage

The IMUs are provided through an extension loadable in a vehicle’s Lua VM. To load it, issue the following command in a vehicle:

extensions.load('imu')

This will make the IMU extension available to the vehicle. What follows is a breakdown of each function this extension exposes.

addIMU

imu.addIMU(name, pos, [debug])

Used to add an IMU at a certain position relative to the vehicle. IMUs are given a name that’s supposed to be unique for later reference during removal. It is crucial to note that the IMU’s position is relative to the vehicle’s coordinate space – relative to the RefNode. This means an IMU added at location (0, 1, 0) will always end up in the same spot, regardless of where the vehicle is in the world, but also means exact coordinates need to be determined first. One recommended way to do so is to use the Vehicle Editor. The debug flag is an optional boolean which enables debug visualization of the IMU to be added.

addIMUAtNode

imu.addIMUAtNode(name, node, [debug])

Similar to imu.addIMU but instead of a position is given a node ID of the node the IMU is placed at. Other arguments are used the same way.

removeIMU

imu.removeIMU(name)

Removes the IMU of the given name. The IMU that was removed is returned and the function returns nil if no IMU of the given name was found.

getIMU

imu.getIMU(name)

Retrieves an IMU of the given name. If no IMU with a matching name is found, nil is returned. Otherwise, the IMU is returned as a table. The structure of that table is explained below.

IMU Structure

IMUs are presented as Lua tables with various fields containing measurement data. An example IMU looks like this:

{
  a = 430,
  aX = 0.00046557877210677,
  aY = 4.8179574853672e-05,
  aZ = 0.0015101531196775,
  b = 434,
  c = 433,
  d = 0.11710267271508,
  debug = true,
  gX = -3.9092405963171,
  gY = -5.8214835947941,
  gZ = 0.026276952910208,
  lX = -0.10393915662027,
  lY = 0.028109545925439,
  lZ = 0.25954606025934,
  name = "hello",
  pos = vec3(0.73,0.51,0.8),
  u = 0.25539744090396,
  v = 0.19280339786285,
  w = 0.55179916123319
}

Key fields are:

  • aX, aY, aZ: Rotational acceleration on each axis
  • gX, gY, gZ: Measured forces on each axis

Other fields are mainly used for computations and do not contain actual sensor data. Modifying these fields is not recommended as it will likely make measurements inaccurate.

Last modified: 18/9/2023 10:26

Any further questions?

Join our discord