OKVIS ROS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrameTypedefs.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2  * OKVIS - Open Keyframe-based Visual-Inertial SLAM
3  * Copyright (c) 2015, Autonomous Systems Lab / ETH Zurich
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  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of Autonomous Systems Lab / ETH Zurich nor the names of
14  * its contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Created on: Mar 27, 2013
30  * Author: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
31  * Modified: Andreas Forster (an.forster@gmail.com)
32  *********************************************************************************/
33 
41 #ifndef INCLUDE_OKVIS_FRAMETYPEDEFS_HPP_
42 #define INCLUDE_OKVIS_FRAMETYPEDEFS_HPP_
43 
44 #include <map>
45 
46 #include <Eigen/Core>
48 
50 namespace okvis {
51 
59 {
66  KeypointIdentifier(uint64_t fi = 0, size_t ci = 0, size_t ki = 0)
67  : frameId(fi),
68  cameraIndex(ci),
69  keypointIndex(ki)
70  {
71  }
72 
73  uint64_t frameId;
74  size_t cameraIndex;
75  size_t keypointIndex;
76 
78  uint64_t getFrameId()
79  {
80  return frameId;
81  }
83  void setFrameId(uint64_t fid)
84  {
85  frameId = fid;
86  }
88  bool isBinaryEqual(const KeypointIdentifier & rhs) const
89  {
90  return frameId == rhs.frameId && cameraIndex == rhs.cameraIndex
91  && keypointIndex == rhs.keypointIndex;
92  }
94  bool operator==(const KeypointIdentifier & rhs) const
95  {
96  return isBinaryEqual(rhs);
97  }
100  bool operator<(const KeypointIdentifier & rhs) const
101  {
102 
103  if (frameId == rhs.frameId) {
104  if (cameraIndex == rhs.cameraIndex) {
105  return keypointIndex < rhs.keypointIndex;
106  } else {
107  return cameraIndex < rhs.cameraIndex;
108  }
109  }
110  return frameId < rhs.frameId;
111  }
112 
113 };
114 
116 struct Match
117 {
124  Match(size_t idxA_, size_t idxB_, float distance_)
125  : idxA(idxA_),
126  idxB(idxB_),
127  distance(distance_)
128  {
129  }
130  size_t idxA;
131  size_t idxB;
132  float distance;
133 };
134 typedef std::vector<Match> Matches;
135 
139 struct MapPoint
140 {
141  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
142 
145  : id(0),
146  quality(0.0),
147  distance(0.0)
148  {
149  }
157  MapPoint(uint64_t id, const Eigen::Vector4d & point,
158  double quality, double distance)
159  : id(id),
160  point(point),
161  quality(quality),
162  distance(distance)
163  {
164  }
165  uint64_t id;
166  Eigen::Vector4d point;
167  double quality;
168  double distance;
169  std::map<okvis::KeypointIdentifier, uint64_t> observations;
170 };
171 
172 typedef std::vector<MapPoint, Eigen::aligned_allocator<MapPoint> > MapPointVector;
173 typedef std::map<uint64_t, MapPoint, std::less<uint64_t>,
174  Eigen::aligned_allocator<MapPoint> > PointMap;
175 typedef std::map<uint64_t, okvis::kinematics::Transformation, std::less<uint64_t>,
176  Eigen::aligned_allocator<okvis::kinematics::Transformation> > TransformationMap;
177 
180 {
181  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
182 
196  const Eigen::Vector2d& keypointMeasurement,
197  double keypointSize,
198  size_t cameraIdx,
199  uint64_t frameId,
200  const Eigen::Vector4d& landmark_W,
201  uint64_t landmarkId, bool isInitialized)
202  : keypointIdx(keypointIdx),
203  cameraIdx(cameraIdx),
204  frameId(frameId),
205  keypointMeasurement(keypointMeasurement),
206  keypointSize(keypointSize),
207  landmark_W(landmark_W),
208  landmarkId(landmarkId),
209  isInitialized(isInitialized)
210  {
211  }
213  : keypointIdx(0),
214  cameraIdx(-1),
215  frameId(0),
216  keypointSize(0),
217  landmarkId(0),
218  isInitialized(false)
219  {
220  }
221  size_t keypointIdx;
222  size_t cameraIdx;
223  uint64_t frameId;
224  Eigen::Vector2d keypointMeasurement;
225  double keypointSize;
226  Eigen::Vector4d landmark_W;
227  uint64_t landmarkId;
229 };
230 typedef std::vector<Observation, Eigen::aligned_allocator<Observation> > ObservationVector;
231 
232 // todo: find a better place for this
233 typedef Eigen::Matrix<double, 9, 1> SpeedAndBiases;
234 typedef Eigen::Matrix<double, 9, 1> SpeedAndBias;
235 
236 } // namespace okvis
237 
238 #endif /* INCLUDE_OKVIS_FRAMETYPEDEFS_HPP_ */
size_t keypointIdx
Keypoint ID.
Definition: FrameTypedefs.hpp:221
A type to store information about a point in the world map.
Definition: FrameTypedefs.hpp:139
size_t idxA
Keypoint index in frame A.
Definition: FrameTypedefs.hpp:130
bool operator<(const KeypointIdentifier &rhs) const
Less than operator. Compares first multiframe ID, then camera index, then keypoint index...
Definition: FrameTypedefs.hpp:100
Unique identifier for a keypoint.
Definition: FrameTypedefs.hpp:58
double distance
Distance to origin of the frame the coordinates are given in.
Definition: FrameTypedefs.hpp:168
size_t cameraIndex
Camera index.
Definition: FrameTypedefs.hpp:74
Eigen::Matrix< double, 9, 1 > SpeedAndBias
Definition: FrameTypedefs.hpp:234
Eigen::Vector4d landmark_W
landmark as homogeneous point in body frame B
Definition: FrameTypedefs.hpp:226
Eigen::Vector4d point
Homogeneous coordinate of the point.
Definition: FrameTypedefs.hpp:166
double keypointSize
Keypoint size. Basically standard deviation of the image coordinates in pixels.
Definition: FrameTypedefs.hpp:225
void setFrameId(uint64_t fid)
Set multiframe ID.
Definition: FrameTypedefs.hpp:83
std::vector< MapPoint, Eigen::aligned_allocator< MapPoint > > MapPointVector
Definition: FrameTypedefs.hpp:172
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Observation(size_t keypointIdx, const Eigen::Vector2d &keypointMeasurement, double keypointSize, size_t cameraIdx, uint64_t frameId, const Eigen::Vector4d &landmark_W, uint64_t landmarkId, bool isInitialized)
Constructor.
Definition: FrameTypedefs.hpp:195
float distance
Distance between the keypoints.
Definition: FrameTypedefs.hpp:132
size_t cameraIdx
index of the camera this point is observed in
Definition: FrameTypedefs.hpp:222
std::map< uint64_t, okvis::kinematics::Transformation, std::less< uint64_t >, Eigen::aligned_allocator< okvis::kinematics::Transformation > > TransformationMap
Definition: FrameTypedefs.hpp:176
uint64_t id
ID of the point. E.g. landmark ID.
Definition: FrameTypedefs.hpp:165
uint64_t landmarkId
unique landmark ID
Definition: FrameTypedefs.hpp:227
bool operator==(const KeypointIdentifier &rhs) const
Equal to operator.
Definition: FrameTypedefs.hpp:94
EIGEN_MAKE_ALIGNED_OPERATOR_NEW MapPoint()
Default constructor. Point is at origin with quality 0.0 and ID 0.
Definition: FrameTypedefs.hpp:144
Type to store the result of matching.
Definition: FrameTypedefs.hpp:116
Eigen::Vector2d keypointMeasurement
2D image keypoint [pixels]
Definition: FrameTypedefs.hpp:224
Eigen::Matrix< double, 9, 1 > SpeedAndBiases
Definition: FrameTypedefs.hpp:233
size_t keypointIndex
Index of the keypoint.
Definition: FrameTypedefs.hpp:75
uint64_t frameId
Multiframe ID.
Definition: FrameTypedefs.hpp:73
Header file for the Transformation class.
double quality
Quality of the point. Usually between 0 and 1.
Definition: FrameTypedefs.hpp:167
uint64_t frameId
unique pose block ID == multiframe ID
Definition: FrameTypedefs.hpp:223
std::map< uint64_t, MapPoint, std::less< uint64_t >, Eigen::aligned_allocator< MapPoint > > PointMap
Definition: FrameTypedefs.hpp:174
Observation()
Definition: FrameTypedefs.hpp:212
MapPoint(uint64_t id, const Eigen::Vector4d &point, double quality, double distance)
Constructor.
Definition: FrameTypedefs.hpp:157
std::vector< Match > Matches
Definition: FrameTypedefs.hpp:134
Match(size_t idxA_, size_t idxB_, float distance_)
Constructor.
Definition: FrameTypedefs.hpp:124
KeypointIdentifier(uint64_t fi=0, size_t ci=0, size_t ki=0)
Constructor.
Definition: FrameTypedefs.hpp:66
uint64_t getFrameId()
Get multiframe ID.
Definition: FrameTypedefs.hpp:78
bool isBinaryEqual(const KeypointIdentifier &rhs) const
Are two identifiers identical?
Definition: FrameTypedefs.hpp:88
std::map< okvis::KeypointIdentifier, uint64_t > observations
Observations of this point.
Definition: FrameTypedefs.hpp:169
For convenience to pass associations - also contains the 3d points.
Definition: FrameTypedefs.hpp:179
bool isInitialized
Initialisation status of landmark.
Definition: FrameTypedefs.hpp:228
std::vector< Observation, Eigen::aligned_allocator< Observation > > ObservationVector
Definition: FrameTypedefs.hpp:230
size_t idxB
Keypoint index in frame B.
Definition: FrameTypedefs.hpp:131