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 
32 #include <rtabmap/core/Transform.h>
34 #include <rtabmap/utilite/UMath.h>
36 
37 namespace rtabmap {
38 
39 class Landmark
40 {
41 public:
43  id_(0),
44  size_(0.0f)
45  {}
46  Landmark(const int & id, const float & size, const Transform & pose, const cv::Mat & covariance) :
47  id_(id),
48  size_(size),
49  pose_(pose),
50  covariance_(covariance)
51  {
52  UASSERT(id_>0);
53  UASSERT(!pose_.isNull());
54  UASSERT(covariance_.cols == 6 && covariance_.rows == 6 && covariance_.type() == CV_64FC1);
55  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());
56  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());
57  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());
58  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());
59  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());
60  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());
61  }
62  RTABMAP_DEPRECATED(Landmark(const int & id, const Transform & pose, const cv::Mat & covariance), "Use constructor with size=0 instead.");
63 
64  virtual ~Landmark() {}
65 
66  const int & id() const {return id_;}
67  const float & size() const {return size_;}
68  const Transform & pose() const {return pose_;}
69  const cv::Mat & covariance() const {return covariance_;}
70 
71 private:
72  int id_;
73  float size_;
75  cv::Mat covariance_;
76 };
77 
78 typedef std::map<int, Landmark> Landmarks;
79 
80 inline Landmark::Landmark(const int & id, const Transform & pose, const cv::Mat & covariance) :
81  id_(id),
82  size_(0.0f),
83  pose_(pose),
84  covariance_(covariance)
85 {
86  UASSERT(id_>0);
87  UASSERT(!pose_.isNull());
88  UASSERT(covariance_.cols == 6 && covariance_.rows == 6 && covariance_.type() == CV_64FC1);
89  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());
90  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());
91  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());
92  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());
93  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());
94  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());
95 }
96 
97 }
98 
99 #endif /* CORELIB_INCLUDE_RTABMAP_CORE_LANDMARK_H_ */
RTABMAP_DEPRECATED(Landmark(const int &id, const Transform &pose, const cv::Mat &covariance), "Use constructor with size=0 instead.")
f
std::map< int, Landmark > Landmarks
Definition: Landmark.h:78
Basic mathematics functions.
const cv::Mat & covariance() const
Definition: Landmark.h:69
Some conversion functions.
bool uIsFinite(const T &value)
Definition: UMath.h:55
#define UASSERT(condition)
const int & id() const
Definition: Landmark.h:66
const Transform & pose() const
Definition: Landmark.h:68
#define UASSERT_MSG(condition, msg_str)
Definition: ULogger.h:67
virtual ~Landmark()
Definition: Landmark.h:64
const float & size() const
Definition: Landmark.h:67
bool isNull() const
Definition: Transform.cpp:107
ULogger class and convenient macros.
Transform pose_
Definition: Landmark.h:74
cv::Mat covariance_
Definition: Landmark.h:75
std::string UTILITE_EXP uFormat(const char *fmt,...)
Landmark(const int &id, const float &size, const Transform &pose, const cv::Mat &covariance)
Definition: Landmark.h:46


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28