Skip to content

inertialsim.sensors.imu

Inertial Measurement Unit (IMU) simulation.

Classes:

Name Description
IMUModel

Specify which sources of error to simulate.

IMUSpecification

IMU sensor specification.

IMUData

IMU simulation results.

IMU

IMU sensor simulation.

IMUModel

IMUModel()

Specify which sources of error to simulate.

By default all sources of error are simulated.

Default specifications

Sensor specification parameters default to zero (or identity). Unspecified parameters will have no effect on the simulation result regardless of the settings here.

Methods:

Name Description
reset

Reset model parameters to their defaults.

set_all

Set all model parameters.

Attributes:

Name Type Description
data_interface
gyro
accelerometer

data_interface instance-attribute

data_interface = DataInterfaceModel()

gyro instance-attribute

gyro = SensorModel()

accelerometer instance-attribute

accelerometer = SensorModel()

reset

reset() -> None

Reset model parameters to their defaults.

set_all

set_all(*, value: bool) -> None

Set all model parameters.

All model parameters will be set to the input value, True or False.

Parameters:

Name Type Description Default
value bool

True or False.

required

IMUSpecification

IMUSpecification(axes: int = NUM_CARTESIAN_AXES)

IMU sensor specification.

An IMU sensor specification includes the parameters required to simulate IMU response to ideal inputs. These include input limits, noise coefficients, biases, scale factors, and internal sensor misalignments for gyro and accelerometer components.

IMU data interfaces

IMU specifications compose a gyro and an accelerometer specification with a single data interface. The gyro and accelerometer data interfaces are deleted from the composition and should not be accessed.

By default the specification returns a perfect sensor whose output will precisely match its sensed input. To simulated realistic sensors, set any of the relevant attributes. See the attribute documentation for further details and see the sensors/config module for examples.

Classes:

Name Description
IMUDataInterface

IMU interface parameters.

Attributes:

Name Type Description
data_interface IMUDataInterface
gyro GyroSpecification
accelerometer AccelerometerSpecification
axes int

The number of independent sensing axes of the sensor.

manufacturer str

The manufacturer of the sensor.

model str

The model number/identifier of the sensor.

version str

The version number/identifier of the sensor.

data_interface instance-attribute

data_interface: IMUDataInterface = IMUDataInterface(axes)

gyro instance-attribute

accelerometer instance-attribute

axes property

axes: int

The number of independent sensing axes of the sensor.

manufacturer property writable

manufacturer: str

The manufacturer of the sensor.

model property writable

model: str

The model number/identifier of the sensor.

version property writable

version: str

The version number/identifier of the sensor.

IMUDataInterface

IMUDataInterface(axes: int)

Bases: DataInterface

IMU interface parameters.

The data interface of the IMU. The IMU interface includes the data rate, which is the frequency at which the sensor transmits new data, the data type, and any digital quantization in the data.

Methods:

Name Description
sample_rate
delta_sample_rate

Attributes:

Name Type Description
delta_stride int

Integer number of rate outputs per delta output.

quantization tuple[Parameter | None, Parameter | None]

Data interface rate output quantization.

delta_quantization tuple[Parameter | None, Parameter | None]

Data interface delta output quantization.

delta_stride property

delta_stride: int

Integer number of rate outputs per delta output.

quantization property writable

quantization: tuple[Parameter | None, Parameter | None]

Data interface rate output quantization.

Outputs will be quantized at simulated digital levels. Use this when the parameters of the analog to digital conversion are known. If the sensor to simulate has been characterized experimentally, e.g. by the Allan deviation method, use Noise.quantization instead. Do not use both. Values are a tuple of two Parameters with the first applying to the gyros and the second applying to the accelerometers. Units must be one of: "rad/s/LSB" or "deg/s/LSB" for gyros and "m/s/s/LSB", "g/LSB", or "ft/s/s/LSB" for accelerometers. Default value = (None, None)

delta_quantization property writable

delta_quantization: tuple[
    Parameter | None, Parameter | None
]

