MRPT  1.9.9
SE_traits.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "poses-precomp.h" // Precompiled headers
11 
12 #include <mrpt/poses/SE_traits.h>
13 
14 using namespace mrpt;
15 using namespace mrpt::math;
16 
17 using namespace mrpt::poses;
18 
19 /** A pseudo-Logarithm map in SE(3), where the output = [X,Y,Z, Ln(ROT)], that
20  * is, the normal
21  * SO(3) logarithm is used for the rotation components, but the translation is
22  * left unmodified.
23  */
24 void SE_traits<3>::pseudo_ln(const CPose3D& P, array_t& x)
25 {
26  x[0] = P.m_coords[0];
27  x[1] = P.m_coords[1];
28  x[2] = P.m_coords[2];
29  CArrayDouble<3> ln_rot = P.ln_rotation();
30  x[3] = ln_rot[0];
31  x[4] = ln_rot[1];
32  x[5] = ln_rot[2];
33 }
34 
35 /** Return one or both of the following 6x6 Jacobians, useful in graph-slam
36  * problems...
37  */
39  const CPose3D& P1DP2inv, matrix_VxV_t* df_de1, matrix_VxV_t* df_de2)
40 {
41  const CMatrixDouble33& R =
42  P1DP2inv.getRotationMatrix(); // The rotation matrix.
43 
44  // Common part: d_Ln(R)_dR:
46  CPose3D::ln_rot_jacob(R, dLnRot_dRot);
47 
48  if (df_de1)
49  {
50  matrix_VxV_t& J1 = *df_de1;
51  // This Jacobian has the structure:
52  // [ I_3 | -[d_t]_x ]
53  // Jacob1 = [ ---------+------------------- ]
54  // [ 0_3x3 | dLnR_dR * (...) ]
55  //
56  J1.zeros();
57  J1(0, 0) = 1;
58  J1(1, 1) = 1;
59  J1(2, 2) = 1;
60 
61  J1(0, 4) = P1DP2inv.z();
62  J1(0, 5) = -P1DP2inv.y();
63  J1(1, 3) = -P1DP2inv.z();
64  J1(1, 5) = P1DP2inv.x();
65  J1(2, 3) = P1DP2inv.y();
66  J1(2, 4) = -P1DP2inv.x();
67 
68  alignas(MRPT_MAX_ALIGN_BYTES) const double aux_vals[] = {
69  0, R(2, 0), -R(1, 0), -R(2, 0), 0, R(0, 0), R(1, 0), -R(0, 0), 0,
70  // -----------------------
71  0, R(2, 1), -R(1, 1), -R(2, 1), 0, R(0, 1), R(1, 1), -R(0, 1), 0,
72  // -----------------------
73  0, R(2, 2), -R(1, 2), -R(2, 2), 0, R(0, 2), R(1, 2), -R(0, 2), 0};
74  const CMatrixFixedNumeric<double, 9, 3> aux(aux_vals);
75 
76  // right-bottom part = dLnRot_dRot * aux
77  J1.block(3, 3, 3, 3) = (dLnRot_dRot * aux).eval();
78  }
79  if (df_de2)
80  {
81  // This Jacobian has the structure:
82  // [ -R | 0_3x3 ]
83  // Jacob2 = [ ---------+------------------- ]
84  // [ 0_3x3 | dLnR_dR * (...) ]
85  //
86  matrix_VxV_t& J2 = *df_de2;
87  J2.zeros();
88 
89  for (int i = 0; i < 3; i++)
90  for (int j = 0; j < 3; j++)
91  J2.set_unsafe(i, j, -R.get_unsafe(i, j));
92 
93  alignas(MRPT_MAX_ALIGN_BYTES) const double aux_vals[] = {
94  0, R(0, 2), -R(0, 1), 0, R(1, 2), -R(1, 1), 0, R(2, 2), -R(2, 1),
95  // -----------------------
96  -R(0, 2), 0, R(0, 0), -R(1, 2), 0, R(1, 0), -R(2, 2), 0, R(2, 0),
97  // -----------------------
98  R(0, 1), -R(0, 0), 0, R(1, 1), -R(1, 0), 0, R(2, 1), -R(2, 0), 0};
99  const CMatrixFixedNumeric<double, 9, 3> aux(aux_vals);
100 
101  // right-bottom part = dLnRot_dRot * aux
102  J2.block(3, 3, 3, 3) = (dLnRot_dRot * aux).eval();
103  }
104 }
105 
107  const CPose3D& Dinv, const CPose3D& P1, const CPose3D& P2,
108  matrix_VxV_t* df_de1, matrix_VxV_t* df_de2)
109 {
110  MRPT_TODO("Implement me!");
111  THROW_EXCEPTION("Implement me!");
112 }
113 
114 
116  const CPose2D& P1DP2inv, matrix_VxV_t* df_de1, matrix_VxV_t* df_de2)
117 {
118  if (df_de1)
119  {
120  matrix_VxV_t& J1 = *df_de1;
121  // This Jacobian has the structure:
122  // [ I_2 | -[d_t]_x ]
123  // Jacob1 = [ ---------+--------------- ]
124  // [ 0 | 1 ]
125  //
126  J1.unit(VECTOR_SIZE, 1.0);
127  J1(0, 2) = -P1DP2inv.y();
128  J1(1, 2) = P1DP2inv.x();
129  }
130  if (df_de2)
131  {
132  // This Jacobian has the structure:
133  // [ -R | 0 ]
134  // Jacob2 = [ ---------+------- ]
135  // [ 0 | -1 ]
136  //
137  matrix_VxV_t& J2 = *df_de2;
138 
139  const double ccos = cos(P1DP2inv.phi());
140  const double csin = sin(P1DP2inv.phi());
141 
142  const double vals[] = {-ccos, csin, 0, -csin, -ccos, 0, 0, 0, -1};
144  }
145 }
146 
148  const CPose2D& Dinv, const CPose2D& P1, const CPose2D& P2,
149  matrix_VxV_t* df_de1, matrix_VxV_t* df_de2)
150 {
151  using mrpt::math::TPoint2D;
152  const double phi1 = P1.phi();
153 
154  const TPoint2D dt(P2.x() - P1.x(), P2.y() - P1.y());
155  const double si = std::sin(phi1), ci = std::cos(phi1);
156 
157  CMatrixDouble22 RotDinv;
158  Dinv.getRotationMatrix(RotDinv);
159  CMatrixDouble33 K; // zeros
160  K.block<2, 2>(0, 0) = RotDinv;
161  K(2, 2) = 1.0;
162 
163  if (df_de1)
164  {
165  (*df_de1)(0, 0) = -ci;
166  (*df_de1)(0, 1) = -si;
167  (*df_de1)(0, 2) = -si * dt.x + ci * dt.y;
168  (*df_de1)(1, 0) = si;
169  (*df_de1)(1, 1) = -ci;
170  (*df_de1)(1, 2) = -ci * dt.x - si * dt.y;
171  (*df_de1)(2, 0) = 0;
172  (*df_de1)(2, 1) = 0;
173  (*df_de1)(2, 2) = -1;
174  (*df_de1) = K * (*df_de1);
175  }
176 
177  if (df_de2)
178  {
179  (*df_de2)(0, 0) = ci;
180  (*df_de2)(0, 1) = si;
181  (*df_de2)(0, 2) = 0;
182  (*df_de2)(1, 0) = -si;
183  (*df_de2)(1, 1) = ci;
184  (*df_de2)(1, 2) = 0;
185  (*df_de2)(2, 0) = 0;
186  (*df_de2)(2, 1) = 0;
187  (*df_de2)(2, 2) = 1;
188  (*df_de2) = K * (*df_de2);
189  }
190 }
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
#define MRPT_MAX_ALIGN_BYTES
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
mrpt::math::CArrayDouble< 3 > ln_rotation() const
Take the logarithm of the 3x3 rotation matrix, generating the corresponding vector in the Lie Algebra...
Definition: CPose3D.cpp:785
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
Definition: CArrayNumeric.h:25
This base provides a set of functions for maths stuff.
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z] access directly or with x(), y(), z() setter/getter methods...
Definition: CPose3D.h:96
void getRotationMatrix(mrpt::math::CMatrixDouble22 &R) const
Returns the SE(2) 2x2 rotation matrix.
Definition: CPose2D.cpp:130
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define MRPT_TODO(x)
Definition: common.h:129
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:38
const float R
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
const double & phi() const
Get the phi angle of the 2D pose (in radians)
Definition: CPose2D.h:80
A helper class for SE(2) and SE(3) geometry-related transformations, on-manifold optimization Jacobia...
Definition: SE_traits.h:27
GLenum GLint x
Definition: glext.h:3538
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
Definition: CPose3D.h:230
Lightweight 2D point.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020