9 #ifndef GRAPH_SLAM_LEVMARQ_IMPL_H 10 #define GRAPH_SLAM_LEVMARQ_IMPL_H 34 template <
class POSE,
class gst>
55 static inline void sumIncr(POSE&
p,
const typename gst::Array_O& delta)
71 typename gst::graph_t::constraint_t::type_value exp_delta_pose(
73 gst::SE_TYPE::exp(delta, exp_delta_pose);
74 p =
p + exp_delta_pose;
83 static inline void sumIncr(POSE&
p,
const typename gst::Array_O& delta)
86 typename gst::graph_t::constraint_t::type_value exp_delta_pose(
88 gst::SE_TYPE::exp(delta, exp_delta_pose);
89 p =
p + exp_delta_pose;
101 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
103 const EDGE_ITERATOR &edge) {
105 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
108 template <
class MAT,
class EDGE_ITERATOR>
110 const EDGE_ITERATOR &edge) {
112 JtJ.multiply_AtA(J1);
115 template <
class MAT,
class EDGE_ITERATOR>
117 const EDGE_ITERATOR &edge) {
119 JtJ.multiply_AtB(J1,J2);
122 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
124 const VEC1 & ERR,VEC2 &OUT) {
126 J.multiply_Atb(ERR,OUT,
true );
133 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
135 const EDGE_ITERATOR &edge) {
137 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
140 template <
class MAT,
class EDGE_ITERATOR>
142 const EDGE_ITERATOR &edge) {
144 JtJ.multiply_AtA(J1);
147 template <
class MAT,
class EDGE_ITERATOR>
149 const EDGE_ITERATOR &edge) {
151 JtJ.multiply_AtB(J1,J2);
154 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
156 const VEC1 & ERR,VEC2 &OUT) {
158 J.multiply_Atb(ERR,OUT,
true );
165 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
168 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
171 template <
class MAT,
class EDGE_ITERATOR>
172 static inline void multiplyJtLambdaJ(
const MAT &J1, MAT &JtJ,
const EDGE_ITERATOR &edge) { JtJ.multiply_AtBC(J1,edge->second.cov_inv,J1); }
173 template <
class MAT,
class EDGE_ITERATOR>
174 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); }
176 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
177 static inline void multiply_Jt_W_err(
const JAC &J,
const EDGE_ITERATOR &edge,
const VEC1 & ERR,VEC2 &OUT)
180 JtInf.multiply_AtB(J,edge->second.cov_inv);
181 JtInf.multiply_Ab(ERR,OUT,
true );
187 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
190 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
193 template <
class MAT,
class EDGE_ITERATOR>
194 static inline void multiplyJtLambdaJ(
const MAT &J1, MAT &JtJ,
const EDGE_ITERATOR &edge) { JtJ.multiply_AtBC(J1,edge->second.cov_inv,J1); }
196 template <
class MAT,
class EDGE_ITERATOR>
197 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); }
199 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
200 static inline void multiply_Jt_W_err(
const JAC &J,
const EDGE_ITERATOR &edge,
const VEC1 & ERR,VEC2 &OUT)
203 JtInf.multiply_AtB(J,edge->second.cov_inv);
204 JtInf.multiply_Ab(ERR,OUT,
true );
211 template <
class GRAPH_T>
213 const GRAPH_T &graph,
222 lstJacobians.clear();
225 const size_t nObservations = lstObservationData.size();
227 for (
size_t i=0;i<nObservations;i++)
229 const typename gst::observation_info_t & obs = lstObservationData[i];
230 typename gst::edge_const_iterator it = obs.edge;
231 const typename gst::graph_t::constraint_t::type_value* EDGE_POSE = obs.edge_mean;
232 typename gst::graph_t::constraint_t::type_value* P1 = obs.P1;
233 typename gst::graph_t::constraint_t::type_value* P2 = obs.P2;
236 const typename gst::graph_t::edge_t &edge = it->second;
240 typename gst::graph_t::constraint_t::type_value DinvP1invP2 = ((*P2) - (*P1)) - *EDGE_POSE;
243 errs.resize(errs.size()+1);
247 MRPT_ALIGN16 std::pair<mrpt::utils::TPairNodeIDs,typename gst::TPairJacobs> newMapEntry;
248 newMapEntry.first =
ids;
249 gst::SE_TYPE::jacobian_dDinvP1invP2_depsilon(-(*EDGE_POSE), *P1, *P2, &newMapEntry.second.first,&newMapEntry.second.second);
252 lstJacobians.insert(lstJacobians.end(),newMapEntry );
256 double ret_err = 0.0;
257 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 sumIncr(POSE &p, const typename gst::Array_O &delta)
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 computePseudoLnError(const POSE &DinvP1invP2, VEC &err, const EDGE_ITERATOR &edge)
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
static void computePseudoLnError(const POSE &DinvP1invP2, VEC &err, const EDGE_ITERATOR &edge)
static void sumIncr(CPose3D &p, const typename gst::Array_O &delta)
Helper types for STL containers with Eigen memory allocators.
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 sumIncr(POSE &p, const typename gst::Array_O &delta)
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 computePseudoLnError(const POSE &DinvP1invP2, VEC &err, 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)
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)
static void computePseudoLnError(const POSE &DinvP1invP2, VEC &err, const EDGE_ITERATOR &edge)
static void sumIncr(CPose2D &p, const typename gst::Array_O &delta)