SRBA: Sparser Relative Bundle Adjustment
|
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/tfest.h> // for use in landmark_matcher<> 00013 00014 namespace srba { 00015 namespace observations { 00020 struct RelativePoses_3D 00021 { 00022 static const size_t OBS_DIMS = 6; 00023 00025 struct obs_data_t 00026 { 00027 double x,y,z; 00028 double yaw,pitch,roll; 00029 00031 template <class ARRAY> 00032 inline void getAsArray(ARRAY &obs) const { 00033 obs[0]=x; obs[1]=y; obs[2]=z; 00034 obs[3]=yaw; obs[4]=pitch; obs[5]=roll; 00035 } 00036 }; 00037 00040 struct TObservationParams 00041 { 00042 // This type of observations has no further parameters. 00043 }; 00044 }; 00045 00047 template <> struct landmark_matcher<RelativePoses_3D> 00048 { 00049 template <class POSE> 00050 static bool find_relative_pose( 00051 const mrpt::aligned_containers<RelativePoses_3D::obs_data_t>::vector_t & new_kf_obs, 00052 const mrpt::aligned_containers<RelativePoses_3D::obs_data_t>::vector_t & old_kf_obs, 00053 const RelativePoses_3D::TObservationParams ¶ms, 00054 POSE &pose_new_kf_wrt_old_kf) 00055 { 00056 ASSERT_(new_kf_obs.size()==old_kf_obs.size()) 00057 // Find the observation related to one of the two KFs connected by this new edge: it should have an exact (0,...,0) in its relative pose: 00058 for (size_t i=0;i<new_kf_obs.size();i++) 00059 { 00060 const RelativePoses_3D::obs_data_t & kf0 = new_kf_obs[i], &kf1 = old_kf_obs[i]; 00061 if ( (kf0.x!=0 || kf0.y!=0 || kf0.z!=0 || kf0.yaw!=0 || kf0.pitch!=0 || kf0.roll!=0) && 00062 (kf1.x!=0 || kf1.y!=0 || kf1.z!=0 || kf1.yaw!=0 || kf1.pitch!=0 || kf1.roll!=0) ) 00063 continue; // skip. 00064 const mrpt::poses::CPose3D new_obs(kf0.x,kf0.y,kf0.z,kf0.yaw,kf0.pitch,kf0.roll); 00065 const mrpt::poses::CPose3D old_obs(kf1.x,kf1.y,kf1.z,kf1.yaw,kf1.pitch,kf1.roll); 00066 pose_new_kf_wrt_old_kf = POSE(old_obs-new_obs); 00067 return true; 00068 } 00069 return false; // None found (should not happen?) 00070 } 00071 }; 00072 00074 } 00075 } // end NS