SRBA: Sparser Relative Bundle Adjustment
srba/srba_options_noise.h
00001 /* +---------------------------------------------------------------------------+
00002    |                     Mobile Robot Programming Toolkit (MRPT)               |
00003    |                          http://www.mrpt.org/                             |
00004    |                                                                           |
00005    | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file        |
00006    | See: http://www.mrpt.org/Authors - All rights reserved.                   |
00007    | Released under BSD License. See details in http://www.mrpt.org/License    |
00008    +---------------------------------------------------------------------------+ */
00009 
00010 #pragma once
00011 
00012 #include <mrpt/poses/CPose2D.h>
00013 #include <mrpt/poses/CPose3D.h>
00014 #include <mrpt/math/lightweight_geom_data.h>
00015 
00016 namespace srba {
00017 namespace options
00018 {
00025         struct observation_noise_identity
00026         {
00028             struct parameters_t
00029             {
00031                 double std_noise_observations;
00032 
00033                 parameters_t() : std_noise_observations (1.) 
00034                 { }
00035             };
00036 
00038             struct noise_data_per_obs_t
00039             {
00040                 // None: all obs. have the same value="std_noise_observations" 
00041             };
00042 
00044             template <class MATRIX_H,class MATRIX_J1,class MATRIX_J2>
00045             inline static void accum_JtJ(MATRIX_H & H, const MATRIX_J1 & J1, const MATRIX_J2 &J2, const size_t obs_idx, const parameters_t & obs_noise_params) 
00046             {
00047                 MRPT_UNUSED_PARAM(obs_idx); MRPT_UNUSED_PARAM(obs_noise_params);
00048                 H.noalias() += J1.transpose() * J2;  // The constant scale factor 1/sigma will be applied in the end (below)
00049             }
00051             template <class MATRIX_H>
00052             inline static void scale_H(MATRIX_H & H, const parameters_t & obs_noise_params) 
00053             {
00054                 ASSERTDEB_(obs_noise_params.std_noise_observations>0)
00055                 H *= 1.0/obs_noise_params.std_noise_observations;
00056             }
00057 
00059             template <class VECTOR_GRAD,class MATRIX_J,class VECTOR_R>
00060             inline static void accum_Jtr(VECTOR_GRAD & g, const MATRIX_J & J, const VECTOR_R &r, const size_t obs_idx, const parameters_t & obs_noise_params) 
00061             {
00062                 MRPT_UNUSED_PARAM(obs_idx); MRPT_UNUSED_PARAM(obs_noise_params);
00063                 g.noalias() += J.transpose() * r;  // The constant scale factor 1/sigma will be applied in the end (below)
00064             }
00066             template <class VECTOR_GRAD>
00067             inline static void scale_Jtr(VECTOR_GRAD & g, const parameters_t & obs_noise_params) 
00068             {
00069                 ASSERTDEB_(obs_noise_params.std_noise_observations>0)
00070                 g *= 1.0/obs_noise_params.std_noise_observations;
00071             }
00072 
00073         };  // end of "observation_noise_identity"
00074 
00078         template <class obs_t>
00079         struct observation_noise_constant_matrix
00080         {
00081             static const size_t OBS_DIMS = obs_t::OBS_DIMS;  
00082 
00083             typedef Eigen::Matrix<double,OBS_DIMS,OBS_DIMS>  obs_noise_matrix_t; 
00084 
00086             struct parameters_t
00087             {
00089                 obs_noise_matrix_t  lambda;
00090 
00091                 parameters_t() : lambda( obs_noise_matrix_t::Identity() ) 
00092                 { }
00093             };
00094 
00096             struct noise_data_per_obs_t
00097             {
00098                 // None: all obs. have the same value
00099             };
00100 
00102             template <class MATRIX_H,class MATRIX_J1,class MATRIX_J2>
00103             inline static void accum_JtJ(MATRIX_H & H, const MATRIX_J1 & J1, const MATRIX_J2 &J2,
00104                 const size_t obs_idx, const parameters_t & obs_noise_params) 
00105             {
00106                 MRPT_UNUSED_PARAM(obs_idx);
00107                 H.noalias() += J1.transpose() * obs_noise_params.lambda * J2;
00108             }
00109 
00111             template <class MATRIX_H>
00112             inline static void scale_H(MATRIX_H & H, const parameters_t & obs_noise_params) 
00113             {  // Nothing else to do.
00114                 MRPT_UNUSED_PARAM(H);
00115                 MRPT_UNUSED_PARAM(obs_noise_params);
00116             }
00117 
00119             template <class VECTOR_GRAD,class MATRIX_J,class VECTOR_R>
00120             inline static void accum_Jtr(VECTOR_GRAD & g, const MATRIX_J & J, const VECTOR_R &r,
00121                 const size_t obs_idx, const parameters_t & obs_noise_params) 
00122             {
00123                 MRPT_UNUSED_PARAM(obs_idx);
00124                 g.noalias() += J.transpose() * obs_noise_params.lambda * r;
00125             }
00127             template <class VECTOR_GRAD>
00128             inline static void scale_Jtr(VECTOR_GRAD & g, const parameters_t & obs_noise_params) 
00129             {  // Nothing else to do.
00130                 MRPT_UNUSED_PARAM(g); MRPT_UNUSED_PARAM(obs_noise_params);
00131             }
00132 
00133         };  // end of "observation_noise_constant_matrix"
00134 
00135 } } // End of namespaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends