9 #ifndef GRAPH_SLAM_LEVMARQ_IMPL_H 10 #define GRAPH_SLAM_LEVMARQ_IMPL_H 35 template <
class EDGE,
class gst>
42 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
44 const POSE& P1DP2inv, VEC& err,
const EDGE_ITERATOR& edge)
47 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
50 template <
class MAT,
class EDGE_ITERATOR>
52 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
58 template <
class MAT,
class EDGE_ITERATOR>
60 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
63 JtJ.multiply_AtB(J1, J2);
66 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
68 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
71 J.multiply_Atb(ERR, OUT,
true );
79 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
81 const POSE& P1DP2inv, VEC& err,
const EDGE_ITERATOR& edge)
84 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
87 template <
class MAT,
class EDGE_ITERATOR>
89 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
95 template <
class MAT,
class EDGE_ITERATOR>
97 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
100 JtJ.multiply_AtB(J1, J2);
103 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
105 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
108 J.multiply_Atb(ERR, OUT,
true );
116 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
118 const POSE& P1DP2inv, VEC& err,
const EDGE_ITERATOR& edge)
120 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
123 template <
class MAT,
class EDGE_ITERATOR>
125 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
127 JtJ.multiply_AtBC(J1, edge->second.cov_inv, J1);
129 template <
class MAT,
class EDGE_ITERATOR>
131 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
133 JtJ.multiply_AtBC(J1, edge->second.cov_inv, J2);
136 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
138 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
141 JtInf.multiply_AtB(J, edge->second.cov_inv);
142 JtInf.multiply_Ab(ERR, OUT,
true );
150 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
152 const POSE& P1DP2inv, VEC& err,
const EDGE_ITERATOR& edge)
155 gst::SE_TYPE::pseudo_ln(P1DP2inv, err);
158 template <
class MAT,
class EDGE_ITERATOR>
160 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
162 JtJ.multiply_AtBC(J1, edge->second.cov_inv, J1);
165 template <
class MAT,
class EDGE_ITERATOR>
167 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
169 JtJ.multiply_AtBC(J1, edge->second.cov_inv, J2);
172 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
174 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
177 JtInf.multiply_AtB(J, edge->second.cov_inv);
178 JtInf.multiply_Ab(ERR, OUT,
true );
186 template <
class GRAPH_T>
188 const GRAPH_T& graph,
198 lstJacobians.clear();
201 const size_t nObservations = lstObservationData.size();
203 for (
size_t i = 0; i < nObservations; i++)
205 const typename gst::observation_info_t& obs = lstObservationData[i];
206 typename gst::edge_const_iterator it = obs.edge;
207 const typename gst::graph_t::constraint_t::type_value* EDGE_POSE =
209 typename gst::graph_t::constraint_t::type_value* P1 = obs.P1;
210 typename gst::graph_t::constraint_t::type_value* P2 = obs.P2;
213 const typename gst::graph_t::edge_t& edge = it->second;
218 typename gst::graph_t::constraint_t::type_value P1DP2inv(
221 typename gst::graph_t::constraint_t::type_value P1D(
223 P1D.composeFrom(*P1, *EDGE_POSE);
224 const typename gst::graph_t::constraint_t::type_value P2inv =
226 P1DP2inv.composeFrom(P1D, P2inv);
230 errs.resize(errs.size() + 1);
232 P1DP2inv, errs.back(), edge);
236 std::pair<mrpt::utils::TPairNodeIDs, typename gst::TPairJacobs>
238 newMapEntry.first =
ids;
239 gst::SE_TYPE::jacobian_dP1DP2inv_depsilon(
240 P1DP2inv, &newMapEntry.second.first, &newMapEntry.second.second);
243 lstJacobians.insert(lstJacobians.end(), newMapEntry);
249 double ret_err = 0.0;
250 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.
std::pair< TNodeID, TNodeID > TPairNodeIDs
A pair of node IDs.
static void multiplyJ1tLambdaJ2(const MAT &J1, const MAT &J2, MAT &JtJ, const EDGE_ITERATOR &edge)
mrpt::aligned_containers< mrpt::utils::TPairNodeIDs, TPairJacobs >::multimap_t map_pairIDs_pairJacobs_t
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)
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.
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)