Estimators & Observers¶
Estimators and observers provide estimates for states or external disturbances when they are not directly measurable. OpenSMC includes 7 powerful estimators, including ESO, HGO, and Levant's differentiator.
Usage Example¶
from opensmc.estimators import ExtendedStateObserver
# Create an ESO for simultaneous state and disturbance estimation
eso = ExtendedStateObserver(order=2, gains=[10, 20])
# Update observer based on measurement and control input
x_hat, disturbance_hat = eso.update(y=1.0, u=0.5, dt=0.01)
Available Estimators¶
estimators
¶
OpenSMC Estimators — 7 disturbance/state estimator implementations.
Classes¶
DisturbanceObserver
¶
Bases: Estimator
Disturbance observer for 2nd-order mechanical systems.
Parameters¶
J : float Inertia (default 2.0). b : float Damping coefficient (default 0.15). k1 : float Disturbance estimation gain (default 5000.0). k2 : float Velocity estimation gain (default 200.0). dt : float Integration time step for Euler update (default 1e-4).
Source code in opensmc/estimators/disturbance_observer.py
Functions¶
estimate(t, x, u, y=None, **kwargs)
¶
Compute disturbance estimate and advance one Euler step.
Parameters¶
t : float Current time. x : ndarray Plant state; x[1] is used as the velocity measurement. u : float or ndarray Control input (scalar). y : ignored **kwargs : dt : float, optional — override the default time step.
Returns¶
dhat : float Estimated disturbance.
Source code in opensmc/estimators/disturbance_observer.py
ExtendedStateObserver
¶
Bases: Estimator
Extended State Observer for 2nd-order systems.
Parameters¶
alpha1 : float Observer gain 1 (default 6.0). alpha2 : float Observer gain 2 (default 11.0). alpha3 : float Observer gain 3 (default 6.0). epsilon : float Bandwidth parameter; smaller => faster but more peaking (default 0.01). b_input : float Input gain of the plant (default 1.0). dt : float Integration time step for Euler update (default 1e-4).
Source code in opensmc/estimators/eso.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
Attributes¶
state_estimates
property
¶
Return current state estimates [x_hat1, x_hat2, sigma_hat].
Functions¶
estimate(t, x, u, y=None, **kwargs)
¶
Compute lumped uncertainty estimate and advance one Euler step.
Parameters¶
t : float Current time. x : ndarray Plant state (used for output measurement if y is None). u : float or ndarray Control input (scalar). y : float or None Measured output. If None, x[0] is used. **kwargs : dt : float, optional — override the default time step. epsilon : float, optional — override bandwidth parameter.
Returns¶
dhat : float Estimated lumped uncertainty (sigma_hat = f(x) + d).
Source code in opensmc/estimators/eso.py
HighGainObserver
¶
Bases: Estimator
High-Gain Observer for velocity recovery from position measurement.
Parameters¶
alpha1 : float Observer gain 1 (default 9.0). alpha2 : float Observer gain 2 (default 6.0). epsilon : float Bandwidth parameter; smaller => faster convergence but more peaking (default 0.01). dt : float Integration time step for Euler update (default 1e-4).
Source code in opensmc/estimators/high_gain.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
Attributes¶
state_estimates
property
¶
Return current state estimates [x_hat1, x_hat2].
Functions¶
estimate(t, x, u, y=None, **kwargs)
¶
Compute state estimate and advance one Euler step.
The HGO recovers velocity from position-only measurement. It returns x_hat2 (estimated velocity) as the estimate, since the primary purpose is to provide unmeasured state information. For disturbance estimation, use ESO or DOB instead.
Parameters¶
t : float Current time. x : ndarray Plant state (used for output measurement if y is None). u : float or ndarray Control input (not used in HGO dynamics, kept for interface). y : float or None Measured output. If None, x[0] is used. **kwargs : dt : float, optional — override the default time step. epsilon : float, optional — override bandwidth parameter.
Returns¶
x_hat2 : float Estimated velocity (second state).
Source code in opensmc/estimators/high_gain.py
IntegralChainDifferentiator
¶
Bases: Estimator
Integral Chain Differentiator for arbitrary-order derivative estimation.
Parameters¶
order : int Differentiation order (number of derivatives to estimate). The observer will have order+1 states (default 2). a_coeffs : list or ndarray or None Hurwitz coefficients [a1, a2, ..., a_{n+1}]. If None, uses coefficients of (s+1)^{n+1} (default). epsilon : float Bandwidth parameter; smaller => more accurate but more peaking (default 0.005). dt : float Integration time step for Euler update (default 1e-4).
Source code in opensmc/estimators/integral_chain.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Attributes¶
derivatives
property
¶
Return all current derivative estimates [y, y', y'', ...].
Functions¶
estimate(t, x, u, y=None, **kwargs)
¶
Compute derivative estimates and advance one Euler step.
Returns the last state (highest derivative estimate), which corresponds to the lumped uncertainty estimate in a 2nd-order plant context.
Parameters¶
t : float Current time. x : ndarray or float Plant state (used for signal measurement if y is None). u : float or ndarray Control input (not used by the ICD, kept for interface). y : float or None Measured signal. If None, x[0] is used. **kwargs : dt : float, optional — override the default time step. epsilon : float, optional — override bandwidth parameter.
Returns¶
dhat : float Highest derivative estimate (last observer state).
Source code in opensmc/estimators/integral_chain.py
LevantDifferentiator
¶
Bases: Estimator
Arbitrary-order robust exact differentiator (Levant 2003).
For order n, maintains n+1 states z[0]..z[n] such that z[k] -> f^{(k)} in finite time.
Parameters¶
order : int Differentiation order (number of derivatives to estimate). Default 1. L : float Lipschitz constant bound on |f^{(n+1)}|. Default 10.0. lambdas : list or ndarray or None Gain vector of length n+1. If None, uses Levant 2003 Table 1 defaults (or linearly spaced gains for orders > 4). dt : float Integration time step for Euler update (default 1e-4).
Source code in opensmc/estimators/levant.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
Attributes¶
derivatives
property
¶
Return all current derivative estimates [f, f', f'', ...].
Functions¶
estimate(t, x, u, y=None, **kwargs)
¶
Compute derivative estimates and advance one Euler step.
Returns the last state (highest derivative estimate).
Parameters¶
t : float Current time. x : ndarray or float Plant state (used for signal measurement if y is None). u : float or ndarray Control input (not used by the differentiator, kept for interface compatibility). y : float or None Measured signal. If None, x[0] is used. **kwargs : dt : float, optional — override the default time step.
Returns¶
dhat : float or ndarray Highest derivative estimate (z[n]). If order == 1, returns scalar. For higher orders, still returns the highest-order derivative as a scalar.
Source code in opensmc/estimators/levant.py
NoEstimator
¶
RBF_ELM
¶
Bases: Estimator
RBF network with OS-ELM online learning for disturbance estimation.
Parameters¶
n_input : int Input dimension (default 2). n_hidden : int Number of RBF hidden neurons / centers (default 50). x_min : array-like Lower bounds for center placement domain (default [-3, -5]). x_max : array-like Upper bounds for center placement domain (default [3, 5]). lam : float Regularization parameter for initial P matrix: P_0 = I / lam (default 1e-4). k_nn : int Number of nearest neighbors for width computation (default 3). seed : int or None Random seed for reproducible center placement (default None). dt : float Not used directly (kept for interface consistency). Default 1e-3.
Source code in opensmc/estimators/rbf_elm.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
Functions¶
estimate(t, x, u, y=None, **kwargs)
¶
Compute disturbance estimate from state features.
Uses the RBF-ELM network to estimate d_hat from the plant state x (used as input features). If a target is provided via kwargs, an online update is performed.
Parameters¶
t : float Current time. x : ndarray Plant state (used as input features for the network). u : float or ndarray Control input (not used directly by the network). y : float or None Measured output (not used directly). **kwargs : target : float, optional — if provided, perform an online update with this target value after computing the estimate.
Returns¶
dhat : float Estimated disturbance.
Source code in opensmc/estimators/rbf_elm.py
forward(x)
¶
online_update(x, target)
¶
OS-ELM update via Woodbury identity (Liang 2006).
Parameters¶
x : ndarray (n_input,) Input feature vector. target : float Target value (reconstructed disturbance).
Returns¶
d_hat : float Prediction BEFORE the weight update.