Data interface delta output quantization.

Outputs will be quantized at simulated digital levels. Use this when the parameters of the analog to digital conversion are known. If the sensor to simulate has been characterized experimentally, e.g. by the Allan deviation method, use Noise.quantization instead. Do not use both. Values are a tuple of two Parameters with the first applying to the gyros and the second applying to the accelerometers. Units must be one of: rad/LSB or deg/LSB for gyro delta angles and m/s/LSB or ft/s/LSB for accelerometer delta velocity. Default value = (None, None)

sample_rate

sample_rate(data_rate: Parameter) -> None

delta_sample_rate

delta_sample_rate(data_rate: Parameter) -> None

IMUData dataclass

IMUData(
    *, gyro: GyroData, accelerometer: AccelerometerData
)

IMU simulation results.

An instance of this class is returned from the IMU.simulate method. It contains the simulated gyro and accelerometer measurements.

Attributes:

Name Type Description
gyro GyroData
accelerometer AccelerometerData
angular_rate Measurement

Gyro angular rate measurements.

delta_angle Measurement | None

Gyro delta angle measurements, if available.

specific_force Measurement

Accelerometer specific force measurements.

delta_velocity Measurement | None

Accelerometer delta velocity measurements, if available.

gyro instance-attribute

gyro: GyroData

accelerometer instance-attribute

accelerometer: AccelerometerData

angular_rate property

angular_rate: Measurement

Gyro angular rate measurements.

delta_angle property

delta_angle: Measurement | None

Gyro delta angle measurements, if available.

specific_force property

specific_force: Measurement

Accelerometer specific force measurements.

delta_velocity property

delta_velocity: Measurement | None

Accelerometer delta velocity measurements, if available.

IMU

IMU(
    model: IMUModel,
    specification: IMUSpecification,
    rng: Generator | int | None = None,
)
IMU(
    model: IMUModel,
    specification: IMUSpecification,
    rng: Generator | int | None = None,
    *,
    mode: str = "real-time",
    max_duration: float,
)
IMU(
    model: IMUModel,
    specification: IMUSpecification,
    rng: Generator | int | None = None,
    *,
    mode: str = "batch",
    max_duration: float | None = None,
)

IMU sensor simulation.

IMUs requires a model which specifies which sources of error to simulate; a specification which includes the parameters necessary to model deterministic and random errors; and optionally a random number generator or seed to control determinism and repeatability of the simulation.

Two modes are supported: batch (default) and real-time. In batch mode, the simulate() method should be called once with all inputs to return all simulated measurement outputs. In real-time mode, the simulate() method can be called repeatedly to incrementally simulate measurements. In real-time mode, a max_duration input (specified in seconds) should supply an upper bound on the expected simulation duration. If the expected duration is unknown it is safe and efficient to specify a value up to several hours.

Parameters:

Name Type Description Default
model IMUModel

IMU model.

required
specification IMUSpecification

IMU specification.

required
rng Generator | int | None

Random number generator or seed. See numpy.random.default_rng.

None
mode str

One of batch (default) or real-time.

'batch'
max_duration float | None

The maximum simulation duration in seconds. Used if simulating in real-time mode to precompute correlated noise terms.

None

Methods:

Name Description
simulate

Simulate IMU measurements from kinematic inputs.

Attributes:

Name Type Description
state tuple[SimulationState, SimulationState]

Simulation state.

state property

Simulation state.

Return the internal gyro and accelerometer simulation states. Each state includes the sensor model; the sensor specification; the random number generator state at initialization; and the value of all internal sensor parameters required to replicate the simulated measurement outputs.

simulate

