Simulation modes¶
There are two primary modes of operation: batch
and real-time
.
Batch mode¶
In batch
mode, which is the default, all inputs are supplied to the
simulate()
method of a given sensor and all outputs are returned. This is
suitable for open loop simulations, post-processing recorded data, Monte Carlo
analysis and similar applications. It is the most efficient simulation method
since it allows for optimization of the underlying math operations. See the
Aircraft simulation and Driving
logs examples.
Real-time mode¶
In real-time
mode, inputs are supplied incrementally and outputs are returned
incrementally. The sensor must be created with the inputs mode="real-time"
and max_duration
parameters set. The max_duration
parameter should be an
upper bound on the duration of the simulation (in seconds). It is used to
precompute time correlated noise terms. This mode is suitable for closed-loop
simulations where the sensor outputs form the input to other processes, e.g.
motion control, sensor fusion, etc.
Simulation duration
If the simulation duration is not well known ahead of time it is safe and
efficient to set max_duration
to a large value (up to several hours). If
the value is exceed an IndexError
will be raised.
In real-time
mode, each call to the simulate()
method must have sufficient
inputs to create an output. For example, simulating gyro data from
attitude (orientation) inputs requires
differencing the attitude input to calculate angular rate. In an incremental
simulation pair-wise attitude inputs must be supplied.
An efficient strategy for accumulating all outputs of a simulation are to store the results in a list (or other iterable container) and combine them at the end. See the Robot arm example.
Sample rate simulation
In real-time
mode the simulate_sample_rate
option of the
model is ignored and users should ensure that the
incremental inputs are supplied at the appropriate sample rates. No
interpolation or resampling is applied.