Simulation#
Simulation runners and experiment helpers.
Trial Runner#
Quadrotor parameter-estimation trial runner.
Orchestrates a closed-loop simulation: trajectory tracking via LQR,
online parameter estimation using any algorithm from online_estimators.estimators,
and payload-change events.
- online_estimators.simulation.trial.make_estimator(name, theta0, window, seed=None)[source]#
Instantiate an estimator by name.
- Parameters:
name (str) – Algorithm identifier (case-insensitive).
"gt"or"none"returnsNone.theta0 (np.ndarray, shape
(n,)) – Initial parameter estimate.window (int) – Number of stacked measurement rows (used for KF noise sizing).
seed (int or None) – If provided, seed the internal RNG of randomised estimators for reproducibility.
- Return type:
estimator or None
- Raises:
ValueError – If name is not recognised.
- online_estimators.simulation.trial.gate_param_update(theta, A, b, rel_resid_max=0.0001, verbose=False)[source]#
Safety gate: accept or reject a proposed parameter update.
Checks physical plausibility (mass bounds, COM bounds, inertia eigenvalues) and numerical quality (relative residual).
- online_estimators.simulation.trial.run_single_trial(estimator_name, base_seed, seed_offset, est_freq, window, ref_type, T_sim=20.0, noise='none', *, verbose_ctrl=False, verbose_est=False)[source]#
Run one closed-loop quadrotor parameter-estimation trial.
- Parameters:
estimator_name (str) – Algorithm name (see
make_estimator()).base_seed (int) – Base random seed.
seed_offset (int) – Offset added to base_seed for reproducibility across trials.
est_freq (int) – Estimation update period (in simulation steps).
window (int) – Number of consecutive measurement snapshots stacked per update.
ref_type (str) – Trajectory type (key into
TRAJECTORY_REGISTRY).T_sim (float) – Simulation duration (s).
noise (str) – Sensor noise level:
"none","low","medium","high".verbose_ctrl (bool) – Print per-step control debug info.
verbose_est (bool) – Print per-update estimation debug info.
- Returns:
Result dictionary with trajectory data, errors, and metadata.
- Return type:
Utilities#
Small numerical helper functions used across simulations.
- online_estimators.simulation.utils.abs_residual(A, x, b)[source]#
Absolute residual
||Ax - b||_2.- Parameters:
A (np.ndarray, shape
(m, n))x (np.ndarray, shape
(n,))b (np.ndarray, shape
(m,))
- Return type:
- online_estimators.simulation.utils.rel_residual(A, x, b, eps=1e-12)[source]#
Relative residual
||Ax - b||_2 / max(||b||_2, eps).
- online_estimators.simulation.utils.closest_spd(theta, epsilon=1e-06)[source]#
Project the inertia sub-matrix to the nearest SPD matrix.
- Parameters:
theta (np.ndarray, shape
(10,)) –[m, cx, cy, cz, Ixx, Iyy, Izz, Ixy, Ixz, Iyz]epsilon (float) – Eigenvalue floor.
- Returns:
Parameters with inertia projected to SPD.
- Return type:
np.ndarray, shape
(10,)