simulate(
    *,
    angular_rate: Vector,
    specific_force: Vector,
    global_pose: GlobalPose | None = None,
    temperature: ArrayLike | None = None,
) -> IMUData
simulate(
    *,
    angular_rate: Vector,
    acceleration: Vector,
    global_pose: GlobalPose,
    temperature: ArrayLike | None = None,
) -> IMUData
simulate(
    *,
    global_pose: GlobalPose,
    temperature: ArrayLike | None = None,
) -> IMUData
simulate(
    *,
    angular_rate: Vector | None = None,
    specific_force: Vector | None = None,
    acceleration: Vector | None = None,
    global_pose: GlobalPose | None = None,
    temperature: ArrayLike | None = None,
) -> IMUData

Simulate IMU measurements from kinematic inputs.

An IMU composes a gyro and an accelerometer so see Gyro.simulate and Accelerometer.simulate for additional documentation regarding each input. Inputs must have matching shape and time.

All inputs are optional. Measurement outputs are calculated based on the best available inputs. Insufficient inputs to calculate a valid output will raise a ValueError.

Measurement output sample rate(s) will match the input sample rate. In batch mode (default), if the simulate_sample_rate model option is True, the output sample rate(s) will match the sample rate(s) in the sensor specification. Linear interpolation of angular rate and specific force is used for the resampling.

All inputs are reduced to specific force and angular rate internally and sources of error from the IMU specification are then applied to produce the measurement output(s).

The supported combination of inputs are:

angular_rate + specific_force: the angular rate input must be the angular rate of the gyro relative to an inertial frame as measured in gyro coordinates. With these inputs, it is not possible to include the effect of Earth's rotation in the measured output. For this reason, the angular rate can also be relative to a fixed navigation frame (also known as world, or global frame) if Earth's rotation is not important for the application. The specific force input must be the specific force (non-gravitational acceleration) acting on the accelerometer as measured in accelerometer coordinates. The input must already account for the effect of gravity.

angular_rate + specific_force + global_pose: the angular rate input must be the angular rate of the gyro relative to an Earth fixed navigation frame (also known as world, or global frame) as measured in gyro coordinates. The effect of Earth's rotation will be added to the input based on the global_pose data to produce angular rate relative to inertial space. If needed, the global_pose input will be interpolated to match the times of the angular_rate input. For this reason, global_pose time stamps must match or span the entire duration of the angular_rate input. The specific force input must be the specific force (non-gravitational acceleration) acting on the accelerometer as measured in accelerometer coordinates. The input must already account for the effect of gravity.

angular_rate + acceleration + global_pose: the angular rate input must be the angular rate of the gyro relative to an Earth fixed navigation frame (also known as world, or global frame) as measured in gyro coordinates. The effect of Earth's rotation will be added to the input based on the global_pose data to produce angular rate relative to inertial space. The acceleration input must be the total acceleration (including gravity) acting on the accelerometer as measured in accelerometer coordinates. The effect of Earth's gravity (not measured by the accelerometer) will be compensated based on the global_pose data to produce specific force. If needed, the global_pose input will be interpolated to match the times of the angular_rate and acceleration inputs. For this reason, global_pose time stamps must match or span the entire duration of the other inputs.

global_pose: acceleration is numerically calculated as the first forward difference of the global velocity (if available) or the second forward difference of the global position. The effect of Earth's gravity (not measured by the accelerometer) will be compensated to produce specific force. Angular rate is numerically calculated as the first forward difference of the global attitude. The effect of Earth's rotation will be compensated to produce angular rate relative to inertial space. At least two poses must be supplied. In real-time mode, overlapping inputs should be supplied, e.g. pairwise poses (1-2, 2-3, 3-4, ...).

The temperature input is always optional. If included, it will be used in combination with any temperature dependent specifications when simulating measurement outputs.

Parameters:

Name Type Description Default
angular_rate Vector | None

Angular rate experienced by the IMU.

None
specific_force Vector | None

Specific force experienced by the IMU.

None
acceleration Vector | None

Total acceleration experienced by the IMU.

None
global_pose GlobalPose | None

Attitude and position of the IMU relative to Earth.

None
temperature ArrayLike | None

Array of temperatures corresponding to the primary input (degrees C).

None

Returns:

Name Type Description
result IMUData

IMUResult instance.