11 #include <Eigen/Dense> 30 template <
class EDGE,
class gst>
37 template <
class MAT,
class EDGE_ITERATOR>
39 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
42 JtJ.matProductOf_AtA(J1);
45 template <
class MAT,
class EDGE_ITERATOR>
47 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
50 JtJ.asEigen() = J1.transpose() * J2.asEigen();
53 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
55 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
58 const auto grad_incr = (J.transpose() * ERR.asEigen()).eval();
59 OUT.asEigen() += grad_incr;
67 template <
class MAT,
class EDGE_ITERATOR>
69 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
72 JtJ.matProductOf_AtA(J1);
75 template <
class MAT,
class EDGE_ITERATOR>
77 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
80 JtJ.asEigen() = J1.transpose() * J2.asEigen();
83 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
85 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
88 OUT.asEigen() += J.transpose() * ERR.asEigen();
96 template <
class MAT,
class EDGE_ITERATOR>
98 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
101 (J1.transpose() * edge->second.cov_inv.asEigen()) * J1.asEigen();
103 template <
class MAT,
class EDGE_ITERATOR>
105 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
108 (J1.transpose() * edge->second.cov_inv.asEigen()) * J2.asEigen();
111 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
113 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
116 (J.transpose() * edge->second.cov_inv.asEigen()) * ERR.asEigen();
124 template <
class MAT,
class EDGE_ITERATOR>
126 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
129 (J1.transpose() * edge->second.cov_inv.asEigen()) * J1.asEigen();
132 template <
class MAT,
class EDGE_ITERATOR>
134 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
137 (J1.transpose() * edge->second.cov_inv.asEigen()) * J2.asEigen();
140 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
142 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
145 (J.transpose() * edge->second.cov_inv.asEigen()) * ERR.asEigen();
153 template <
class GRAPH_T>
155 const GRAPH_T& graph,
164 lstJacobians.clear();
167 const size_t nObservations = lstObservationData.size();
169 for (
size_t i = 0; i < nObservations; i++)
171 const typename gst::observation_info_t& obs = lstObservationData[i];
173 const typename gst::graph_t::constraint_t::type_value* EDGE_POSE =
175 typename gst::graph_t::constraint_t::type_value* P1 = obs.P1;
176 typename gst::graph_t::constraint_t::type_value* P2 = obs.P2;
178 const auto&
ids = e->first;
184 typename gst::graph_t::constraint_t::type_value DinvP1invP2 =
185 ((*P2) - (*P1)) - *EDGE_POSE;
188 errs.resize(errs.size() + 1);
189 errs.back() = gst::SE_TYPE::log(DinvP1invP2);
192 alignas(MRPT_MAX_STATIC_ALIGN_BYTES)
193 std::pair<mrpt::graphs::TPairNodeIDs, typename gst::TPairJacobs>
195 newMapEntry.first =
ids;
196 gst::SE_TYPE::jacob_dDinvP1invP2_de1e2(
197 -(*EDGE_POSE), *P1, *P2, newMapEntry.second.first,
198 newMapEntry.second.second);
201 lstJacobians.insert(lstJacobians.end(), newMapEntry);
207 double ret_err = 0.0;
208 for (
size_t i = 0; i < errs.size(); i++)
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, const EDGE_ITERATOR &edge)
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, const EDGE_ITERATOR &edge)
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
typename SE_TYPE::tangent_vector Array_O
double computeJacobiansAndErrors(const GRAPH_T &graph, const std::vector< typename graphslam_traits< GRAPH_T >::observation_info_t > &lstObservationData, typename graphslam_traits< GRAPH_T >::map_pairIDs_pairJacobs_t &lstJacobians, std::vector< typename graphslam_traits< GRAPH_T >::Array_O > &errs)
std::multimap< mrpt::graphs::TPairNodeIDs, TPairJacobs > map_pairIDs_pairJacobs_t
Auxiliary struct used in graph-slam implementation: It holds the relevant information for each of the...
T square(const T x)
Inline function for the square of a number.
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
SLAM methods related to graphs of pose constraints.
This base provides a set of functions for maths stuff.
static void multiply_Jt_W_err(const JAC &J, const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)
static void multiply_Jt_W_err(const JAC &J, const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Auxiliary traits template for use among graph-slam problems to make life easier with these complicate...
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, const EDGE_ITERATOR &edge)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A Probability Density function (PDF) of a 2D pose as a Gaussian with a mean and the inverse of the c...
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, const EDGE_ITERATOR &edge)
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
static void multiply_Jt_W_err(const JAC &J, const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)
Declares a class that represents a Probability Density function (PDF) of a 3D pose as a Gaussian des...
static void multiply_Jt_W_err(const JAC &J, const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)
CONTAINER::Scalar norm(const CONTAINER &v)
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.