9 #ifndef GRAPH_SLAM_LEVMARQ_IMPL_H 10 #define GRAPH_SLAM_LEVMARQ_IMPL_H 38 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
40 const EDGE_ITERATOR &edge) {
42 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
45 template <
class MAT,
class EDGE_ITERATOR>
47 const EDGE_ITERATOR &edge) {
52 template <
class MAT,
class EDGE_ITERATOR>
54 const EDGE_ITERATOR &edge) {
56 JtJ.multiply_AtB(J1,J2);
59 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
61 const VEC1 & ERR,VEC2 &OUT) {
63 J.multiply_Atb(ERR,OUT,
true );
70 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
72 const EDGE_ITERATOR &edge) {
74 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
77 template <
class MAT,
class EDGE_ITERATOR>
79 const EDGE_ITERATOR &edge) {
84 template <
class MAT,
class EDGE_ITERATOR>
86 const EDGE_ITERATOR &edge) {
88 JtJ.multiply_AtB(J1,J2);
91 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
93 const VEC1 & ERR,VEC2 &OUT) {
95 J.multiply_Atb(ERR,OUT,
true );
102 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
105 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
108 template <
class MAT,
class EDGE_ITERATOR>
109 static inline void multiplyJtLambdaJ(
const MAT &J1, MAT &JtJ,
const EDGE_ITERATOR &edge) { JtJ.multiply_AtBC(J1,edge->second.cov_inv,J1); }
110 template <
class MAT,
class EDGE_ITERATOR>
111 static inline void multiplyJ1tLambdaJ2(
const MAT &J1,
const MAT &J2, MAT &JtJ,
const EDGE_ITERATOR &edge) { JtJ.multiply_AtBC(J1,edge->second.cov_inv,J2); }
113 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
114 static inline void multiply_Jt_W_err(
const JAC &J,
const EDGE_ITERATOR &edge,
const VEC1 & ERR,VEC2 &OUT)
117 JtInf.multiply_AtB(J,edge->second.cov_inv);
118 JtInf.multiply_Ab(ERR,OUT,
true );
124 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
127 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
130 template <
class MAT,
class EDGE_ITERATOR>
131 static inline void multiplyJtLambdaJ(
const MAT &J1, MAT &JtJ,
const EDGE_ITERATOR &edge) { JtJ.multiply_AtBC(J1,edge->second.cov_inv,J1); }
133 template <
class MAT,
class EDGE_ITERATOR>
134 static inline void multiplyJ1tLambdaJ2(
const MAT &J1,
const MAT &J2, MAT &JtJ,
const EDGE_ITERATOR &edge) { JtJ.multiply_AtBC(J1,edge->second.cov_inv,J2); }
136 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
137 static inline void multiply_Jt_W_err(
const JAC &J,
const EDGE_ITERATOR &edge,
const VEC1 & ERR,VEC2 &OUT)
140 JtInf.multiply_AtB(J,edge->second.cov_inv);
141 JtInf.multiply_Ab(ERR,OUT,
true );
148 template <
class GRAPH_T>
150 const GRAPH_T &graph,
159 lstJacobians.clear();
162 const size_t nObservations = lstObservationData.size();
164 for (
size_t i=0;i<nObservations;i++)
166 const typename gst::observation_info_t & obs = lstObservationData[i];
167 typename gst::edge_const_iterator it = obs.edge;
168 const typename gst::graph_t::constraint_t::type_value* EDGE_POSE = obs.edge_mean;
169 typename gst::graph_t::constraint_t::type_value* P1 = obs.P1;
170 typename gst::graph_t::constraint_t::type_value* P2 = obs.P2;
173 const typename gst::graph_t::edge_t &edge = it->second;
180 P1D.composeFrom(*P1,*EDGE_POSE);
181 const typename gst::graph_t::constraint_t::type_value P2inv = -(*P2);
182 P1DP2inv.composeFrom(P1D,P2inv);
186 errs.resize(errs.size()+1);
190 MRPT_ALIGN16 std::pair<mrpt::utils::TPairNodeIDs,typename gst::TPairJacobs> newMapEntry;
191 newMapEntry.first =
ids;
192 gst::SE_TYPE::jacobian_dP1DP2inv_depsilon(P1DP2inv, &newMapEntry.second.first,&newMapEntry.second.second);
195 lstJacobians.insert(lstJacobians.end(),newMapEntry );
199 double ret_err = 0.0;
200 for (
size_t i=0;i<errs.size();i++) ret_err+=errs[i].squaredNorm();
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 computePseudoLnError(const POSE &P1DP2inv, VEC &err, const EDGE_ITERATOR &edge)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
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)
Helper types for STL containers with Eigen memory allocators.
static void computePseudoLnError(const POSE &P1DP2inv, VEC &err, const EDGE_ITERATOR &edge)
mrpt::aligned_containers< mrpt::utils::TPairNodeIDs, TPairJacobs >::multimap_t map_pairIDs_pairJacobs_t
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, typename mrpt::aligned_containers< typename graphslam_traits< GRAPH_T >::Array_O >::vector_t &errs)
Auxiliary struct used in graph-slam implementation: It holds the relevant information for each of the...
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
static void computePseudoLnError(const POSE &P1DP2inv, VEC &err, 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)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
std::pair< TNodeID, TNodeID > TPairNodeIDs
A pair of node IDs.
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 computePseudoLnError(const POSE &P1DP2inv, VEC &err, const EDGE_ITERATOR &edge)
static void multiply_Jt_W_err(const JAC &J, const EDGE_ITERATOR &edge, const VEC1 &ERR, VEC2 &OUT)