32 using namespace gtsam;
58 const Vector3& bias,
const list<Vector3>& measuredOmegas,
59 const list<double>& deltaTs,
60 const Vector3& initialRotationRate = Vector3::Zero()) {
63 list<Vector3>::const_iterator itOmega = measuredOmegas.begin();
64 list<double>::const_iterator itDeltaT = deltaTs.begin();
65 for (; itOmega != measuredOmegas.end(); ++itOmega, ++itDeltaT) {
72 Rot3 evaluatePreintegratedMeasurementsRotation(
73 const Vector3& bias,
const list<Vector3>& measuredOmegas,
74 const list<double>& deltaTs,
75 const Vector3& initialRotationRate = Vector3::Zero()) {
77 evaluatePreintegratedMeasurements(bias, measuredOmegas, deltaTs,
78 initialRotationRate).deltaRij());
83 return Rot3::Expmap((measuredOmega - biasOmega) * deltaT);
101 Rot3 expectedDeltaR1 = Rot3::RzRyRx(0.5 *
M_PI / 100.0, 0.0, 0.0);
102 double expectedDeltaT1(0.5);
112 Rot3 expectedDeltaR2 = Rot3::RzRyRx(2.0 * 0.5 *
M_PI / 100.0, 0.0, 0.0);
113 double expectedDeltaT2(1);
125 Matrix3 gyroscopeCovariance = Matrix3::Ones()*0.4;
126 Vector3 omegaCoriolis(0.1, 0.5, 0.9);
130 double deltaTij = 0.02;
131 Matrix3 delRdelBiasOmega = Matrix3::Ones()*0.5;
132 Matrix3 preintMeasCov = Matrix3::Ones()*0.2;
134 std::make_shared<PreintegratedRotationParams>(params),
160 measuredOmega <<
M_PI / 100, 0, 0;
172 errorExpected << 0, 0, 0;
176 Matrix H1e = numericalDerivative11<Vector3, Rot3>(
178 Matrix H2e = numericalDerivative11<Vector3, Rot3>(
180 Matrix H3e = numericalDerivative11<Vector3, Vector3>(
184 Matrix RH1e = numericalDerivative11<Rot3, Rot3>(
185 std::bind(&evaluateRotationError, factor, std::placeholders::_1, x2, bias),
x1);
186 Matrix RH2e = numericalDerivative11<Rot3, Rot3>(
187 std::bind(&evaluateRotationError, factor, x1, std::placeholders::_1, bias),
x2);
191 (void) factor.evaluateError(x1, x2, bias, H1a, H2a, H3a);
217 measuredOmega << 0, 0,
M_PI / 10.0 + 0.3;
231 errorExpected << 0, 0, 0;
235 Matrix H1e = numericalDerivative11<Vector, Rot3>(
237 Matrix H2e = numericalDerivative11<Vector, Rot3>(
239 Matrix H3e = numericalDerivative11<Vector, Vector3>(
243 Matrix RH1e = numericalDerivative11<Rot3, Rot3>(
244 std::bind(&evaluateRotationError, factor, std::placeholders::_1, x2, bias),
x1);
245 Matrix RH2e = numericalDerivative11<Rot3, Rot3>(
246 std::bind(&evaluateRotationError, factor, x1, std::placeholders::_1, bias),
x2);
247 Matrix RH3e = numericalDerivative11<Rot3, Vector3>(
248 std::bind(&evaluateRotationError, factor, x1, x2, std::placeholders::_1), bias);
266 measuredOmega << 0.1, 0, 0;
270 Matrix expectedDelRdelBiasOmega = numericalDerivative11<Rot3, Vector3>(
271 std::bind(&evaluateRotation, measuredOmega, std::placeholders::_1, deltaT), biasOmega);
273 const Matrix3 Jr = Rot3::ExpmapDerivative(
274 (measuredOmega - biasOmega) * deltaT);
276 Matrix3 actualdelRdelBiasOmega = -Jr *
deltaT;
288 thetahat << 0.1, 0.1, 0;
292 deltatheta << 0, 0, 0;
295 Matrix expectedDelFdeltheta = numericalDerivative11<Vector3, Vector3>(
296 std::bind(&evaluateLogRotation, thetahat, std::placeholders::_1), deltatheta);
300 double normx = x.norm();
301 const Matrix3 actualDelFdeltheta = I_3x3 + 0.5 * X
302 + (1 / (normx * normx) - (1 +
cos(normx)) / (2 * normx *
sin(normx))) * X
317 measuredOmega << 0.1, 0, 0;
325 const Matrix3 Jr = Rot3::ExpmapDerivative(
326 (measuredOmega - biasOmega) * deltaT);
328 Matrix3 delRdelBiasOmega = -Jr *
deltaT;
331 (measuredOmega - biasOmega - deltabiasOmega) * deltaT).matrix();
333 const Matrix3 hatRot =
334 Rot3::Expmap((measuredOmega - biasOmega) * deltaT).matrix();
335 const Matrix3 actualRot = hatRot
336 *
Rot3::Expmap(delRdelBiasOmega * deltabiasOmega).matrix();
345 Vector3 bias = Vector3::Zero();
350 list<Vector3> measuredOmegas;
351 list<double> deltaTs;
352 measuredOmegas.push_back(
Vector3(
M_PI / 100.0, 0.0, 0.0));
353 deltaTs.push_back(0.01);
354 measuredOmegas.push_back(
Vector3(
M_PI / 100.0, 0.0, 0.0));
355 deltaTs.push_back(0.01);
356 for (
int i = 1;
i < 100;
i++) {
357 measuredOmegas.push_back(
359 deltaTs.push_back(0.01);
364 evaluatePreintegratedMeasurements(bias, measuredOmegas, deltaTs,
368 Matrix expectedDelRdelBias =
369 numericalDerivative11<Rot3, Vector3>(
370 std::bind(&evaluatePreintegratedMeasurementsRotation, std::placeholders::_1,
371 measuredOmegas, deltaTs,
Vector3(
M_PI / 100.0, 0.0, 0.0)), bias);
372 Matrix expectedDelRdelBiasOmega = expectedDelRdelBias.rightCols(3);
392 omegaCoriolis << 0, 0.1, 0.1;
394 measuredOmega << 0, 0,
M_PI / 10.0 + 0.3;
411 Matrix H1e = numericalDerivative11<Vector, Rot3>(
413 Matrix H2e = numericalDerivative11<Vector, Rot3>(
415 Matrix H3e = numericalDerivative11<Vector, Vector3>(
419 Matrix RH1e = numericalDerivative11<Rot3, Rot3>(
420 std::bind(&evaluateRotationError, factor, std::placeholders::_1, x2, bias),
x1);
421 Matrix RH2e = numericalDerivative11<Rot3, Rot3>(
422 std::bind(&evaluateRotationError, factor, x1, std::placeholders::_1, bias),
x2);
423 Matrix RH3e = numericalDerivative11<Rot3, Vector3>(
424 std::bind(&evaluateRotationError, factor, x1, x2, std::placeholders::_1), bias);
440 measuredOmega << 0, 0,
M_PI / 10.0;
443 for (
int i = 0;
i < 1000; ++
i) {
447 Matrix expectedMeasCov(3,3);
455 Rot3 expectedRot = Rot3::Ypr(20*
M_PI, 0, 0);
460 Matrix expectedH = numericalDerivative11<Vector3, Vector3>(
474 Rot3 x1(Rot3::RzRyRx(0, 0, 0));
491 for (
size_t i = 0;
i < 5; ++
i) {
500 graph.push_back(factor);
503 Rot3 expectedRot(Rot3::RzRyRx(0,
M_PI / 4, 0));
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
const Rot3 & deltaRij() const
Provides additional testing facilities for common data structures.
Jet< T, N > cos(const Jet< T, N > &f)
virtual const Values & optimize()
static int runAllTests(TestResult &result)
Factor Graph consisting of non-linear factors.
noiseModel::Diagonal::shared_ptr model
const ValueType at(Key j) const
#define DOUBLES_EQUAL(expected, actual, threshold)
Vector3 kZeroOmegaCoriolis(0, 0, 0)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
static Pose3 body_P_sensor(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2), Point3(0.25, -0.10, 1.0))
Jet< T, N > sin(const Jet< T, N > &f)
Pose2_ Expmap(const Vector3_ &xi)
Some functions to compute numerical derivatives.
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
Vector3 predict(const Vector3 &bias, OptionalJacobian< 3, 3 > H={}) 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
const Matrix3 & delRdelBiasOmega() const
NonlinearFactorGraph graph
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
T compose(const T &t1, const T &t2)
static const SmartProjectionParams params
const Vector3 & biasHat() const
const double & deltaTij() const
std::shared_ptr< Base > shared_ptr
#define EXPECT(condition)
std::optional< Vector3 > getOmegaCoriolis() const
static const double deltaT
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Linear Factor Graph where all factors are Gaussians.
Matrix3 skewSymmetric(double wx, double wy, double wz)
static const Vector3 measuredOmega(w, 0, 0)
const Matrix3 kMeasuredAccCovariance
void integrateMeasurement(const Vector3 &measuredOmega, double deltaT)
Vector callEvaluateError(const PriorFactor< ConstantBias > &factor, const ConstantBias &bias)
static Rot3 predict(const Rot3 &rot_i, const Vector3 &bias, const PreintegratedAhrsMeasurements &pim, const Vector3 &omegaCoriolis, const std::optional< Pose3 > &body_P_sensor={})
const Matrix3 & getGyroscopeCovariance() const
void insert(Key j, const Value &val)
TEST(AHRSFactor, PreintegratedAhrsMeasurements)
A class for computing marginals in a NonlinearFactorGraph.
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 x
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Vector evaluateError(const Rot3 &rot_i, const Rot3 &rot_j, const Vector3 &bias, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
vector of errors
const Matrix3 & preintMeasCov() const