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