RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
Landmark.h
1/*
2Copyright (c) 2010-2018, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, 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>
36
37namespace rtabmap {
38
56class RTABMAP_CORE_EXPORT Landmark
57{
58public:
61 id_(0),
62 size_(0.0f)
63 {}
64
72 Landmark(const int & id, const float & size, const Transform & pose, const cv::Mat & covariance) :
73 id_(id),
74 size_(size),
75 pose_(pose),
76 covariance_(covariance)
77 {
78 UASSERT(id_>0);
79 UASSERT(!pose_.isNull());
80 UASSERT(covariance_.cols == 6 && covariance_.rows == 6 && covariance_.type() == CV_64FC1);
81 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());
82 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());
83 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());
84 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());
85 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());
86 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());
87 }
88
92 RTABMAP_DEPRECATED Landmark(const int & id, const Transform & pose, const cv::Mat & covariance);
93
94 virtual ~Landmark() {}
95
97 const int & id() const {return id_;}
99 const float & size() const {return size_;}
101 const Transform & pose() const {return pose_;}
103 const cv::Mat & covariance() const {return covariance_;}
104
105private:
106 int id_;
107 float size_;
108 Transform pose_;
109 cv::Mat covariance_;
110};
111
113typedef std::map<int, Landmark> Landmarks;
114
115inline Landmark::Landmark(const int & id, const Transform & pose, const cv::Mat & covariance) :
116 id_(id),
117 size_(0.0f),
118 pose_(pose),
119 covariance_(covariance)
120{
121 UASSERT(id_>0);
122 UASSERT(!pose_.isNull());
123 UASSERT(covariance_.cols == 6 && covariance_.rows == 6 && covariance_.type() == CV_64FC1);
124 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());
125 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());
126 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());
127 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());
128 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());
129 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());
130}
131
132} // namespace rtabmap
133
134#endif /* CORELIB_INCLUDE_RTABMAP_CORE_LANDMARK_H_ */
Some conversion functions.
std::string UTILITE_EXPORT uFormat(const char *fmt,...)
ULogger class and convenient macros.
#define UASSERT(condition)
Definition ULogger.h:66
Basic mathematics functions.
bool uIsFinite(const T &value)
Definition UMath.h:53
Optimized pose of a visual landmark (e.g. ArUco/AprilTag) in the map.
Definition Landmark.h:57
const cv::Mat & covariance() const
Definition Landmark.h:103
Landmark(const int &id, const float &size, const Transform &pose, const cv::Mat &covariance)
Constructs a landmark with size, pose, and covariance.
Definition Landmark.h:72
const int & id() const
Definition Landmark.h:97
Landmark()
Default-constructs an invalid landmark (id == 0).
Definition Landmark.h:60
const Transform & pose() const
Definition Landmark.h:101
const float & size() const
Definition Landmark.h:99
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
bool isNull() const
Checks whether the transform is null (all zeros).
std::map< int, Landmark > Landmarks
Map of landmark id → Landmark (typically positive keys).
Definition Landmark.h:113