00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ODOMETRYEVENT_H_
00029 #define ODOMETRYEVENT_H_
00030
00031 #include "rtabmap/utilite/UEvent.h"
00032 #include "rtabmap/utilite/ULogger.h"
00033 #include "rtabmap/utilite/UMath.h"
00034 #include "rtabmap/core/SensorData.h"
00035 #include "rtabmap/core/OdometryInfo.h"
00036
00037 namespace rtabmap {
00038
00039 class OdometryEvent : public UEvent
00040 {
00041 public:
00042 static cv::Mat generateCovarianceMatrix(float rotVariance, float transVariance)
00043 {
00044 UASSERT(uIsFinite(rotVariance) && rotVariance>0);
00045 UASSERT(uIsFinite(transVariance) && transVariance>0);
00046 cv::Mat covariance = cv::Mat::eye(6,6,CV_64FC1);
00047 covariance.at<double>(0,0) = transVariance;
00048 covariance.at<double>(1,1) = transVariance;
00049 covariance.at<double>(2,2) = transVariance;
00050 covariance.at<double>(3,3) = rotVariance;
00051 covariance.at<double>(4,4) = rotVariance;
00052 covariance.at<double>(5,5) = rotVariance;
00053 return covariance;
00054 }
00055 public:
00056 OdometryEvent() :
00057 _covariance(cv::Mat::eye(6,6,CV_64FC1))
00058 {
00059 }
00060 OdometryEvent(
00061 const SensorData & data,
00062 const Transform & pose,
00063 const cv::Mat & covariance = cv::Mat::eye(6,6,CV_64FC1),
00064 const OdometryInfo & info = OdometryInfo()) :
00065 _data(data),
00066 _pose(pose),
00067 _info(info)
00068 {
00069 UASSERT(covariance.cols == 6 && covariance.rows == 6 && covariance.type() == CV_64FC1);
00070 UASSERT_MSG(uIsFinite(covariance.at<double>(0,0)) && covariance.at<double>(0,0)>0, "Transitional variance should not be null! (set to 1 if unknown)");
00071 UASSERT_MSG(uIsFinite(covariance.at<double>(1,1)) && covariance.at<double>(1,1)>0, "Transitional variance should not be null! (set to 1 if unknown)");
00072 UASSERT_MSG(uIsFinite(covariance.at<double>(2,2)) && covariance.at<double>(2,2)>0, "Transitional variance should not be null! (set to 1 if unknown)");
00073 UASSERT_MSG(uIsFinite(covariance.at<double>(3,3)) && covariance.at<double>(3,3)>0, "Rotational variance should not be null! (set to 1 if unknown)");
00074 UASSERT_MSG(uIsFinite(covariance.at<double>(4,4)) && covariance.at<double>(4,4)>0, "Rotational variance should not be null! (set to 1 if unknown)");
00075 UASSERT_MSG(uIsFinite(covariance.at<double>(5,5)) && covariance.at<double>(5,5)>0, "Rotational variance should not be null! (set to 1 if unknown)");
00076 _covariance = covariance;
00077 }
00078 OdometryEvent(
00079 const SensorData & data,
00080 const Transform & pose,
00081 double rotVariance = 1.0,
00082 double transVariance = 1.0,
00083 const OdometryInfo & info = OdometryInfo()) :
00084 _data(data),
00085 _pose(pose),
00086 _covariance(generateCovarianceMatrix(rotVariance, transVariance)),
00087 _info(info)
00088 {
00089 }
00090 virtual ~OdometryEvent() {}
00091 virtual std::string getClassName() const {return "OdometryEvent";}
00092
00093 SensorData & data() {return _data;}
00094 const SensorData & data() const {return _data;}
00095 const Transform & pose() const {return _pose;}
00096 const cv::Mat & covariance() const {return _covariance;}
00097 const OdometryInfo & info() const {return _info;}
00098 double rotVariance() const {return uMax3(_covariance.at<double>(3,3), _covariance.at<double>(4,4), _covariance.at<double>(5,5));}
00099 double transVariance() const {return uMax3(_covariance.at<double>(0,0), _covariance.at<double>(1,1), _covariance.at<double>(2,2));}
00100
00101 private:
00102 SensorData _data;
00103 Transform _pose;
00104 cv::Mat _covariance;
00105 OdometryInfo _info;
00106 };
00107
00108 class OdometryResetEvent : public UEvent
00109 {
00110 public:
00111 OdometryResetEvent(){}
00112 virtual ~OdometryResetEvent() {}
00113 virtual std::string getClassName() const {return "OdometryResetEvent";}
00114 };
00115
00116 }
00117
00118
00119 #endif