SRBA: Sparser Relative Bundle Adjustment
srba/models/landmarks.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 <srba/landmark_render_models.h>
00013 #include <srba/landmark_jacob_families.h>
00014 
00015 namespace srba {
00016 namespace landmarks {
00017 
00025     struct Euclidean3D
00026     {
00027         static const size_t  LM_DIMS = 3; 
00028         static const landmark_jacob_family_t  jacob_family = jacob_point_landmark;  
00029         //static const size_t  LM_EUCLIDEAN_DIMS = 3; //!< Either 2 or 3, depending on the real minimum number of coordinates needed to parameterize the landmark.
00030         typedef srba::landmark_rendering_as_point render_mode_t;
00031 
00033         template <class VECTOR> inline static void relativeEuclideanLocation(const VECTOR &posParams, mrpt::math::TPoint3D &posEuclidean)
00034         {
00035             posEuclidean.x = posParams[0];
00036             posEuclidean.y = posParams[1];
00037             posEuclidean.z = posParams[2];
00038         }
00039 
00043         template <class POSE,class VECTOR>
00044         inline static void composePosePoint(VECTOR & pt, const POSE & pose) {
00045             pose.composePoint(pt[0],pt[1],pt[2], pt[0],pt[1],pt[2]);
00046         }
00051         template <class POSE,class VECTOR>
00052         static inline void inverseComposePosePoint(const VECTOR &lm_global,VECTOR &lm_local,const POSE &pose) {
00053             pose.inverseComposePoint(lm_global[0],lm_global[1],lm_global[2], lm_local[0],lm_local[1],lm_local[2]);
00054         }
00055     };
00056 
00058     struct Euclidean2D
00059     {
00060         static const size_t  LM_DIMS = 2; 
00061         static const landmark_jacob_family_t  jacob_family = jacob_point_landmark;  
00062         //static const size_t  LM_EUCLIDEAN_DIMS = 2; //!< Either 2 or 3, depending on the real minimum number of coordinates needed to parameterize the landmark.
00063         typedef srba::landmark_rendering_as_point render_mode_t;
00064 
00066         template <class VECTOR> inline static void relativeEuclideanLocation(const VECTOR &posParams, mrpt::math::TPoint3D &posEuclidean)
00067         {
00068             posEuclidean.x = posParams[0];
00069             posEuclidean.y = posParams[1];
00070             posEuclidean.z = 0;
00071         }
00072 
00076         template <class POSE,class VECTOR>
00077         inline static void composePosePoint(VECTOR & pt, const POSE & pose) {
00078             double lx,ly,lz;
00079             pose.composePoint(pt[0],pt[1],0, lx,ly,lz);
00080             pt[0]=lx; pt[1]=ly;
00081             ASSERTMSG_(std::abs(lz)<1e-2, "Error: Using a 3D transformation to obtain a 2D point but it results in |z|>eps")
00082         }
00087         template <class POSE,class VECTOR>
00088         static inline void inverseComposePosePoint(const VECTOR &lm_global,VECTOR &lm_local,const POSE &pose) {
00089             pose.inverseComposePoint(lm_global[0],lm_global[1], lm_local[0],lm_local[1]);
00090         }
00091     };
00092 
00094     struct RelativePoses2D
00095     {
00096         static const size_t  LM_DIMS = 3; 
00097         static const landmark_jacob_family_t  jacob_family = jacob_relpose_landmark;  
00098         //static const size_t  LM_EUCLIDEAN_DIMS = 3; //!< Either 2 or 3, depending on the real minimum number of coordinates needed to parameterize the landmark.
00099         typedef srba::landmark_rendering_as_pose_constraints render_mode_t;
00100 
00104         template <class POSE,class VECTOR>
00105         inline static void composePosePoint(VECTOR & pt, const POSE & pose) {
00106             MRPT_UNUSED_PARAM(pt);
00107             MRPT_UNUSED_PARAM(pose);
00108             // Not applicable: nothing to do on "pt"
00109         }
00114         template <class POSE,class VECTOR>
00115         static inline void inverseComposePosePoint(const VECTOR &lm_global,VECTOR &lm_local,const POSE &pose) {
00116             // Not applicable
00117             MRPT_UNUSED_PARAM(pose);
00118             lm_local=lm_global;
00119         }
00120 
00121     };
00122 
00124     struct RelativePoses3D
00125     {
00126         static const size_t  LM_DIMS = 6; 
00127         static const landmark_jacob_family_t  jacob_family = jacob_relpose_landmark;  
00128         //static const size_t  LM_EUCLIDEAN_DIMS = 3; //!< Either 2 or 3, depending on the real minimum number of coordinates needed to parameterize the landmark.
00129         typedef srba::landmark_rendering_as_pose_constraints render_mode_t;
00130 
00134         template <class POSE,class VECTOR>
00135         inline static void composePosePoint(VECTOR & pt, const POSE & pose) {
00136             MRPT_UNUSED_PARAM(pt);
00137             MRPT_UNUSED_PARAM(pose);
00138             // Not applicable: nothing to do on "pt"
00139         }
00144         template <class POSE,class VECTOR>
00145         static inline void inverseComposePosePoint(const VECTOR &lm_global,VECTOR &lm_local,const POSE &pose) {
00146             // Not applicable
00147             MRPT_UNUSED_PARAM(pose);
00148             lm_local=lm_global;
00149         }
00150 
00151     };
00152 
00155 }
00156 } // end NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends