11 #include <Eigen/Dense> 30 template <
class EDGE,
class gst>
37 template <
class MAT,
class EDGE_ITERATOR>
39 const MAT& J1, MAT& JtJ, [[maybe_unused]]
const EDGE_ITERATOR& edge)
41 JtJ.matProductOf_AtA(J1);
44 template <
class MAT,
class EDGE_ITERATOR>
46 const MAT& J1,
const MAT& J2, MAT& JtJ,
47 [[maybe_unused]]
const EDGE_ITERATOR& edge)
49 JtJ.asEigen() = J1.transpose() * J2.asEigen();
52 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
54 const JAC& J, [[maybe_unused]]
const EDGE_ITERATOR& edge,
55 const VEC1& ERR, VEC2& OUT)
57 const auto grad_incr = (J.transpose() * ERR.asEigen()).eval();
58 OUT.asEigen() += grad_incr;
66 template <
class MAT,
class EDGE_ITERATOR>
68 const MAT& J1, MAT& JtJ, [[maybe_unused]]
const EDGE_ITERATOR& edge)
70 JtJ.matProductOf_AtA(J1);
73 template <
class MAT,
class EDGE_ITERATOR>
75 const MAT& J1,
const MAT& J2, MAT& JtJ,
76 [[maybe_unused]]
const EDGE_ITERATOR& edge)
78 JtJ.asEigen() = J1.transpose() * J2.asEigen();
81 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
83 const JAC& J, [[maybe_unused]]
const EDGE_ITERATOR& edge,
84 const VEC1& ERR, VEC2& OUT)
86 OUT.asEigen() += J.transpose() * ERR.asEigen();
94 template <
class MAT,
class EDGE_ITERATOR>
96 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
99 (J1.transpose() * edge->second.cov_inv.asEigen()) * J1.asEigen();
101 template <
class MAT,
class EDGE_ITERATOR>
103 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
106 (J1.transpose() * edge->second.cov_inv.asEigen()) * J2.asEigen();
109 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
111 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
114 (J.transpose() * edge->second.cov_inv.asEigen()) * ERR.asEigen();
122 template <
class MAT,
class EDGE_ITERATOR>
124 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
127 (J1.transpose() * edge->second.cov_inv.asEigen()) * J1.asEigen();
130 template <
class MAT,
class EDGE_ITERATOR>
132 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
135 (J1.transpose() * edge->second.cov_inv.asEigen()) * J2.asEigen();
138 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
140 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
143 (J.transpose() * edge->second.cov_inv.asEigen()) * ERR.asEigen();
151 template <
class GRAPH_T>
153 [[maybe_unused]]
const GRAPH_T& graph,
161 lstJacobians.clear();
164 const size_t nObservations = lstObservationData.size();
166 for (
size_t i = 0; i < nObservations; i++)
168 const typename gst::observation_info_t& obs = lstObservationData[i];
170 const typename gst::graph_t::constraint_t::type_value* EDGE_POSE =
172 typename gst::graph_t::constraint_t::type_value* P1 = obs.P1;
173 typename gst::graph_t::constraint_t::type_value* P2 = obs.P2;
175 const auto& ids = e->first;
181 typename gst::graph_t::constraint_t::type_value DinvP1invP2 =
182 ((*P2) - (*P1)) - *EDGE_POSE;
185 errs.resize(errs.size() + 1);
186 errs.back() = gst::SE_TYPE::log(DinvP1invP2);
189 alignas(MRPT_MAX_STATIC_ALIGN_BYTES)
190 std::pair<mrpt::graphs::TPairNodeIDs, typename gst::TPairJacobs>
192 newMapEntry.first = ids;
193 gst::SE_TYPE::jacob_dDinvP1invP2_de1e2(
194 -(*EDGE_POSE), *P1, *P2, newMapEntry.second.first,
195 newMapEntry.second.second);
198 lstJacobians.insert(lstJacobians.end(), newMapEntry);
204 double ret_err = 0.0;
205 for (
size_t i = 0; i < errs.size(); i++)
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, const EDGE_ITERATOR &edge)
static void multiply_Jt_W_err(const JAC &J, [[maybe_unused]] const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)
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, [[maybe_unused]] 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
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...
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, [[maybe_unused]] const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, [[maybe_unused]] const EDGE_ITERATOR &edge)
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, [[maybe_unused]] const EDGE_ITERATOR &edge)
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)
return_t square(const num_t x)
Inline function for the square of a number.
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 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...
double computeJacobiansAndErrors([[maybe_unused]] 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)
CONTAINER::Scalar norm(const CONTAINER &v)
static void multiplyJtLambdaJ(const MAT &J1, MAT &JtJ, [[maybe_unused]] const EDGE_ITERATOR &edge)