OdometryEvent.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the Universite de Sherbrooke nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 /* ODOMETRYEVENT_H_ */


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:17