MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
include/architecture/slam/mapbuilders/EKFilter.h
00001 /**
00002 *
00003 * Author: Miguel Julia <mjulia@umh.es> 
00004 * 
00005 * Date:   2009
00006 * 
00007 * Class EKF
00008 * 
00009 */
00010 
00011 #pragma once
00012 #ifndef __EKF__
00013 #define __EKF__
00014 #include "vslamFilter.h"
00015 
00016 
00017 /**
00018 * @brief Implements a slam algorithm consisting on a extended Kalman filter
00019 *
00020 */
00021 class EKFilter: public vslamFilter
00022 {
00023 
00024 ///////////////////////////////////////////////////////////////////////
00025 //-------------------------  Attributes  ------------------------------
00026 ///////////////////////////////////////////////////////////////////////.
00027 private:
00028 
00029         Ematrix state;
00030         Ematrix covariance;
00031 
00032         point* robotcells;
00033         float* dispRobot;                               // measure of uncertainty for each robot
00034         pose** odoData;                                 // odometry values
00035         pose** lastOdoData;                             // last odometry values
00036         rangeSensorData** rsData;                       // captured range sensor data 
00037         landmarksData** lmData;                         // captured features
00038 
00039         ClMutex closing;                                // run/stop control
00040         bool endSlam;                                   // stop condition
00041         
00042         gridMapInterface* omap;                         // a common occupancy grid for all particles
00043         binMap* ppmap;                                  // a common precise pose binMap for all particles
00044         binMap* ipmap;                                  // a common imprecise pose binMap for all particles
00045         visualMap* vmap;                                // visual map                   
00046 
00047         matrix Identity3;                               // 3x3 identity matrix
00048         
00049 //      float range;
00050         float mahTh;
00051         float descTh;
00052         int nearestNeighbourOrderBy;
00053         float mediana;
00054         double determinante;
00055 
00056         float maxCorrect;
00057         float minIncorrect;
00058 
00059         int errorcount;
00060 //--------------------------------------------------------------------- 
00061 ///////////////////////////////////////////////////////////////////////
00062 
00063 ///////////////////////////////////////////////////////////////////////
00064 //-------------------------  Methods  ---------------------------------
00065 ///////////////////////////////////////////////////////////////////////
00066 public:
00067         /// Constructor
00068         EKFilter();
00069         /// Destructor
00070         virtual ~EKFilter();
00071         /// Constructor
00072         EKFilter(int nrobots, ConfigFile& configFile);
00073 
00074         ///initializer  
00075         void initialize(int nrobots, ConfigFile& configfile);
00076 
00077         // maps
00078         /// returns a copy of the current occupancy map
00079         gridMapInterface* getOMap();
00080         /// returns a copy of the current visual map
00081         visualMap* getVMap();
00082         /// return a copy of the current precise pose map
00083         binMap* getPreMap();
00084         /// returns a copy of the current imprecise pose map
00085         binMap* getImpMap();
00086 
00087         /// returns the current pose of the robot
00088         pose getPos(int robot);
00089         /// returns the current cell of the robot
00090         point getCell(int robot);
00091         /// returns the matrix that represents the covariance of the position of the robot
00092         matrix getCovariance(int robot) const;
00093         /// returns the matrix that represents the covariance of robots and marks
00094         Ematrix getGlobalCovariance() const;
00095         /// returns a measure of the dispersion of the robot
00096         float getDisp(int robot) const;
00097         /// returns the map as a QImage
00098         QImage* getQImage();
00099         /// returns the map as a QPixmap
00100         QPixmap* getPixmap();
00101 
00102 private:
00103 
00104         /// set up for the execution thread
00105         int setup();                    
00106         /// primary execution loop
00107         void execute();                 
00108         /// called before stopping
00109         void onStop();  
00110         
00111         /// evaluates the uncertainty on the position of each robot
00112         void evalDisp(int r);
00113         /// evaluates the uncertainty on the position of each robot
00114         float evalUncertainty();
00115 
00116         /// odometry noise matrix Q
00117         Ematrix noiseQ(const pose& pos, const pose& deltaOdo, float thetaodo);
00118         /// jacobian F
00119         matrix jacobianF(const pose& pos, const pose& deltaOdo, float thetaodo);
00120         /// jacobian G
00121         Ematrix jacobianG(const pose& pos, const pose& deltaOdo, float thetaodo);
00122         /// jacobian H1
00123         matrix jacobianH1(const pose& pos, const pos3d& mark);
00124         /// jacobian H2
00125         matrix jacobianH2(const pose& pos);
00126         /// jacobian J1
00127         matrix jacobianJ1(const pose& pos, const pos3d& mark);
00128         /// Data association between the new observations and the map
00129         landmark* dataAssociation(const matrix& ZT, const matrix& Rt, const pos3d& globalpos, const pose& robotPos, const matrix& H, const matrix& Htrans, const float* desc, const Ematrix& Pcomp, int r);
00130         /// motion model
00131         matrix motionModel (const pose& pos, const pose& deltaOdo, float thetaodo);
00132         /// Draws the poses of the robots in an opencv image
00133         void drawPose (IplImage& im, const pose& pos, const matrix& covariance, float xorigin, float yorigin, float resolution);
00134 
00135 //--------------------------------------------------------------------- 
00136 ///////////////////////////////////////////////////////////////////////
00137 };
00138 
00139 #endif 
 All Classes Functions Variables Typedefs