35 template <
typename SystemModelT>
45 state_(
std::move(state0)),
51 template <
typename SystemModelT>
62 Eigen::LLT<StateCovT> llt = P.llt();
63 if (llt.info() != Eigen::ComputationInfo::Success)
65 P = calculateClosestPosSemidefMatrix(P);
68 ARMARX_CHECK(llt.info() == Eigen::ComputationInfo::Success);
71 weights_.state.sqrt_d_lambda * llt.matrixL().transpose().toDenseMatrix();
75 auto propagate_and_retract = [&omega, &
dt, &state_after](
long row,
88 xi_j.rowwise() -= xi_0.transpose();
89 StateCovT cov_after = wj * xi_j.transpose() * xi_j + w0 * xi_0 * xi_0.transpose();
93 for (
long j = 0; j < dim::state; j++)
98 propagate_and_retract(j, 0, sig_j_plus, w, xi_j_after);
99 propagate_and_retract(j, dim::state, sig_j_minus, w, xi_j_after);
102 StateCovT P_after = calculate_covariance(weights_.state.wj, weights_.state.w0, xi_j_after);
104 for (
long j = 0; j < dim::control; j++)
106 const ControlNoiseT w_plus = weights_.control.sqrt_d_lambda * chol_Q_.row(j);
107 const ControlNoiseT w_minus = -weights_.control.sqrt_d_lambda * chol_Q_.row(j);
108 propagate_and_retract(j, 0, state_, w_plus, w_j_after);
109 propagate_and_retract(j, dim::control, state_, w_minus, w_j_after);
112 StateCovT Q = calculate_covariance(weights_.control.wj, weights_.control.w0, w_j_after);
115 P_ = std::move((new_P + new_P.transpose()) / 2.0f);
116 state_ = std::move(state_after);
119 template <
typename SystemModelT>
125 StateCovT xi_j = weights_.state.sqrt_d_lambda * P.llt().matrixL().transpose().toDenseMatrix();
126 ARMARX_CHECK(P.llt().info() == Eigen::ComputationInfo::Success);
132 for (
long j = 0; j < dim::state; j++)
142 weights_.update.wm * y_hat + weights_.update.wj * y_j.colwise().sum().transpose();
143 y_j.rowwise() -= y_mean.transpose();
146 const ObsCovT P_yy = weights_.update.w0 * y_hat * y_hat.transpose() +
147 weights_.update.wj * y_j.transpose() * y_j + R_;
155 P_yy.colPivHouseholderQr().solve(P_xiy.transpose()).transpose();
156 FloatT relative_error = (P_yy * K.transpose() - P_xiy.transpose()).
norm() / P_xiy.norm();
162 StateCovT new_P = P - K * (P_yy)*K.transpose();
165 P_ = calculateClosestPosSemidefMatrix(new_P);
168 template <
typename SystemModelT>
175 template <
typename SystemModelT>
182 template <
typename SystemModelT>
187 const StateCovT new_P = ((cov + cov.transpose()) / 2.0f);
188 Eigen::EigenSolver<StateCovT> solver(new_P);
193 return (V * D * V.inverse());
196 template <
typename SystemModelT>
202 template <
typename SystemModelT>
206 FloatT m = (alpha * alpha - 1) * l;
208 wj = 1 / (2 * (l + m));
210 w0 = m / (m + l) + 3 - alpha * alpha;
226 template <
typename SystemModelT>
234 state_(
std::move(state0)),
240 template <
typename SystemModelT>
251 Eigen::LLT<StateCovT> llt = P.llt();
252 if (llt.info() != Eigen::ComputationInfo::Success)
254 P = calculateClosestPosSemidefMatrix(P);
257 ARMARX_CHECK(llt.info() == Eigen::ComputationInfo::Success);
260 weights_.state.sqrt_d_lambda * llt.matrixL().transpose().toDenseMatrix();
264 auto propagate_and_retract = [&
dt, &state_after](
long row,
276 xi_j.rowwise() -= xi_0.transpose();
277 StateCovT cov_after = wj * xi_j.transpose() * xi_j + w0 * xi_0 * xi_0.transpose();
281 for (
long j = 0; j < dim::state; j++)
286 propagate_and_retract(j, 0, sig_j_plus, xi_j_after);
287 propagate_and_retract(j, dim::state, sig_j_minus, xi_j_after);
290 StateCovT P_after = calculate_covariance(weights_.state.wj, weights_.state.w0, xi_j_after);
303 P_ = std::move((new_P + new_P.transpose()) / 2.0f);
305 state_ = std::move(state_after);
308 template <
typename SystemModelT>
314 StateCovT xi_j = weights_.state.sqrt_d_lambda * P.llt().matrixL().transpose().toDenseMatrix();
315 ARMARX_CHECK(P.llt().info() == Eigen::ComputationInfo::Success);
321 for (
long j = 0; j < dim::state; j++)
331 weights_.update.wm * y_hat + weights_.update.wj * y_j.colwise().sum().transpose();
332 y_j.rowwise() -= y_mean.transpose();
335 const ObsCovT P_yy = weights_.update.w0 * y_hat * y_hat.transpose() +
336 weights_.update.wj * y_j.transpose() * y_j + R_;
344 P_yy.colPivHouseholderQr().solve(P_xiy.transpose()).transpose();
345 FloatT relative_error = (P_yy * K.transpose() - P_xiy.transpose()).
norm() / P_xiy.norm();
349 const auto residual = y - y_mean;
354 StateCovT new_P = P - K * (P_yy)*K.transpose();
357 P_ = calculateClosestPosSemidefMatrix(new_P);
360 template <
typename SystemModelT>
367 template <
typename SystemModelT>
374 template <
typename SystemModelT>
379 const StateCovT new_P = ((cov + cov.transpose()) / 2.0f);
380 Eigen::EigenSolver<StateCovT> solver(new_P);
385 return (V * D * V.inverse());
388 template <
typename SystemModelT>
390 state(dim::state, alpha(0)),
update(dim::state, alpha(2))
394 template <
typename SystemModelT>
398 FloatT m = (alpha * alpha - 1) * l;
400 wj = 1 / (2 * (l + m));
402 w0 = m / (m + l) + 3 - alpha * alpha;