9 #ifndef GRAPH_SLAM_LEVMARQ_IMPL_H 10 #define GRAPH_SLAM_LEVMARQ_IMPL_H 27 template <
class POSE,
class gst>
48 static inline void sumIncr(POSE&
p,
const typename gst::Array_O& delta)
64 typename gst::graph_t::constraint_t::type_value exp_delta_pose(
66 gst::SE_TYPE::exp(delta, exp_delta_pose);
67 p =
p + exp_delta_pose;
76 static inline void sumIncr(POSE&
p,
const typename gst::Array_O& delta)
79 typename gst::graph_t::constraint_t::type_value exp_delta_pose(
81 gst::SE_TYPE::exp(delta, exp_delta_pose);
82 p =
p + exp_delta_pose;
89 template <
class EDGE,
class gst>
96 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
98 const POSE& DinvP1invP2, VEC& err,
const EDGE_ITERATOR& edge)
101 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
104 template <
class MAT,
class EDGE_ITERATOR>
106 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
109 JtJ = J1.transpose() * J1;
112 template <
class MAT,
class EDGE_ITERATOR>
114 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
117 JtJ = J1.transpose() * J2;
120 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
122 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
125 const auto grad_incr = (J.transpose() * ERR).eval();
134 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
136 const POSE& DinvP1invP2, VEC& err,
const EDGE_ITERATOR& edge)
139 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
142 template <
class MAT,
class EDGE_ITERATOR>
144 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
147 JtJ = J1.transpose() * J1;
150 template <
class MAT,
class EDGE_ITERATOR>
152 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
155 JtJ = J1.transpose() * J2;
158 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
160 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
163 OUT += J.transpose() * ERR;
171 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
173 const POSE& DinvP1invP2, VEC& err,
const EDGE_ITERATOR& edge)
175 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
178 template <
class MAT,
class EDGE_ITERATOR>
180 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
182 JtJ = (J1.transpose() * edge->second.cov_inv) * J1;
184 template <
class MAT,
class EDGE_ITERATOR>
186 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
188 JtJ = (J1.transpose() * edge->second.cov_inv) * J2;
191 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
193 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
195 OUT += (J.transpose() * edge->second.cov_inv) * ERR;
203 template <
class POSE,
class VEC,
class EDGE_ITERATOR>
205 const POSE& DinvP1invP2, VEC& err,
const EDGE_ITERATOR& edge)
208 gst::SE_TYPE::pseudo_ln(DinvP1invP2, err);
211 template <
class MAT,
class EDGE_ITERATOR>
213 const MAT& J1, MAT& JtJ,
const EDGE_ITERATOR& edge)
215 JtJ = (J1.transpose() * edge->second.cov_inv) * J1;
218 template <
class MAT,
class EDGE_ITERATOR>
220 const MAT& J1,
const MAT& J2, MAT& JtJ,
const EDGE_ITERATOR& edge)
222 JtJ = (J1.transpose() * edge->second.cov_inv) * J2;
225 template <
class JAC,
class EDGE_ITERATOR,
class VEC1,
class VEC2>
227 const JAC& J,
const EDGE_ITERATOR& edge,
const VEC1& ERR, VEC2& OUT)
229 OUT += (J.transpose() * edge->second.cov_inv) * ERR;
237 template <
class GRAPH_T>
239 const GRAPH_T& graph,
248 lstJacobians.clear();
251 const size_t nObservations = lstObservationData.size();
253 for (
size_t i = 0; i < nObservations; i++)
255 const typename gst::observation_info_t& obs = lstObservationData[i];
257 const typename gst::graph_t::constraint_t::type_value* EDGE_POSE =
259 typename gst::graph_t::constraint_t::type_value* P1 = obs.P1;
260 typename gst::graph_t::constraint_t::type_value* P2 = obs.P2;
262 const auto&
ids = e->first;
263 const auto& edge = e->second;
268 typename gst::graph_t::constraint_t::type_value DinvP1invP2 =
269 ((*P2) - (*P1)) - *EDGE_POSE;
272 errs.resize(errs.size() + 1);
274 DinvP1invP2, errs.back(), edge);
278 std::pair<mrpt::graphs::TPairNodeIDs, typename gst::TPairJacobs>
280 newMapEntry.first =
ids;
281 gst::SE_TYPE::jacobian_dDinvP1invP2_depsilon(
282 -(*EDGE_POSE), *P1, *P2, &newMapEntry.second.first,
283 &newMapEntry.second.second);
286 lstJacobians.insert(lstJacobians.end(), newMapEntry);
292 double ret_err = 0.0;
293 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)
#define MRPT_MAX_ALIGN_BYTES
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)
std::vector< T, mrpt::aligned_allocator_cpp11< T > > aligned_std_vector
static void sumIncr(CPose3D &p, const typename gst::Array_O &delta)
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, mrpt::aligned_std_vector< typename graphslam_traits< GRAPH_T >::Array_O > &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)
mrpt::aligned_std_multimap< mrpt::graphs::TPairNodeIDs, TPairJacobs > map_pairIDs_pairJacobs_t
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)
typename SE_TYPE::array_t Array_O
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)
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
static void sumIncr(CPose2D &p, const typename gst::Array_O &delta)