Go to the documentation of this file.00001
00012 #ifndef OBSERVATIONPINHOLEANCHOREDHOMOGENEOUSPOINTSLINE_HPP
00013 #define OBSERVATIONPINHOLEANCHOREDHOMOGENEOUSPOINTSLINE_HPP
00014 #include "rtslam/observationAbstract.hpp"
00015 #include "rtslam/sensorPinhole.hpp"
00016 #include "rtslam/landmarkAnchoredHomogeneousPointsLine.hpp"
00017
00018 #include "boost/shared_ptr.hpp"
00019
00020 namespace jafar {
00021 namespace rtslam {
00022
00023 class ObservationPinHoleAnchoredHomogeneousPointsLine;
00024 typedef boost::shared_ptr<ObservationPinHoleAnchoredHomogeneousPointsLine> obs_ph_ahpl_ptr_t;
00025
00026 class ObservationModelPinHoleAnchoredHomogeneousPointsLine: public ObservationModelAbstract
00027 {
00028 public:
00029 typedef SensorPinhole sensor_spec_t;
00030 typedef boost::shared_ptr<sensor_spec_t> sensor_spec_ptr_t;
00031 typedef boost::weak_ptr<sensor_spec_t> sensor_spec_wptr_t;
00032 protected:
00033 sensor_spec_wptr_t sensorSpecWPtr;
00034 public:
00035 void linkToPinHole( sensor_spec_ptr_t ptr )
00036 {
00037 sensorSpecWPtr = ptr;
00038 ObservationModelAbstract::linkToSensor(ptr);
00039 }
00040 sensor_spec_ptr_t pinHolePtr( void )
00041 {
00042 sensor_spec_ptr_t sptr = sensorSpecWPtr.lock();
00043 if (!sptr) {
00044 std::cerr << __FILE__ << ":" << __LINE__ << " ObsSpec::sensor threw weak" << std::endl;
00045 throw "WEAK";
00046 }
00047 return sptr;
00048 }
00049 virtual void linkToSensorSpecific( sensor_ptr_t ptr )
00050 {
00051 boost::shared_ptr<SensorPinhole> sptr = SPTR_CAST<SensorPinhole>( ptr );
00052 if( sptr==NULL )
00053 {
00054 std::cerr << __FILE__ << ":" << __LINE__ << " : cast unfair." << std::endl;
00055 throw "CAST";
00056 }
00057 linkToPinHole( sptr );
00058 }
00059 protected:
00060 size_t exp_size, prior_size;
00061 void init_sizes() { exp_size = 4; prior_size = 2; }
00062 public:
00063
00064 ObservationModelPinHoleAnchoredHomogeneousPointsLine() { init_sizes(); }
00065 ObservationModelPinHoleAnchoredHomogeneousPointsLine(const sensor_ptr_t & pinholePtr);
00066
00070 virtual void project_func(const vec7 & sg, const vec & lmk, vec & meas, vec & nobs);
00074 virtual void project_func(const vec7 & sg, const vec & lmk, vec & meas, vec & nobs, mat & EXP_sg, mat & EXP_lmk);
00078 virtual void backProject_func(const vec7 & sg, const vec & meas, const vec & nobs, vec & lmk);
00082 virtual void backProject_func(const vec7 & sg, const vec & meas, const vec & nobs, vec & lmk, mat & LMK_sg,
00083 mat & LMK_meas, mat & LMK_nobs);
00084
00092 virtual bool predictVisibility_func(jblas::vec x, jblas::vec nobs);
00093
00094 };
00095
00096
00102 class ObservationPinHoleAnchoredHomogeneousPointsLine: public ObservationAbstract,
00103 public SpecificChildOf<LandmarkAnchoredHomogeneousPointsLine>
00104 {
00105 public:
00106
00107 ENABLE_LINK_TO_SPECIFIC_PARENT(LandmarkAbstract,LandmarkAnchoredHomogeneousPointsLine,AHP,ObservationAbstract)
00108 ;
00109
00110 ENABLE_ACCESS_TO_SPECIFIC_PARENT(LandmarkAnchoredHomogeneousPointsLine,ahp)
00111 ;
00112
00113 boost::shared_ptr<ObservationModelPinHoleAnchoredHomogeneousPointsLine> modelSpec;
00114 void linkToPinHole( ObservationModelPinHoleAnchoredHomogeneousPointsLine::sensor_spec_ptr_t ptr ) { modelSpec->linkToPinHole(ptr); }
00115 ObservationModelPinHoleAnchoredHomogeneousPointsLine::sensor_spec_ptr_t pinHolePtr( void ) { return modelSpec->pinHolePtr(); }
00116 void linkToSensorSpecific( sensor_ptr_t ptr ) { modelSpec->linkToSensorSpecific(ptr); }
00117
00118 public:
00119
00120 ObservationPinHoleAnchoredHomogeneousPointsLine(const sensor_ptr_t & pinholePtr, const landmark_ptr_t & ahplPtr);
00121 ~ObservationPinHoleAnchoredHomogeneousPointsLine(void) {
00122
00123 }
00124
00125 virtual std::string typeName() const {
00126 return "Pinhole-Anch-homog-points-line";
00127 }
00128
00129
00130 void setup(double dmin);
00131
00132
00133
00137 virtual bool predictAppearance_func();
00138
00139 virtual void desc_image(image::oimstream& os) const;
00140
00141
00142
00143
00144 double computeLinearityScore(){
00145 return lmkAHPL::linearityScore(sensorPtr()->globalPose(), landmarkPtr()->state.x(), landmarkPtr()->state.P());
00146 }
00147
00148 public:
00149 double pixelNoise;
00150 };
00151
00152 }
00153 }
00154
00155 #endif // OBSERVATIONPINHOLEANCHOREDHOMOGENEOUSPOINTSLINE_HPP