inertialsim.sensors
¶
Sensor specification and simulation.
The sensors module provides:
- classes to simulate gyroscope, accelerometer, and IMU sensor measurements from a wide variety of inputs (combinations of angular rate, specific force, acceleration, orientation, velocity, position and pose in local and global coordinate frames)
- classes to specify sensor parameters in customary units with automatic conversion to SI units
- classes to represent sensor simulation outputs (measurements, simulation state, and metadata)
Modules:
Name | Description |
---|---|
accelerometer |
Accelerometer simulation. |
gyro |
Gyro simulation. |
imu |
Inertial Measurement Unit (IMU) simulation. |
magnetometer |
Magnetometer simulation. |
Classes:
Name | Description |
---|---|
Measurement |
Sensor measurement data. |
InertialSensorModel |
Inertial sensor model options. |
SensorModel |
Sensor model options. |
InertialSensor |
A base class for representing inertial sensors. |
Sensor |
An abstract base class for representing sensors. |
SimulationState |
Simulation metadata. |
InertialSensorSpecification |
Base class specification for inertial sensors. |
Parameter |
A parameter with value and associated units. |
SensorSpecification |
Sensor specification abstract base class. |
InertialSensorState |
Inertial sensor internal state. |
SensorState |
Sensor internal state. |
Measurement
¶
Sensor measurement data.
Time sampled sensor measurement data. Measurement data can be timestamped with a time of validity for each measurement datum or can be uniformly sampled at a fixed rate. Measurements can consist of any number of channels (e.g. 3-axis sensors have 3 channels). There is no assumption that channels are independent, measurement data in each channel may be correlated or duplicated (such as results when non-orthogonal sensing axes measure a common input).
Use the from
methods to construct an instance. Do not initialize an
instance directly.
Methods:
Name | Description |
---|---|
from_timestamped_data |
Construct a Measurement from timestamped data. |
from_sampled_data |
Construct a Measurement from uniformly sampled data. |
from_measurements |
Construct a Measurement from a collection of Measurements. |
Attributes:
Name | Type | Description |
---|---|---|
data |
|
|
time |
|
|
sample_rate |
|
|
num_measurements |
int
|
The number of measurement samples. |
num_channels |
int
|
The number of independent channels or axes of measurement. |
num_channels
property
¶
num_channels: int
The number of independent channels or axes of measurement.
from_timestamped_data
classmethod
¶
from_timestamped_data(
*,
data: ArrayLike,
time: ArrayLike,
sample_rate: float | None = None,
) -> Self
Construct a Measurement from timestamped data.
Measurement data can be any array-like input with shape in ((N,),
(N,1), (N,1,1), (N,M), (N,M,1))
where N is the time index of samples
and M is the channel (or axis) index.
If sample_rate
is input, the time
input is checked for consistency
with it. If sample_rate
is None, the median sample rate of the time
input is used. If only one data point is input, sample_rate
must be
supplied because it cannot be calculated.
The inputs are copied to prevent unexpected side effects.
Input shape
A 3-axis gyro sampled at 100Hz for 1 second will result in data with
shape=(100,3)
or shape=(100,3,1)
. This is 100 samples with 3
channels.
Sample rate inconsistencies
Sample rate inconsistencies must be avoided in inertial algorithms that require numerical differentiation, integration, or interpolation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Array of measurements. |
required |
time
|
ArrayLike
|
Array of unique, strictly increasing times corresponding to each measurement sample. |
required |
sample_rate
|
float | None
|
Expected sample rate (Hz). |
None
|
Returns:
Name | Type | Description |
---|---|---|
measurement |
Self
|
Measurement instance. |
from_sampled_data
classmethod
¶
Construct a Measurement from uniformly sampled data.
Measurement data can be any array-like input with shape in ((N,),
(N,1), (N,1,1), (N,M), (N,M,1))
where N is the time index of samples
and M is the channel (or axis) index.
A time span is constructed internally using the
sample_rate
input such that a unique timestamp is associated with each
measurement sample.
The inputs are copied to prevent unexpected side effects.
Input shape
A 3-axis gyro sampled at 100Hz for 1 second will result in data with
shape=(100,3)
or shape=(100,3,1)
. This is 100 samples with 3
channels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Array of measurements. |
required |
sample_rate
|
float
|
Measurement sample rate (Hz). |
required |
Returns:
Name | Type | Description |
---|---|---|
measurement |
Self
|
Measurement instance. |
from_measurements
classmethod
¶
from_measurements(measurements: list[Self]) -> Self
Construct a Measurement from a collection of Measurements.
An efficient strategy for accumulating data is to store intermediate values in a list (or other container). This occurs, for example, when incrementally simulating Gyro, Accelerometer, or IMU outputs. This method allows for merging the result into a single Measurement instance once complete. See the example below.
Inputs do not need to be of the same dimension but they must have consistent sample rates, channel counts, and timestamps. The sample rate and time inputs are checked for consistency as described in the from_timestamped_data method.
Incremental simulation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
measurements
|
list[Self]
|
List of Measurement instances. |
required |
Returns:
Name | Type | Description |
---|---|---|
measurement |
Self
|
Measurement instance. |
InertialSensorModel
dataclass
¶
InertialSensorModel(
*,
data_interface: DataInterface = DataInterface(),
misalignment: Misalignment = Misalignment(),
input_limits: InputLimits = InputLimits(),
bias: Bias = Bias(),
noise: Noise = Noise(),
scale_factor: ScaleFactor = ScaleFactor(),
)
Bases: SensorModel
Inertial sensor model options.
Specify model options for simulating inertial sensor errors and inertial sensor data interfaces. These model options are suitable for both gyro and accelerometer sensors. By default all supported sources of error are simulated. By default, delta angle and delta velocity data outputs are not 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. See for example GyroSpecification.
Classes:
Name | Description |
---|---|
Misalignment |
Misalignment simulation options. |
InputLimits |
Input limits simulation options. |
Bias |
Bias simulation options. |
ScaleFactor |
Scale factor simulation options. |
DataInterface |
Data interface simulation options. |
Noise |
Noise simulation options. |
Methods:
Name | Description |
---|---|
reset |
Reset model parameters to their defaults. |
set_all |
Set all model parameters. |
Attributes:
Name | Type | Description |
---|---|---|
misalignment |
Misalignment
|
Misalignment simulation options. |
input_limits |
InputLimits
|
Input limits simulation options. |
bias |
Bias
|
Bias simulation options. |
scale_factor |
ScaleFactor
|
Scale factor simulation options. |
data_interface |
DataInterface
|
Data interface simulation options. |
noise |
Noise
|
Noise simulation options. |
misalignment
class-attribute
instance-attribute
¶
misalignment: Misalignment = field(
default_factory=Misalignment
)
Misalignment simulation options.
input_limits
class-attribute
instance-attribute
¶
input_limits: InputLimits = field(
default_factory=InputLimits
)
Input limits simulation options.
bias
class-attribute
instance-attribute
¶
Bias simulation options.
scale_factor
class-attribute
instance-attribute
¶
scale_factor: ScaleFactor = field(
default_factory=ScaleFactor
)
Scale factor simulation options.
data_interface
class-attribute
instance-attribute
¶
data_interface: DataInterface = field(
default_factory=DataInterface
)
Data interface simulation options.
noise
class-attribute
instance-attribute
¶
Noise simulation options.
Misalignment
dataclass
¶
Misalignment(*, simulate_random: bool = True)
Misalignment simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_random |
bool
|
Simulate random sensing axis misalignment. |
InputLimits
dataclass
¶
Input limits simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_minimum |
bool
|
Simulate minimum sensed value. |
simulate_maximum |
bool
|
Simulate maximum sensed value. |
Bias
dataclass
¶
Bias(
*,
simulate_fixed: bool = True,
simulate_random: bool = True,
simulate_temperature: bool = True,
)
Bias simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_fixed |
bool
|
Simulate fixed bias offset. |
simulate_random |
bool
|
Simulate random bias offset. |
simulate_temperature |
bool
|
Simulate temperature dependent bias offset. |
ScaleFactor
dataclass
¶
Scale factor simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_fixed |
bool
|
|
simulate_random |
bool
|
|
DataInterface
dataclass
¶
DataInterface(
*,
simulate_sample_rate: bool = True,
simulate_quantization: bool = True,
simulate_delta_outputs: bool = False,
)
Bases: DataInterface
Data interface simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_sample_rate |
bool
|
Simulate sensor data sample rate. |
simulate_quantization |
bool
|
Simulate sensor data quantization. |
simulate_delta_outputs |
bool
|
Simulate delta (pre-integrated) sensor outputs. |
Noise
dataclass
¶
Noise(
*,
simulate_quantization: bool = True,
simulate_random_walk: bool = True,
simulate_bias_instability: bool = True,
simulate_rate_random_walk: bool = True,
simulate_rate_ramp: bool = True,
)
Bases: Noise
Noise simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_wgn |
bool
|
Simulate white, Gaussian noise. |
simulate_quantization |
bool
|
Simulate rate quantization noise. |
simulate_bias_instability |
bool
|
Simulate bias instability noise. |
simulate_rate_random_walk |
bool
|
Simulate rate random walk noise. |
simulate_rate_ramp |
bool
|
Simulate rate ramp noise. |
simulate_random_walk |
bool
|
Simulate random walk noise. Alias for |
simulate_wgn
class-attribute
instance-attribute
¶
simulate_wgn: bool = True
Simulate white, Gaussian noise.
simulate_quantization
class-attribute
instance-attribute
¶
simulate_quantization: bool = simulate_quantization
Simulate rate quantization noise.
simulate_bias_instability
class-attribute
instance-attribute
¶
simulate_bias_instability: bool = simulate_bias_instability
Simulate bias instability noise.
simulate_rate_random_walk
class-attribute
instance-attribute
¶
simulate_rate_random_walk: bool = simulate_rate_random_walk
Simulate rate random walk noise.
SensorModel
dataclass
¶
SensorModel(
*,
data_interface: DataInterface = DataInterface(),
misalignment: Misalignment = Misalignment(),
input_limits: InputLimits = InputLimits(),
bias: Bias = Bias(),
noise: Noise = Noise(),
scale_factor: ScaleFactor = ScaleFactor(),
)
Sensor model options.
Specify model options for simulating generic sensor errors and data interfaces. These model options are suitable for many types of sensors. By default all supported 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. See SensorSpecification.
Classes:
Name | Description |
---|---|
DataInterface |
Data interface simulation options. |
Misalignment |
Misalignment simulation options. |
InputLimits |
Input limits simulation options. |
Bias |
Bias simulation options. |
Noise |
Noise simulation options. |
ScaleFactor |
Scale factor simulation options. |
Methods:
Name | Description |
---|---|
reset |
Reset model parameters to their defaults. |
set_all |
Set all model parameters. |
Attributes:
Name | Type | Description |
---|---|---|
data_interface |
DataInterface
|
Data interface simulation options. |
misalignment |
Misalignment
|
Misalignment simulation options. |
input_limits |
InputLimits
|
Input limits simulation options. |
bias |
Bias
|
Bias simulation options. |
noise |
Noise
|
Noise simulation options. |
scale_factor |
ScaleFactor
|
Scale factor simulation options. |
data_interface
class-attribute
instance-attribute
¶
data_interface: DataInterface = field(
default_factory=DataInterface
)
Data interface simulation options.
misalignment
class-attribute
instance-attribute
¶
misalignment: Misalignment = field(
default_factory=Misalignment
)
Misalignment simulation options.
input_limits
class-attribute
instance-attribute
¶
input_limits: InputLimits = field(
default_factory=InputLimits
)
Input limits simulation options.
bias
class-attribute
instance-attribute
¶
Bias simulation options.
noise
class-attribute
instance-attribute
¶
Noise simulation options.
scale_factor
class-attribute
instance-attribute
¶
scale_factor: ScaleFactor = field(
default_factory=ScaleFactor
)
Scale factor simulation options.
DataInterface
dataclass
¶
Data interface simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_sample_rate |
bool
|
Simulate sensor data sample rate. |
simulate_quantization |
bool
|
Simulate sensor data quantization. |
Misalignment
dataclass
¶
Misalignment(*, simulate_random: bool = True)
Misalignment simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_random |
bool
|
Simulate random sensing axis misalignment. |
InputLimits
dataclass
¶
Input limits simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_minimum |
bool
|
Simulate minimum sensed value. |
simulate_maximum |
bool
|
Simulate maximum sensed value. |
Bias
dataclass
¶
Bias(
*,
simulate_fixed: bool = True,
simulate_random: bool = True,
simulate_temperature: bool = True,
)
Bias simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_fixed |
bool
|
Simulate fixed bias offset. |
simulate_random |
bool
|
Simulate random bias offset. |
simulate_temperature |
bool
|
Simulate temperature dependent bias offset. |
Noise
dataclass
¶
Noise(*, simulate_wgn: bool = True)
Noise simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_wgn |
bool
|
Simulate white, Gaussian noise. |
ScaleFactor
dataclass
¶
Scale factor simulation options.
Attributes:
Name | Type | Description |
---|---|---|
simulate_fixed |
bool
|
|
simulate_random |
bool
|
|
InertialSensor
¶
InertialSensor(
model: InertialSensorModel,
specification: InertialSensorSpecification,
rng: Generator | int | None = None,
mode: str = "batch",
max_duration: float | None = None,
)
Bases: Sensor
A base class for representing inertial sensors.
Accelerometers and gyroscopes inherit common attributes and methods.
Sensors requires a model which specifies which sources of error to simulate; a specification which includes the parameters necessary to model deterministic and stochastic errors; and optionally a random number generator or seed to control determinism and repeatability of the simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
InertialSensorModel
|
Model options. |
required |
specification
|
InertialSensorSpecification
|
Sensor specification. |
required |
rng
|
Generator | int | None
|
Random number generator or seed. See numpy.random.default_rng. |
None
|
mode
|
str
|
One of |
'batch'
|
max_duration
|
float | None
|
The maximum duration to precompute noise samples. If simulating in real-time mode, the maximum number of calls to the _simulate_from_rate() method that can be made is max_duration * sample_rate. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
state |
SimulationState
|
Simulation state. |
state
property
¶
state: SimulationState
Simulation state.
Return the simulation state. The 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.
Sensor
¶
Sensor(
model: SensorModel,
specification: SensorSpecification,
rng: Generator | int | None = None,
mode: str = "batch",
max_duration: float | None = None,
)
Bases: ABC
An abstract base class for representing sensors.
Sensors inherit common attributes and methods.
Sensors requires a model which specifies which sources of error to simulate; a specification which includes the parameters necessary to model deterministic and stochastic errors; and optionally a random number generator or seed to control determinism and repeatability of the simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
SensorModel
|
Model options. |
required |
specification
|
SensorSpecification
|
Sensor specification. |
required |
rng
|
Generator | int | None
|
Random number generator or seed. See numpy.random.default_rng. |
None
|
mode
|
str
|
One of |
'batch'
|
max_duration
|
float | None
|
The maximum duration to precompute noise samples. If simulating in real-time mode, the maximum number of calls to the _simulate_from_rate() method that can be made is max_duration * sample_rate. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
state |
SimulationState
|
Simulation state. |
state
property
¶
state: SimulationState
Simulation state.
Return the simulation state. The 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.
SimulationState
dataclass
¶
SimulationState(
*,
model: SensorModel,
specification: SensorSpecification,
rng: Mapping,
sensor: SensorState,
)
Simulation metadata.
Inputs and internal state sufficient to regenerate simulation results.
Sensor model options, and sensor specification parameters are user inputs.
Along with the state
field of the numpy.random.BitGenerator stored in
the random number generator, they are sufficient to duplicate a simulation.
The state data records the fixed and random errors applied to the simulation
input that resulted in the output.
Attributes:
Name | Type | Description |
---|---|---|
model |
SensorModel
|
|
specification |
SensorSpecification
|
|
rng |
Mapping
|
|
sensor |
SensorState
|
|
InertialSensorSpecification
¶
InertialSensorSpecification(axes: int = NUM_CARTESIAN_AXES)
Bases: SensorSpecification
Base class specification for inertial sensors.
A generic inertial sensor specification that includes data interface, input limits, noise coefficients, biases, scale factors, and sensor misalignments. These specification options are suitable for both gyro and accelerometer sensors.
Derived classes must implement the abstract attributes and methods.
Classes:
Name | Description |
---|---|
InputLimits |
Sensor input limits specification. |
Bias |
Sensor bias specification. |
ScaleFactor |
Sensor scale factor specification. |
Misalignment |
Sensor misalignment specification. |
DataInterface |
An abstract base class for data interface specifications. |
Noise |
Sensor noise specification. |
Attributes:
Name | Type | Description |
---|---|---|
manufacturer |
str
|
Manufacturer of the sensor. |
model |
str
|
Model number/identifier of the sensor. |
version |
str
|
Version number/identifier of the sensor. |
input_limits |
InputLimits
|
|
bias |
Bias
|
|
scale_factor |
ScaleFactor
|
Sensor scale factor specification. |
misalignment |
Misalignment
|
Sensor misalignment specification. |
axes |
int
|
Number of independent sensing axes of the sensor. |
data_interface |
DataInterface
|
|
noise |
Noise
|
|
scale_factor
instance-attribute
¶
scale_factor: ScaleFactor = ScaleFactor(axes)
Sensor scale factor specification.
misalignment
instance-attribute
¶
misalignment: Misalignment = Misalignment(axes)
Sensor misalignment specification.
InputLimits
¶
InputLimits(axes: int)
Bases: ABC
Sensor input limits specification.
The extreme values of the input (negative and positive) within which performance is of the specified accuracy. Simulated outputs outside of this range are truncated to these limits.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
minimum |
Parameter
|
Minimum negative input. |
maximum |
Parameter
|
Maximum positive input. |
Bias
¶
Bias(axes: int)
Bases: ABC
Sensor bias specification.
Bias is the non-zero output of a sensor at rest, or equivalently, the output that has no correlation with the input. It is comprised of a fixed component (that can be calibrated), a random component (that may vary from turn-on to turn-on or with changing conditions), and a temperature dependent component.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
fixed |
Parameter
|
Fixed bias. |
repeatability |
Parameter
|
Random bias. |
temperature |
Parameter
|
Temperature bias. |
fixed
abstractmethod
property
writable
¶
fixed: Parameter
Fixed bias.
A fixed bias that is constant across all conditions. For many sensors, this may be removed by factory calibration in which case this parameter can represent any known residual error in that calibration.
repeatability
abstractmethod
property
writable
¶
repeatability: Parameter
Random bias.
The standard deviation of a random bias component that varies with each turn-on of the sensor and/or varies across external conditions. This parameter may represent unknown residuals from the factory calibration of a fixed bias.
ScaleFactor
¶
ScaleFactor(axes: int)
Sensor scale factor specification.
Scale factor is the ratio of change in output to change in input at the analog sensing elements.
A perfect sensor has a linear analog response with a scale of 1.0. Imperfect sensors may have a non-unit scale.
Attributes:
Name | Type | Description |
---|---|---|
fixed |
Parameter
|
Fixed scale factor error. |
repeatability |
Parameter
|
Random scale factor error. |
fixed
property
writable
¶
fixed: Parameter
Fixed scale factor error.
A fixed offset from the ideal unit scale factor (1.0) that is
constant across all conditions. For many sensors, this may be
removed by factory calibration in which case this parameter can
represent any known residual error in that calibration. Units are
ratios of similar quantities so must be one of: "dimensionless"
,
"%"
, or "ppm"
.
Default value = Parameter([0.0,0.0,0.0], "dimensionless")
.
repeatability
property
writable
¶
repeatability: Parameter
Random scale factor error.
The standard deviation of a random scale factor error that varies
with each turn-on of the sensor and/or varies across external
conditions. This parameter may represent unknown residuals from the
factory calibration of fixed scale factor. Units are ratios of
similar quantities so must be one of: "dimensionless"
, "%"
, or
"ppm"
.
Default value = Parameter([0.0,0.0,0.0], "dimensionless")
.
Misalignment
¶
Misalignment(axes: int)
Sensor misalignment specification.
Misalignment is the offset between the ideal orthogonal input reference axes (IRA) and the actual sensitive input axis (IA) of the sensor. It is comprised of a fixed component (that can be calibrated) and a random component (that may vary from turn-on to turn-on or with changing conditions).
See Standard [05] and Standard [06] for details.
Attributes:
Name | Type | Description |
---|---|---|
fixed |
Parameter
|
Fixed sensor alignment. |
repeatability |
Parameter
|
Random sensor misalignment. |
fixed
property
writable
¶
fixed: Parameter
Fixed sensor alignment.
Coordinate transform matrix converting 3-dimensional input reference
axes (IRA) to N-dimensional input axes (IA). IRA are also known as
platform axes and the IA are also known as accelerometer, gyro, or
sensor axes. The resulting matrix is Nx3 where N is the number of
measurement axes of the device. For an ideal sensor this will
typically be an identity matrix. For real sensors, the deviation
from identity represents the misalignment. This fixed misalignment
may be removed by factory calibration in which case this parameter
can represent any residual error in that calibration. Units must be
"dimensionless". For sensors with <= 3 axes, the default value is a
one-to-one map of input axes to the available output axes. For
example, in a default 2-axis sensor input x-y axes map to output x-y
axes: Parameter([[1,0,0],[0,1,0]],"dimensionless")
. The input
z-axis is not sensed. For sensors with > 3 axes, inputs are
duplicated in sequence to fill the output. For example, by default
a 4-axis sensor will duplicate the x input:
Parameter([[1,0,0],[0,1,0],[0,0,1],[1,0,0]],"dimensionless")
. This
is typically not how redundant sensor designs are aligned so users
should take care to supply the correct input in these cases. An
example of a single axis sensor with a fixed, known misalignment is:
Parameter([0.999,0.02,-0.04],"dimensionless")
. This maps IRA
inputs to a single output with a known misalignment.
Default value = Parameter(np.eye(3), "rad")
.
repeatability
property
writable
¶
repeatability: Parameter
Random sensor misalignment.
Standard deviation of a (small) random angle offset applied to the
each input axis (IA). Each axis is independently rotated, meaning
that the result is non-orthogonal. The random offset is applied as
a rotation vector with components sampled independently around each
of the 3 input reference axes (IRA). For example, a single axis
sensor has a default fixed axis of:
Parameter([1,0,0],"dimensionless")
. That axis will be rotated
according to:
rotation_vector = repeatability * rng.std_normal(shape=(3,1))
axis = Rotation.from_rotation_vector(rotation_vector) @ [1,0,0]
Parameter([0.999,0.02,-0.04],"dimensionless")
. This process is
repeated for each axis. This parameter may represent an unknown
residual from the factory calibration or an offset that varies with
changing conditions like packaging stress and shock. Units must be
one of: "rad"
or "deg"
.
Default value = Parameter([0.0,0.0,0.0], "rad")
per axis.
DataInterface
¶
DataInterface(axes: int)
Bases: DataInterface
An abstract base class for data interface specifications.
The data interface of the sensor. The sensor interface includes the sample rate, which is the frequency at which the sensor transmits new data, and the data type, which is one of rate or delta.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
sample_rate |
Parameter
|
The frequency at which new data is output from the sensor. |
quantization |
Parameter | None
|
Data interface output quantization. |
delta_sample_rate |
Parameter
|
The frequency at which delta type data is output from the sensor. |
delta_quantization |
Parameter | None
|
Data interface delta output quantization. |
delta_stride |
int
|
Integer number of rate outputs per delta output. |
sample_rate
property
writable
¶
sample_rate: Parameter
The frequency at which new data is output from the sensor.
Units must be "Hz"
.
Default value = Parameter(100, "Hz")
.
quantization
abstractmethod
property
writable
¶
quantization: Parameter | None
Data interface output quantization.
Outputs will be quantized at simulated digital levels. Use this when the parameters of the analog to digital conversion are known.
delta_sample_rate
property
writable
¶
delta_sample_rate: Parameter
The frequency at which delta type data is output from the sensor.
Units must be "Hz"
and must be a integer divisor of sample_rate
.
Default value = Parameter(0, "Hz")
meaning no delta outputs.
Noise
¶
Noise(axes: int)
Bases: Noise
Sensor noise specification.
Common inertial sensor noise terms describing quantization, random walk, bias instability, rate random walk, and rate ramp. See Reference [20] and Standard [05] & Standard [06] for details.
Each of these noise terms can be determined experimentally from Allan variance/deviation plots or from data sheets and direct knowledge of the sensor. Not all terms will be applicable to all sensors.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
quantization |
Parameter
|
Quantization noise. |
random_walk |
Parameter
|
Random walk noise. |
noise_density |
Parameter
|
Noise density. |
bias_instability |
Parameter
|
Bias instability noise. |
rate_random_walk |
Parameter
|
Rate random walk noise. |
rate_ramp |
Parameter
|
Rate ramp noise. |
quantization
abstractmethod
property
writable
¶
quantization: Parameter
Quantization noise.
Uniformly distributed random noise arising from digital quantization of the input. Use this parameter when the sensor to simulate has been characterized experimentally, e.g. by the Allan deviation method. If the parameters of the analog to digital converter are known explicitly, use ScaleFactor.quantization instead. Do not use both.
random_walk
abstractmethod
property
writable
¶
random_walk: Parameter
Random walk noise.
Random white noise in the signal that when integrated results in error buildup. Also known equivalently as noise density.
noise_density
property
writable
¶
noise_density: Parameter
Noise density.
Equivalent to random_walk noise term. Prefer using random_walk for inertial sensors to match the terminology of Standards [03], [04] and similar.
bias_instability
abstractmethod
property
writable
¶
bias_instability: Parameter
Bias instability noise.
The random variation in bias as computed over specified finite sampling time and averaging time intervals. Also known equivalently as bias in-run stability and flicker noise.
Parameter
¶
A parameter with value and associated units.
Parameters are used to set sensor specifications to ensure unit conversions are handled correctly. Parameter attributes are read only so that the value and units cannot be changed independently.
Attributes:
Name | Type | Description |
---|---|---|
value |
NDArray
|
Numeric value of the parameter (typically an array with each element applicable to one axis of the sensor). |
units |
str
|
String representing the units of the value (e.g. |
Methods:
Name | Description |
---|---|
per_axis |
Return a new Parameter with the value applied on a per-axis basis. |
to_si_units |
Return a new parameter in SI units. |
per_axis
¶
Return a new Parameter with the value applied on a per-axis basis.
If the parameter is specified as a single value, return a new parameter with an array of value replicated across the requested number of axes. If the parameter value is already a vector of the correct size and shape it is unchanged. The units field is unchanged.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axes
|
int
|
Number of axes. |
required |
Returns:
Name | Type | Description |
---|---|---|
parameter |
Parameter
|
New Parameter instance. The original is unchanged. |
to_si_units
¶
to_si_units() -> Parameter
Return a new parameter in SI units.
Returns a new Parameter object with the value and units fields converted to SI units.
Supported units
This function only supports common inertial sensor units. It does
not support conversion of arbitrary units. The numerator of the
units string can include any of "deg"
for degrees, "%"
, "ppm"
for parts-per-million, "ft"
for feet or "g"
for units of
standard gravity. The denominator(s) can include any of "/h"
for
per hour, "/sqrt(h)"
for per square-root hour, "/s/sqrt(Hz)"
for
per second per square root Hertz and "/F"
for per degree
Fahrenheit.
Returns:
Name | Type | Description |
---|---|---|
parameter |
Parameter
|
New Parameter instance. The original is unchanged. |
SensorSpecification
¶
SensorSpecification(axes: int = NUM_CARTESIAN_AXES)
Bases: ABC
Sensor specification abstract base class.
A generic inertial sensor specification that includes data interface, input limits, noise coefficients, biases, scale factors, and sensor misalignments.
Derived classes must implement the abstract attributes and methods.
Classes:
Name | Description |
---|---|
DataInterface |
Sensor data interface specification. |
InputLimits |
Sensor input limits specification. |
Noise |
Sensor noise specification. |
Bias |
Sensor bias specification. |
ScaleFactor |
Sensor scale factor specification. |
Misalignment |
Sensor misalignment specification. |
Attributes:
Name | Type | Description |
---|---|---|
manufacturer |
str
|
Manufacturer of the sensor. |
model |
str
|
Model number/identifier of the sensor. |
version |
str
|
Version number/identifier of the sensor. |
data_interface |
DataInterface
|
|
input_limits |
InputLimits
|
|
noise |
Noise
|
|
bias |
Bias
|
|
scale_factor |
ScaleFactor
|
Sensor scale factor specification. |
misalignment |
Misalignment
|
Sensor misalignment specification. |
axes |
int
|
Number of independent sensing axes of the sensor. |
scale_factor
instance-attribute
¶
scale_factor: ScaleFactor = ScaleFactor(axes)
Sensor scale factor specification.
misalignment
instance-attribute
¶
misalignment: Misalignment = Misalignment(axes)
Sensor misalignment specification.
DataInterface
¶
DataInterface(axes: int)
Bases: ABC
Sensor data interface specification.
The data interface of the sensor. The sensor interface includes the sample rate, which is the frequency at which the sensor transmits new data, and the data type, which is one of rate or delta.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
sample_rate |
Parameter
|
The frequency at which new data is output from the sensor. |
quantization |
Parameter | None
|
Data interface output quantization. |
InputLimits
¶
InputLimits(axes: int)
Bases: ABC
Sensor input limits specification.
The extreme values of the input (negative and positive) within which performance is of the specified accuracy. Simulated outputs outside of this range are truncated to these limits.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
minimum |
Parameter
|
Minimum negative input. |
maximum |
Parameter
|
Maximum positive input. |
Noise
¶
Noise(axes: int)
Bases: ABC
Sensor noise specification.
Common inertial sensor noise terms describing quantization, random walk, bias instability, rate random walk, and rate ramp. See Reference [20] and Standard [05] & Standard [06] for details.
Each of these noise terms can be determined experimentally from Allan variance/deviation plots or from data sheets and direct knowledge of the sensor. Not all terms will be applicable to all sensors.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
noise_density |
Parameter
|
Random white, Gaussian noise. |
Bias
¶
Bias(axes: int)
Bases: ABC
Sensor bias specification.
Bias is the non-zero output of a sensor at rest, or equivalently, the output that has no correlation with the input. It is comprised of a fixed component (that can be calibrated), a random component (that may vary from turn-on to turn-on or with changing conditions), and a temperature dependent component.
Derived classes should set appropriate defaults and handle units in the setter methods.
Attributes:
Name | Type | Description |
---|---|---|
fixed |
Parameter
|
Fixed bias. |
repeatability |
Parameter
|
Random bias. |
temperature |
Parameter
|
Temperature bias. |
fixed
abstractmethod
property
writable
¶
fixed: Parameter
Fixed bias.
A fixed bias that is constant across all conditions. For many sensors, this may be removed by factory calibration in which case this parameter can represent any known residual error in that calibration.
repeatability
abstractmethod
property
writable
¶
repeatability: Parameter
Random bias.
The standard deviation of a random bias component that varies with each turn-on of the sensor and/or varies across external conditions. This parameter may represent unknown residuals from the factory calibration of a fixed bias.
ScaleFactor
¶
ScaleFactor(axes: int)
Sensor scale factor specification.
Scale factor is the ratio of change in output to change in input at the analog sensing elements.
A perfect sensor has a linear analog response with a scale of 1.0. Imperfect sensors may have a non-unit scale.
Attributes:
Name | Type | Description |
---|---|---|
fixed |
Parameter
|
Fixed scale factor error. |
repeatability |
Parameter
|
Random scale factor error. |
fixed
property
writable
¶
fixed: Parameter
Fixed scale factor error.
A fixed offset from the ideal unit scale factor (1.0) that is
constant across all conditions. For many sensors, this may be
removed by factory calibration in which case this parameter can
represent any known residual error in that calibration. Units are
ratios of similar quantities so must be one of: "dimensionless"
,
"%"
, or "ppm"
.
Default value = Parameter([0.0,0.0,0.0], "dimensionless")
.
repeatability
property
writable
¶
repeatability: Parameter
Random scale factor error.
The standard deviation of a random scale factor error that varies
with each turn-on of the sensor and/or varies across external
conditions. This parameter may represent unknown residuals from the
factory calibration of fixed scale factor. Units are ratios of
similar quantities so must be one of: "dimensionless"
, "%"
, or
"ppm"
.
Default value = Parameter([0.0,0.0,0.0], "dimensionless")
.
Misalignment
¶
Misalignment(axes: int)
Sensor misalignment specification.
Misalignment is the offset between the ideal orthogonal input reference axes (IRA) and the actual sensitive input axis (IA) of the sensor. It is comprised of a fixed component (that can be calibrated) and a random component (that may vary from turn-on to turn-on or with changing conditions).
See Standard [05] and Standard [06] for details.
Attributes:
Name | Type | Description |
---|---|---|
fixed |
Parameter
|
Fixed sensor alignment. |
repeatability |
Parameter
|
Random sensor misalignment. |
fixed
property
writable
¶
fixed: Parameter
Fixed sensor alignment.
Coordinate transform matrix converting 3-dimensional input reference
axes (IRA) to N-dimensional input axes (IA). IRA are also known as
platform axes and the IA are also known as accelerometer, gyro, or
sensor axes. The resulting matrix is Nx3 where N is the number of
measurement axes of the device. For an ideal sensor this will
typically be an identity matrix. For real sensors, the deviation
from identity represents the misalignment. This fixed misalignment
may be removed by factory calibration in which case this parameter
can represent any residual error in that calibration. Units must be
"dimensionless". For sensors with <= 3 axes, the default value is a
one-to-one map of input axes to the available output axes. For
example, in a default 2-axis sensor input x-y axes map to output x-y
axes: Parameter([[1,0,0],[0,1,0]],"dimensionless")
. The input
z-axis is not sensed. For sensors with > 3 axes, inputs are
duplicated in sequence to fill the output. For example, by default
a 4-axis sensor will duplicate the x input:
Parameter([[1,0,0],[0,1,0],[0,0,1],[1,0,0]],"dimensionless")
. This
is typically not how redundant sensor designs are aligned so users
should take care to supply the correct input in these cases. An
example of a single axis sensor with a fixed, known misalignment is:
Parameter([0.999,0.02,-0.04],"dimensionless")
. This maps IRA
inputs to a single output with a known misalignment.
Default value = Parameter(np.eye(3), "rad")
.
repeatability
property
writable
¶
repeatability: Parameter
Random sensor misalignment.
Standard deviation of a (small) random angle offset applied to the
each input axis (IA). Each axis is independently rotated, meaning
that the result is non-orthogonal. The random offset is applied as
a rotation vector with components sampled independently around each
of the 3 input reference axes (IRA). For example, a single axis
sensor has a default fixed axis of:
Parameter([1,0,0],"dimensionless")
. That axis will be rotated
according to:
rotation_vector = repeatability * rng.std_normal(shape=(3,1))
axis = Rotation.from_rotation_vector(rotation_vector) @ [1,0,0]
Parameter([0.999,0.02,-0.04],"dimensionless")
. This process is
repeated for each axis. This parameter may represent an unknown
residual from the factory calibration or an offset that varies with
changing conditions like packaging stress and shock. Units must be
one of: "rad"
or "deg"
.
Default value = Parameter([0.0,0.0,0.0], "rad")
per axis.
InertialSensorState
dataclass
¶
InertialSensorState(
*,
data_interface: DataInterface = DataInterface(),
misalignment: Misalignment = Misalignment(),
input_limits: InputLimits = InputLimits(),
bias: Bias = Bias(),
noise: Noise = Noise(),
scale_factor: ScaleFactor = ScaleFactor(),
)
Bases: SensorState
Inertial sensor internal state.
Fixed (non-random) simulation parameters are stored once. Random simulation
parameters are stored for each time step of the
Measurement output. Parameters that are
not simulated (as determined by the
InertialSensorModel or
IMUModel) default to None
. These
states are suitable for both gyro and accelerometer sensors.
Classes:
Name | Description |
---|---|
Misalignment |
Misalignment simulation state. |
InputLimits |
Input limits simulation state. |
Bias |
Bias simulation state. |
ScaleFactor |
Scale factor error simulation state. |
DataInterface |
Data interface simulation state. |
Noise |
Random noise simulation state. |
Attributes:
Name | Type | Description |
---|---|---|
misalignment |
Misalignment
|
Misalignment simulation state. |
input_limits |
InputLimits
|
Input limits simulation state. |
bias |
Bias
|
Bias simulation state. |
scale_factor |
ScaleFactor
|
Scale factor error simulation state. |
data_interface |
DataInterface
|
Data interface simulation state. |
noise |
Noise
|
Noise simulation state. |
misalignment
class-attribute
instance-attribute
¶
misalignment: Misalignment = field(
default_factory=Misalignment
)
Misalignment simulation state.
input_limits
class-attribute
instance-attribute
¶
input_limits: InputLimits = field(
default_factory=InputLimits
)
Input limits simulation state.
bias
class-attribute
instance-attribute
¶
Bias simulation state.
scale_factor
class-attribute
instance-attribute
¶
scale_factor: ScaleFactor = field(
default_factory=ScaleFactor
)
Scale factor error simulation state.
data_interface
class-attribute
instance-attribute
¶
data_interface: DataInterface = field(
default_factory=DataInterface
)
Data interface simulation state.
noise
class-attribute
instance-attribute
¶
Noise simulation state.
Misalignment
dataclass
¶
Misalignment(
*,
fixed: NDArray | None = None,
random: NDArray | None = None,
total: NDArray | None = None,
)
InputLimits
dataclass
¶
Bias
dataclass
¶
Bias(
*,
fixed: NDArray | None = None,
random: NDArray | None = None,
temperature: NDArray | None = None,
)
ScaleFactor
dataclass
¶
DataInterface
dataclass
¶
Bases: DataInterface
Data interface simulation state.
Attributes:
Name | Type | Description |
---|---|---|
quantization |
NDArray | None
|
|
delta_quantization |
NDArray | None
|
|
Noise
dataclass
¶
Noise(
*,
wgn: NDArray | None = None,
quantization: NDArray | None = None,
bias_instability: NDArray | None = None,
rate_random_walk: NDArray | None = None,
rate_ramp: NDArray | None = None,
)
Bases: Noise
Random noise simulation state.
Attributes:
Name | Type | Description |
---|---|---|
wgn |
NDArray | None
|
|
quantization |
NDArray | None
|
|
bias_instability |
NDArray | None
|
|
rate_random_walk |
NDArray | None
|
|
rate_ramp |
NDArray | None
|
|
random_walk |
NDArray | None
|
Random walk state. Alias for |
SensorState
dataclass
¶
SensorState(
*,
data_interface: DataInterface = DataInterface(),
misalignment: Misalignment = Misalignment(),
input_limits: InputLimits = InputLimits(),
bias: Bias = Bias(),
noise: Noise = Noise(),
scale_factor: ScaleFactor = ScaleFactor(),
)
Sensor internal state.
Fixed (non-random) simulation parameters are stored once. Random simulation
parameters are stored for each time step of the
Measurement output. Parameters that are
not simulated default to None
.
Classes:
Name | Description |
---|---|
DataInterface |
Data interface simulation state. |
Misalignment |
Misalignment simulation state. |
InputLimits |
Input limits simulation state. |
Bias |
Bias simulation state. |
Noise |
Random noise simulation state. |
ScaleFactor |
Scale factor error simulation state. |
Attributes:
Name | Type | Description |
---|---|---|
data_interface |
DataInterface
|
Data interface simulation state. |
misalignment |
Misalignment
|
Misalignment simulation state. |
input_limits |
InputLimits
|
Input limits simulation state. |
bias |
Bias
|
Bias simulation state. |
noise |
Noise
|
Noise simulation state. |
scale_factor |
ScaleFactor
|
Scale factor error simulation state. |
data_interface
class-attribute
instance-attribute
¶
data_interface: DataInterface = field(
default_factory=DataInterface
)
Data interface simulation state.
misalignment
class-attribute
instance-attribute
¶
misalignment: Misalignment = field(
default_factory=Misalignment
)
Misalignment simulation state.
input_limits
class-attribute
instance-attribute
¶
input_limits: InputLimits = field(
default_factory=InputLimits
)
Input limits simulation state.
bias
class-attribute
instance-attribute
¶
Bias simulation state.
noise
class-attribute
instance-attribute
¶
Noise simulation state.
scale_factor
class-attribute
instance-attribute
¶
scale_factor: ScaleFactor = field(
default_factory=ScaleFactor
)
Scale factor error simulation state.
DataInterface
dataclass
¶
DataInterface(*, quantization: NDArray | None = None)
Misalignment
dataclass
¶
Misalignment(
*,
fixed: NDArray | None = None,
random: NDArray | None = None,
total: NDArray | None = None,
)
InputLimits
dataclass
¶
Bias
dataclass
¶
Bias(
*,
fixed: NDArray | None = None,
random: NDArray | None = None,
temperature: NDArray | None = None,
)