GravityFactor.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
26 #include "GravityFactor.h"
27 
28 using namespace std;
29 
30 namespace rtabmap {
31 
32 //***************************************************************************
33 Vector GravityFactor::attitudeError(const Rot3& nRb,
34  OptionalJacobian<2, 3> H) const {
35  if (H) {
36  Matrix23 D_nRef_R;
37  Matrix22 D_e_nRef;
38  Vector3 r = nRb.xyz();
39  Unit3 nRef = Rot3::RzRyRx(r.x(), r.y(), 0).rotate(bRef_, D_nRef_R);
40  Vector e = nZ_.error(nRef, D_e_nRef);
41  (*H) = D_e_nRef * D_nRef_R;
42  //printf("ref=%f %f %f grav=%f %f %f e= %f %f H=%f %f %f, %f %f %f\n",
43  // nRef.point3().x(), nRef.point3().y(), nRef.point3().z(), nZ_.point3().x(), nZ_.point3().y(), nZ_.point3().z(), e(0), e(1),
44  // (*H)(0,0), (*H)(0,1), (*H)(0,2), (*H)(1,0), (*H)(1,1), (*H)(1,2));
45  return e;
46  } else {
47  Vector3 r = nRb.xyz();
48  Unit3 nRef = Rot3::RzRyRx(r.x(), r.y(), 0) * bRef_;
49  Vector e = nZ_.error(nRef);
50  //printf("ref=%f %f %f grav=%f %f %f e= %f %f\n", nRef.point3().x(), nRef.point3().y(), nRef.point3().z(), nZ_.point3().x(), nZ_.point3().y(), nZ_.point3().z(), e(0), e(1));
51  return e;
52  }
53 }
54 
55 //***************************************************************************
56 void Rot3GravityFactor::print(const string& s,
57  const KeyFormatter& keyFormatter) const {
58  cout << s << "Rot3GravityFactor on " << keyFormatter(this->key()) << "\n";
59  nZ_.print(" measured direction in nav frame: ");
60  bRef_.print(" reference direction in body frame: ");
61  this->noiseModel_->print(" noise model: ");
62 }
63 
64 //***************************************************************************
65 bool Rot3GravityFactor::equals(const NonlinearFactor& expected,
66  double tol) const {
67  const This* e = dynamic_cast<const This*>(&expected);
68  return e != NULL && Base::equals(*e, tol) && this->nZ_.equals(e->nZ_, tol)
69  && this->bRef_.equals(e->bRef_, tol);
70 }
71 
72 //***************************************************************************
73 void Pose3GravityFactor::print(const string& s,
74  const KeyFormatter& keyFormatter) const {
75  cout << s << "Pose3GravityFactor on " << keyFormatter(this->key()) << "\n";
76  nZ_.print(" measured direction in nav frame: ");
77  bRef_.print(" reference direction in body frame: ");
78  this->noiseModel_->print(" noise model: ");
79 }
80 
81 //***************************************************************************
82 bool Pose3GravityFactor::equals(const NonlinearFactor& expected,
83  double tol) const {
84  const This* e = dynamic_cast<const This*>(&expected);
85  return e != NULL && Base::equals(*e, tol) && this->nZ_.equals(e->nZ_, tol)
86  && this->bRef_.equals(e->bRef_, tol);
87 }
88 
89 //***************************************************************************
90 
91 }
H
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
gtsam::Rot3::xyz
Vector3 xyz(OptionalJacobian< 3, 3 > H={}) const
rtabmap::Rot3GravityFactor
Definition: GravityFactor.h:87
s
RealScalar s
expected
const set< Key > expected
Vector3
Eigen::Vector3d Vector3
gtsam::Rot3
KeyFormatter
std::function< std::string(Key)> KeyFormatter
key
const gtsam::Symbol key( 'X', 0)
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
nRb
const Rot3 nRb(Point3(0, 1, 0), Point3(1, 0, 0), Point3(0, 0, -1))
gtsam::OptionalJacobian
std
gtsam::NonlinearFactor
rtabmap::Pose3GravityFactor
Definition: GravityFactor.h:177
tol
const G double tol
Eigen::Matrix< double, Eigen::Dynamic, 1 >
GravityFactor.h
NULL
#define NULL
gtsam::Unit3
rtabmap
Definition: CameraARCore.cpp:35


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:10