Landmark.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2018, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef CORELIB_INCLUDE_RTABMAP_CORE_LANDMARK_H_
29 #define CORELIB_INCLUDE_RTABMAP_CORE_LANDMARK_H_
30 
31 #include <rtabmap/core/Transform.h>
33 #include <rtabmap/utilite/UMath.h>
35 
36 namespace rtabmap {
37 
38 class Landmark
39 {
40 public:
42  id_(0)
43  {}
44  Landmark(const int & id, const Transform & pose, const cv::Mat & covariance) :
45  id_(id),
46  pose_(pose),
47  covariance_(covariance)
48  {
49  UASSERT(id_>0);
50  UASSERT(!pose_.isNull());
51  UASSERT(covariance_.cols == 6 && covariance_.rows == 6 && covariance_.type() == CV_64FC1);
52  UASSERT_MSG(uIsFinite(covariance_.at<double>(0,0)) && covariance_.at<double>(0,0)>0, uFormat("Linear covariance should not be null! Value=%f.", covariance_.at<double>(0,0)).c_str());
53  UASSERT_MSG(uIsFinite(covariance_.at<double>(1,1)) && covariance_.at<double>(1,1)>0, uFormat("Linear covariance should not be null! Value=%f.", covariance_.at<double>(1,1)).c_str());
54  UASSERT_MSG(uIsFinite(covariance_.at<double>(2,2)) && covariance_.at<double>(2,2)>0, uFormat("Linear covariance should not be null! Value=%f.", covariance_.at<double>(2,2)).c_str());
55  UASSERT_MSG(uIsFinite(covariance_.at<double>(3,3)) && covariance_.at<double>(3,3)>0, uFormat("Angular covariance should not be null! Value=%f (set to 9999 if unknown).", covariance_.at<double>(3,3)).c_str());
56  UASSERT_MSG(uIsFinite(covariance_.at<double>(4,4)) && covariance_.at<double>(4,4)>0, uFormat("Angular covariance should not be null! Value=%f (set to 9999 if unknown).", covariance_.at<double>(4,4)).c_str());
57  UASSERT_MSG(uIsFinite(covariance_.at<double>(5,5)) && covariance_.at<double>(5,5)>0, uFormat("Angular covariance should not be null! Value=%f (set to 9999 if unknown).", covariance_.at<double>(5,5)).c_str());
58  }
59 
60  virtual ~Landmark() {}
61 
62  const int & id() const {return id_;}
63  const Transform & pose() const {return pose_;}
64  const cv::Mat & covariance() const {return covariance_;}
65 
66 private:
67  int id_;
69  cv::Mat covariance_;
70 };
71 
72 typedef std::map<int, Landmark> Landmarks;
73 
74 }
75 
76 #endif /* CORELIB_INCLUDE_RTABMAP_CORE_LANDMARK_H_ */
const int & id() const
Definition: Landmark.h:62
std::map< int, Landmark > Landmarks
Definition: Landmark.h:72
Basic mathematics functions.
const cv::Mat & covariance() const
Definition: Landmark.h:64
Some conversion functions.
Landmark(const int &id, const Transform &pose, const cv::Mat &covariance)
Definition: Landmark.h:44
bool uIsFinite(const T &value)
Definition: UMath.h:55
#define UASSERT(condition)
bool isNull() const
Definition: Transform.cpp:107
#define UASSERT_MSG(condition, msg_str)
Definition: ULogger.h:67
virtual ~Landmark()
Definition: Landmark.h:60
const Transform & pose() const
Definition: Landmark.h:63
ULogger class and convenient macros.
Transform pose_
Definition: Landmark.h:68
cv::Mat covariance_
Definition: Landmark.h:69
std::string UTILITE_EXP uFormat(const char *fmt,...)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59