00001
00002
00003 #ifndef SLAM_KARMA_HPP
00004 #define SLAM_KARMA_HPP
00005
00006 #ifdef HAVE_TTL
00007
00008 #include "jmath/jblas.hpp"
00009 #include "filter/observeModel.hpp"
00010 #include "slam/bearingOnlySlam.hpp"
00011 #include "slam/robot.hpp"
00012 #include "slam/observationsManager.hpp"
00013 #include "slam/map3d.hpp"
00014
00015 namespace jafar {
00016 namespace slam {
00017
00021 class GPSPoseObserveModel : public jafar::filter::LinearObserveModel {
00022
00023 public:
00024
00025 GPSPoseObserveModel();
00026 virtual ~GPSPoseObserveModel();
00027
00028 void setNoise(double xStdDev_, double yStdDev_, double zStdDev_);
00029 };
00030
00034 class GPSSpeedObserveModel : public jafar::filter::LinearObserveModel {
00035
00036 public:
00037
00038 GPSSpeedObserveModel();
00039 virtual ~GPSSpeedObserveModel();
00040
00041 void setNoise(double vxStdDev_, double vyStdDev_, double vzStdDev_);
00042 };
00043
00047 class AttitudeObserveModel : public jafar::filter::LinearObserveModel {
00048
00049 public:
00050
00051 AttitudeObserveModel();
00052 virtual ~AttitudeObserveModel();
00053
00054 void setNoise(double yawStdDev_, double pitchStdDev_, double rollStdDev_);
00055
00056 virtual jblas::vec& computeInnovation(const jblas::vec& z_, const jblas::vec& x_);
00057 };
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00103 class KarmaPredictModel : public jafar::filter::LinearPredictModel {
00104
00105 protected:
00106
00108 jblas::vec accVar;
00109
00111 double yawAccVar;
00112
00114 double pitchSpeedVar;
00115
00117 double rollSpeedVar;
00118
00119 public:
00120
00121 KarmaPredictModel();
00122
00123 virtual ~KarmaPredictModel();
00124
00126 void setAttitudeStdDev(double yawAccStdDev_, double pitchSpeedStdDev_, double rollSpeedStdDev_);
00127
00129 void setAccStdDev(double xAccStdDev_, double yAccStdDev_, double zAccStdDev_);
00130
00131 virtual void setTimeStep(double timeStep_);
00132
00133 };
00134
00138 class KarmaBoSlamHelper : public LocalSlamHelper {
00139
00140 protected:
00141
00142 Map& map;
00143
00144 public:
00145
00146 KarmaBoSlamHelper(SlamEkf& slam_,
00147 std::size_t sizeLocalMapMax_,
00148 std::size_t sizeFeatureState_,
00149 Map& map_);
00150
00151
00152 virtual void cleanSlamMap();
00153
00154 };
00155
00159 class KarmaManager {
00160
00161 protected:
00162
00163 BearingOnlySlam& slam;
00164 Map map;
00165 KarmaBoSlamHelper slamHelper;
00166
00167
00168 BoObservationsManager observationsManager;
00169 KarmaPredictModel predictModel;
00170
00171 GPSPoseObserveModel gpsPoseObserveModel;
00172 GPSSpeedObserveModel gpsSpeedObserveModel;
00173 AttitudeObserveModel attitudeObserveModel;
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 public:
00191
00192 KarmaManager(BearingOnlySlam& slam_,
00193 unsigned int sizeLocalMap_,
00194 double xmin_, double ymin_,
00195 double xmax_, double ymax_);
00196
00197 BearingOnlySlam& getSlam() {return slam;};
00198 jafar::slam::Map& getMap() {return map;};
00199 KarmaPredictModel& getPredictModel() {return predictModel;};
00200 BoObservationsManager& getObservationsManager() {return observationsManager;};
00201 GPSPoseObserveModel& getGPSPoseObserveModel() {return gpsPoseObserveModel;};
00202 GPSSpeedObserveModel& getGPSSpeedObserveModel() {return gpsSpeedObserveModel;};
00203 AttitudeObserveModel& getAttitudeObserveModel() {return attitudeObserveModel;};
00204
00205 void predictTo(double time_);
00206
00207 void setInitState(double timeStamp_,
00208 double x_, double y_, double z_,
00209 double yaw_, double pitch_, double roll_,
00210 double vx_, double vy_, double vz_);
00211
00212
00213 void addGPSData(double timeStamp_,
00214 double x_, double y_, double z_,
00215 double vx_, double vy_, double vz_);
00216
00217 void addAttitudeData(double timeStamp_,
00218 double yaw_, double pitch_, double roll_);
00219
00220 void addLandmarkManually(jafar::hpm::vecHarrisPoints& points_,
00221 unsigned int index_,
00222 jblas::vec const& state_,
00223 jblas::sym_mat const& stateCov_);
00224
00225 void addImageData(double timeStamp_, int imageFrameNumber_, jafar::hpm::vecHarrisPoints& points_);
00226
00227 void saveCurrentMap(std::string const& filename_) const;
00228
00229 void test();
00230
00231 };
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 }
00273 }
00274
00275
00276 #endif // HAVE_TTL
00277 #endif // SLAM_KARMA_HPP