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/rtabmap_core_export.h>
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),
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  // Use constructor with size=0 instead.
63  RTABMAP_DEPRECATED Landmark(const int & id, const Transform & pose, const cv::Mat & covariance);
64 
65  virtual ~Landmark() {}
66 
67  const int & id() const {return id_;}
68  const float & size() const {return size_;}
69  const Transform & pose() const {return pose_;}
70  const cv::Mat & covariance() const {return covariance_;}
71 
72 private:
73  int id_;
74  float size_;
76  cv::Mat covariance_;
77 };
78 
79 typedef std::map<int, Landmark> Landmarks;
80 
81 inline Landmark::Landmark(const int & id, const Transform & pose, const cv::Mat & covariance) :
82  id_(id),
83  size_(0.0f),
84  pose_(pose),
85  covariance_(covariance)
86 {
87  UASSERT(id_>0);
88  UASSERT(!pose_.isNull());
89  UASSERT(covariance_.cols == 6 && covariance_.rows == 6 && covariance_.type() == CV_64FC1);
90  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());
91  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());
92  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());
93  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());
94  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());
95  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());
96 }
97 
98 }
99 
100 #endif /* CORELIB_INCLUDE_RTABMAP_CORE_LANDMARK_H_ */
rtabmap::Landmark::~Landmark
virtual ~Landmark()
Definition: Landmark.h:65
rtabmap::Landmark::pose_
Transform pose_
Definition: Landmark.h:75
rtabmap::Landmark::id_
int id_
Definition: Landmark.h:73
rtabmap::Landmark::Landmark
Landmark()
Definition: Landmark.h:42
rtabmap::Landmark::covariance
const cv::Mat & covariance() const
Definition: Landmark.h:70
rtabmap::Landmark::size_
float size_
Definition: Landmark.h:74
rtabmap::RTABMAP_DEPRECATED
RTABMAP_DEPRECATED(typedef SensorData Image, "rtabmap::Image class is renamed to rtabmap::SensorData, use the last one instead.")
Transform.h
rtabmap::Landmarks
std::map< int, Landmark > Landmarks
Definition: Landmark.h:79
rtabmap::Transform::isNull
bool isNull() const
Definition: Transform.cpp:107
rtabmap::Landmark::id
const int & id() const
Definition: Landmark.h:67
UMath.h
Basic mathematics functions.
rtabmap::Landmark
Definition: Landmark.h:39
rtabmap::Landmark::covariance_
cv::Mat covariance_
Definition: Landmark.h:76
UConversion.h
Some conversion functions.
UASSERT
#define UASSERT(condition)
UASSERT_MSG
#define UASSERT_MSG(condition, msg_str)
Definition: ULogger.h:67
f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
rtabmap::Landmark::Landmark
Landmark(const int &id, const float &size, const Transform &pose, const cv::Mat &covariance)
Definition: Landmark.h:46
uFormat
std::string UTILITE_EXPORT uFormat(const char *fmt,...)
Definition: UConversion.cpp:365
ULogger.h
ULogger class and convenient macros.
rtabmap::Transform
Definition: Transform.h:41
id
id
rtabmap::Landmark::pose
const Transform & pose() const
Definition: Landmark.h:69
rtabmap
Definition: CameraARCore.cpp:35
uIsFinite
bool uIsFinite(const T &value)
Definition: UMath.h:53
rtabmap::Landmark::size
const float & size() const
Definition: Landmark.h:68


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11