Go to the documentation of this file.00001
00009 #ifndef OBSERVATIONPINHOLEEUCLIDEANPOINT_HPP_
00010 #define OBSERVATIONPINHOLEEUCLIDEANPOINT_HPP_
00011
00012 #include "rtslam/observationAbstract.hpp"
00013 #include "rtslam/sensorPinhole.hpp"
00014 #include "rtslam/landmarkEuclideanPoint.hpp"
00015 #include "boost/shared_ptr.hpp"
00016
00017 namespace jafar {
00018 namespace rtslam {
00019
00020 class ObservationPinHoleEuclideanPoint;
00021 typedef boost::shared_ptr<ObservationPinHoleEuclideanPoint> obs_ph_euc_ptr_t;
00022
00023 class ObservationModelPinHoleEuclideanPoint: public ObservationModelAbstract
00024 {
00025 public:
00026 typedef SensorPinhole sensor_spec_t;
00027 typedef boost::shared_ptr<sensor_spec_t> sensor_spec_ptr_t;
00028 typedef boost::weak_ptr<sensor_spec_t> sensor_spec_wptr_t;
00029 protected:
00030 sensor_spec_wptr_t sensorSpecWPtr;
00031 public:
00032 void linkToPinHole( sensor_spec_ptr_t ptr )
00033 {
00034 sensorSpecWPtr = ptr;
00035 ObservationModelAbstract::linkToSensor(ptr);
00036 }
00037 sensor_spec_ptr_t pinHolePtr( void )
00038 {
00039 sensor_spec_ptr_t sptr = sensorSpecWPtr.lock();
00040 if (!sptr) {
00041 std::cerr << __FILE__ << ":" << __LINE__ << " ObsSpec::sensor threw weak" << std::endl;
00042 throw "WEAK";
00043 }
00044 return sptr;
00045 }
00046 virtual void linkToSensorSpecific( sensor_ptr_t ptr )
00047 {
00048 boost::shared_ptr<SensorPinhole> sptr = SPTR_CAST<SensorPinhole>( ptr );
00049 if( sptr==NULL )
00050 {
00051 std::cerr << __FILE__ << ":" << __LINE__ << " : cast unfair." << std::endl;
00052 throw "CAST";
00053 }
00054 linkToPinHole( sptr );
00055 }
00056
00057 protected:
00058 size_t exp_size, prior_size;
00059 void init_sizes() { exp_size = 2; prior_size = 1; }
00060 public:
00061 ObservationModelPinHoleEuclideanPoint() { init_sizes(); }
00062 ObservationModelPinHoleEuclideanPoint(const sensor_ptr_t & pinholePtr);
00063
00067 virtual void project_func(const vec7 & sg, const vec & lmk, vec & meas, vec & nobs);
00071 virtual void project_func(const vec7 & sg, const vec & lmk, vec & meas, vec & nobs, mat & EXP_sg, mat & EXP_lmk);
00072 virtual void project_func(const vec7 & sg, const vec & lmk, vec & meas, vec & nobs, mat & EXP_sg, mat & EXP_lmk, const vec lmk_fej);
00076 virtual void backProject_func(const vec7 & sg, const vec & meas, const vec & nobs, vec & euc);
00077 static void backProject_func_func(const vec4 & k, const vec & c, const vec7 & sg, const vec & meas, const vec & nobs, vec & euc);
00081 virtual void backProject_func(const vec7 & sg, const vec & meas, const vec & nobs, vec & euc, mat & EUC_sg,
00082 mat & EUC_meas, mat & EUC_nobs);
00083 static void backProject_func_func(const vec4 & k, const vec & c, const vec7 & sg, const vec & meas, const vec & nobs, vec & euc,
00084 mat & EUC_sg, mat & EUC_meas, mat & EUC_nobs);
00085
00086
00094 virtual bool predictVisibility_func(jblas::vec x, jblas::vec nobs);
00095
00096 };
00097
00103 class ObservationPinHoleEuclideanPoint: public ObservationAbstract,
00104 public SpecificChildOf<LandmarkEuclideanPoint>
00105 {
00106 public:
00107
00108 ENABLE_LINK_TO_SPECIFIC_PARENT(LandmarkAbstract,LandmarkEuclideanPoint,EUC,ObservationAbstract);
00109
00110
00111 ENABLE_ACCESS_TO_SPECIFIC_PARENT(LandmarkEuclideanPoint,euc);
00112
00113 boost::shared_ptr<ObservationModelPinHoleEuclideanPoint> modelSpec;
00114 void linkToPinHole( ObservationModelPinHoleEuclideanPoint::sensor_spec_ptr_t ptr ) { modelSpec->linkToPinHole(ptr); }
00115 ObservationModelPinHoleEuclideanPoint::sensor_spec_ptr_t pinHolePtr( void ) { return modelSpec->pinHolePtr(); }
00116 void linkToSensorSpecific( sensor_ptr_t ptr ) { modelSpec->linkToSensorSpecific(ptr); }
00117
00118 public:
00119 ObservationPinHoleEuclideanPoint(const sensor_ptr_t & pinholePtr, const landmark_ptr_t & eucPtr);
00120 ~ObservationPinHoleEuclideanPoint(void){
00121
00122 }
00123
00124 void setup(double dmin);
00125
00126 virtual std::string typeName() const {
00127 return "Pinhole-Euclidean-point";
00128 }
00129
00133 virtual bool predictAppearance_func();
00134
00135 virtual double computeLinearityScore(){
00136 return 0.0;
00137 }
00138
00139 virtual void desc_image(image::oimstream& os) const;
00140
00141 public:
00142 double pixelNoise;
00143
00144 };
00145
00146 }
00147 }
00148
00149 #endif