Go to the documentation of this file.
24 using namespace gtsam;
28 static constexpr
double k = 0.5;
35 D_phi.row(2).setZero();
37 if (
H) *
H = -
k * D_phi;
42 TEST(GroupeEKF, DynamicsJacobian) {
52 Matrix3 expectedH = numericalDerivative11<Vector3, Rot3>(
f,
R);
58 TEST(GroupeEKF, PredictNumericState) {
61 Matrix3
P0 = Matrix3::Identity() * 0.2;
76 Matrix3 expectedH = numericalDerivative11<Rot3, Rot3>(
g,
R0);
81 TEST(GroupeEKF, StateAndControl) {
89 Matrix3
P0 = Matrix3::Identity() * 0.2;
92 Matrix3
Q = Matrix3::Zero();
106 Matrix3 expectedH = numericalDerivative11<Rot3, Rot3>(
g,
R0);
121 size_t state_dim =
X.size();
124 H_X->setZero(tangent_dim, state_dim);
132 if (
p.rows() != 2 ||
p.cols() != 2) {
133 throw std::invalid_argument(
"Matrix must be 2x2.");
136 H->resize(1,
p.size());
137 *
H << 1.0, 0.0, 0.0, 1.0;
139 return p(0, 0) +
p(1, 1);
143 TEST(LieGroupEKF_DynamicMatrix, PredictAndUpdate) {
145 Matrix p0Matrix = (
Matrix(2, 2) << 1.0, 2.0, 3.0, 4.0).finished();
146 Matrix p0Covariance = I_4x4 * 0.01;
148 Matrix process_noise_Q = I_4x4 * 0.001;
149 Matrix measurement_noise_R = Matrix::Identity(1, 1) * 0.005;
166 Matrix pCovariancePredictedExpected = p0Covariance + process_noise_Q;
176 double zObserved = zTrue - 0.03;
185 double innovationY_tangent = zObserved - zPredictionManual;
186 Matrix S_innovation_cov = H_update * pCovarianceBeforeUpdate * H_update.transpose() + measurement_noise_R;
187 Matrix K_gain = pCovarianceBeforeUpdate * H_update.transpose() * S_innovation_cov.inverse();
188 Vector deltaXiTangent = K_gain * innovationY_tangent;
190 Matrix I_KH = I_4x4 - K_gain * H_update;
191 Matrix pUpdatedCovarianceExpected = I_KH * pCovarianceBeforeUpdate * I_KH.transpose() + K_gain * measurement_noise_R * K_gain.transpose();
static int runAllTests(TestResult &result)
G predictMean(Dynamics &&f, double dt, OptionalJacobian< Dim, Dim > A={}) const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EXPECT_LONGS_EQUAL(expected, actual)
Concept check for values that can be used in unit tests.
#define EXPECT(condition)
const Vector kFixedVelocityTangent
3D rotation represented as a rotation matrix or quaternion
Extended Kalman Filter derived class for Lie groups G.
Some functions to compute numerical derivatives.
const Covariance & covariance() const
Extended Kalman Filter on a Lie group G, derived from ManifoldEKF.
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Vector9 dynamics(const Vector6 &imu)
Left-invariant dynamics for NavState.
Navigation state composing of attitude, position, and velocity.
void predict(Dynamics &&f, double dt, const Covariance &Q)
void update(const Measurement &prediction, const Eigen::Matrix< double, traits< Measurement >::dimension, Dim > &H, const Measurement &z, const Eigen::Matrix< double, traits< Measurement >::dimension, traits< Measurement >::dimension > &R)
void g(const string &key, int i)
The quaternion class used to represent 3D orientations and rotations.
TEST(SmartFactorBase, Pinhole)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
static Vector3 Logmap(const Rot3 &R, OptionalJacobian< 3, 3 > H={})
Vector f(const Matrix &X, OptionalJacobian< Eigen::Dynamic, Eigen::Dynamic > H_X={})
double h(const Matrix &p, OptionalJacobian<-1, -1 > H={})
Vector3 dynamics(const Rot3 &X, OptionalJacobian< 3, 3 > H={})
static Rot3 RzRyRx(double x, double y, double z, OptionalJacobian< 3, 1 > Hx={}, OptionalJacobian< 3, 1 > Hy={}, OptionalJacobian< 3, 1 > Hz={})
Rotations around Z, Y, then X axes as in http://en.wikipedia.org/wiki/Rotation_matrix,...
Rot2 R(Rot2::fromAngle(0.1))
static constexpr double k
gtsam
Author(s):
autogenerated on Wed May 28 2025 03:06:45