SRBA: Sparser Relative Bundle Adjustment
srba/srba_options_sensor_pose.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 {
00022         namespace internal {
00025             template <class SENSOR_POSE_CLASS, size_t KF_POSE_DIMS> struct resulting_pose_t;
00026         }
00027 
00032         struct sensor_pose_on_robot_none
00033         {
00035             struct parameters_t
00036             {
00037             };
00038 
00040             template <class POSE>
00041             static inline void robot2sensor(const POSE & robot, POSE & sensor, const parameters_t &p) {
00042                 MRPT_UNUSED_PARAM(p);
00043                 sensor = robot;
00044             }
00045 
00048             template <class KF_POSE>
00049             static inline void pose_robot2sensor(const KF_POSE & pose_wrt_robot,
00050                 KF_POSE & pose_wrt_sensor, const parameters_t &p) {
00051                 MRPT_UNUSED_PARAM(p);
00052                 pose_wrt_sensor = pose_wrt_robot;
00053             }
00054 
00057             template <class landmark_t, class POINT>
00058             static inline void point_robot2sensor(const POINT & pt_wrt_robot,
00059                 POINT & pt_wrt_sensor, const parameters_t &p) {
00060                 MRPT_UNUSED_PARAM(p);
00061                 pt_wrt_sensor=pt_wrt_robot;
00062             }
00063 
00066             template <class MATRIX>
00067             static inline void jacob_dh_dx_rotate( MATRIX & dh_dx, const parameters_t &p) {
00068                 MRPT_UNUSED_PARAM(dh_dx);
00069                 MRPT_UNUSED_PARAM(p);
00070                 /* nothing to do, since there's no displacement */
00071             }
00072             template <class LANDMARK_T>
00073             static inline void sensor2robot_point(typename landmark_traits<LANDMARK_T>::array_landmark_t & pt,
00074                 const parameters_t &p) {
00075                 MRPT_UNUSED_PARAM(pt); MRPT_UNUSED_PARAM(p);
00076                 /* nothing to do, since there's no displacement */
00077             }
00078         };
00079 
00080         namespace internal {
00083             template <> struct resulting_pose_t<sensor_pose_on_robot_none,3> {
00084                 typedef mrpt::poses::CPose2D pose_t; };
00085             template <> struct resulting_pose_t<sensor_pose_on_robot_none,6> {
00086                 typedef mrpt::poses::CPose3D pose_t; };
00087         }
00088 
00092         struct sensor_pose_on_robot_se3
00093         {
00095             struct parameters_t
00096             {
00097                 mrpt::poses::CPose3D  relative_pose;
00098             };
00099 
00101             template <class KF_POSE>
00102             static inline void robot2sensor(const KF_POSE & robot, mrpt::poses::CPose3D & sensor,
00103                 const parameters_t &p) {
00104                 sensor.composeFrom(robot, p.relative_pose);
00105             }
00106 
00109             template <class KF_POSE>
00110             static inline void pose_robot2sensor(const KF_POSE & pose_wrt_robot,
00111                 mrpt::poses::CPose3D & pose_wrt_sensor, const parameters_t &p) {
00112                 pose_wrt_sensor.inverseComposeFrom(pose_wrt_robot, p.relative_pose);
00113             }
00114 
00117             template <class landmark_t,class POINT>
00118             static inline void point_robot2sensor(const POINT & pt_wrt_robot,
00119                 POINT & pt_wrt_sensor, const parameters_t &p) {
00120                 landmark_t::inverseComposePosePoint(pt_wrt_robot,pt_wrt_sensor,p.relative_pose);
00121             }
00122 
00125             template <class MATRIX>
00126             static inline void jacob_dh_dx_rotate( MATRIX & dh_dx, const parameters_t &p) {
00127                 // dh(R2S+x)_dx = dh(x')_dx' * d(x')_dx
00128                 dh_dx = dh_dx * p.relative_pose.getRotationMatrix().transpose();
00129             }
00130 
00131             template <class LANDMARK_T>
00132             static inline void sensor2robot_point(typename landmark_traits<LANDMARK_T>::array_landmark_t & pt, const parameters_t &p) {
00133                 landmark_traits<LANDMARK_T>::composePosePoint(pt, p.relative_pose);
00134             }
00135         };
00136         namespace internal {
00138             template <> struct resulting_pose_t<sensor_pose_on_robot_se3,3> { typedef mrpt::poses::CPose3D pose_t; };
00139             template <> struct resulting_pose_t<sensor_pose_on_robot_se3,6> { typedef mrpt::poses::CPose3D pose_t; };
00140         }
00141 
00142 } } // End of namespaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends