Link.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, 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 LINK_H_
29 #define LINK_H_
30 
31 #include "rtabmap/core/RtabmapExp.h" // DLL export/import defines
32 
33 #include <rtabmap/core/Transform.h>
34 #include <opencv2/core/core.hpp>
35 
36 namespace rtabmap {
37 
39 {
40 public:
41  enum Type {
49  kPosePrior, // Absolute pose in /world frame, From == To
50  kLandmark, // Transform /base_link -­­> /landmark, "From" is node observing the landmark "To" (landmark is negative id)
51  kGravity, // Orientation of the base frame accordingly to gravity (From == To)
53  kSelfRefLink = 97, // Include kPosePrior and kGravity (all links where From=To)
54  kAllWithLandmarks = 98,
55  kAllWithoutLandmarks = 99,
56  kUndef = 99};
57  static std::string typeName(Type type);
58 
59  Link();
60  Link(int from,
61  int to,
62  Type type,
63  const Transform & transform,
64  const cv::Mat & infMatrix = cv::Mat::eye(6,6,CV_64FC1), // information matrix: inverse of covariance matrix
65  const cv::Mat & userData = cv::Mat());
66 
67  bool isValid() const {return from_ != 0 && to_ != 0 && !transform_.isNull() && type_!=kUndef;}
68 
69  int from() const {return from_;}
70  int to() const {return to_;}
71  const Transform & transform() const {return transform_;}
72  Type type() const {return type_;}
73  std::string typeName() const {return typeName(type_);}
74  const cv::Mat & infMatrix() const {return infMatrix_;}
75  double rotVariance(bool minimum = true) const;
76  double transVariance(bool minimum = true) const;
77 
78  void setFrom(int from) {from_ = from;}
79  void setTo(int to) {to_ = to;}
80  void setTransform(const Transform & transform) {transform_ = transform;}
81  void setType(Type type) {type_ = type;}
82 
83  const cv::Mat & userDataRaw() const {return _userDataRaw;}
84  const cv::Mat & userDataCompressed() const {return _userDataCompressed;}
85  void uncompressUserData();
86  cv::Mat uncompressUserDataConst() const;
87 
88  Link merge(const Link & link, Type outputType) const;
89  Link inverse() const;
90 
91 private:
92  void setInfMatrix(const cv::Mat & infMatrix);
93 
94 private:
95  int from_;
96  int to_;
99  cv::Mat infMatrix_; // Information matrix = covariance matrix ^ -1
100 
101  // user data
102  cv::Mat _userDataCompressed; // compressed data
103  cv::Mat _userDataRaw;
104 };
105 
106 }
107 
108 
109 #endif /* LINK_H_ */
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)


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