OKVIS ROS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrameRelativeAdapter.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 7, 2013
30  * Author: Stefan Leutenegger (s.leutenegger@imperial.ac.uk)
31  *********************************************************************************/
32 
39 #ifndef INCLUDE_OKVIS_OPENGV_FRAMERELATIVEADAPTER_HPP_
40 #define INCLUDE_OKVIS_OPENGV_FRAMERELATIVEADAPTER_HPP_
41 
42 #include <stdlib.h>
43 #include <vector>
44 #include <opengv/types.hpp>
45 #include <opengv/relative_pose/CentralRelativeAdapter.hpp>
46 #include <okvis/Estimator.hpp>
48 #include <okvis/assert_macros.hpp>
49 
53 namespace opengv {
57 namespace relative_pose {
58 
60 class FrameRelativeAdapter : public RelativeAdapterBase {
61  private:
62  using RelativeAdapterBase::_t12;
63  using RelativeAdapterBase::_R12;
64 
65  public:
66  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67  OKVIS_DEFINE_EXCEPTION(Exception, std::runtime_error)
68 
69 
80  FrameRelativeAdapter(const okvis::Estimator & estimator,
81  const okvis::cameras::NCameraSystem & nCameraSystem,
82  uint64_t multiFrameIdA, size_t camIdA,
83  uint64_t multiFrameIdB, size_t camIdB);
84 
86  }
87 
90 
96  virtual opengv::bearingVector_t getBearingVector1(size_t index) const;
102  virtual opengv::bearingVector_t getBearingVector2(size_t index) const;
110  virtual opengv::translation_t getCamOffset1(size_t index) const;
118  virtual opengv::rotation_t getCamRotation1(size_t index) const;
126  virtual opengv::translation_t getCamOffset2(size_t index) const;
134  virtual opengv::rotation_t getCamRotation2(size_t index) const;
139  virtual size_t getNumberCorrespondences() const;
140 
142 
143  // custom:
149  double getSigmaAngle1(size_t index);
155  double getSigmaAngle2(size_t index);
161  size_t getMatchKeypointIdxA(size_t index) {
162  return matches_.at(index).idxA;
163  }
169  size_t getMatchKeypointIdxB(size_t index) {
170  return matches_.at(index).idxB;
171  }
178  virtual double getWeight(size_t) const {
179  return 1.0;
180  } // TODO : figure out, if this is needed
181 
182  private:
184  opengv::bearingVectors_t bearingVectors1_;
186  opengv::bearingVectors_t bearingVectors2_;
189 
190  // also store individual uncertainties
192  std::vector<double> sigmaAngles1_;
194  std::vector<double> sigmaAngles2_;
195 
196 };
197 
198 }
199 }
200 
201 #endif /* INCLUDE_OKVIS_OPENGV_FRAMERELATIVEADAPTER_HPP_ */
virtual opengv::rotation_t getCamRotation2(size_t index) const
Retrieve the rotation from a camera of a correspondence in viewpoint 2 to the viewpoint origin...
Definition: FrameRelativeAdapter.cpp:284
The estimator class.
Definition: Estimator.hpp:77
Header file for the NCameraSystem class.
virtual opengv::bearingVector_t getBearingVector2(size_t index) const
Retrieve the bearing vector of a correspondence in viewpoint 2.
Definition: FrameRelativeAdapter.cpp:254
virtual opengv::translation_t getCamOffset1(size_t index) const
Retrieve the position of a camera of a correspondence in viewpoint 1 seen from the origin of the view...
Definition: FrameRelativeAdapter.cpp:260
opengv::bearingVectors_t bearingVectors1_
The bearing vectors of the correspondences in frame 1.
Definition: FrameRelativeAdapter.hpp:184
Adapter for relative pose RANSAC (2D2D)
Definition: FrameRelativeAdapter.hpp:60
size_t getMatchKeypointIdxB(size_t index)
Get the keypoint index in frame 2 of a correspondence.
Definition: FrameRelativeAdapter.hpp:169
A class that assembles multiple cameras into a system of (potentially different) cameras.
Definition: NCameraSystem.hpp:61
size_t getMatchKeypointIdxA(size_t index)
Get the keypoint index in frame 1 of a correspondence.
Definition: FrameRelativeAdapter.hpp:161
virtual ~FrameRelativeAdapter()
Definition: FrameRelativeAdapter.hpp:85
std::vector< double > sigmaAngles1_
The standard deviations of the bearing vectors of frame 1 in [rad].
Definition: FrameRelativeAdapter.hpp:192
#define OKVIS_DEFINE_EXCEPTION(exceptionName, exceptionParent)
Macro for defining an exception with a given parent.
Definition: assert_macros.hpp:52
This file contains some useful assert macros.
virtual size_t getNumberCorrespondences() const
Retrieve the number of correspondences.
Definition: FrameRelativeAdapter.cpp:292
virtual opengv::rotation_t getCamRotation1(size_t index) const
Retrieve the rotation from a camera of a correspondence in viewpoint 1 to the viewpoint origin...
Definition: FrameRelativeAdapter.cpp:268
double getSigmaAngle2(size_t index)
Obtain the angular standard deviation of the correspondence in frame 2 in [rad].
Definition: FrameRelativeAdapter.cpp:303
virtual opengv::translation_t getCamOffset2(size_t index) const
Retrieve the position of a camera of a correspondence in viewpoint 2 seen from the origin of the view...
Definition: FrameRelativeAdapter.cpp:276
std::vector< double > sigmaAngles2_
The standard deviations of the bearing vectors of frame 2' in [rad].
Definition: FrameRelativeAdapter.hpp:194
virtual double getWeight(size_t) const
Retrieve the weight of a correspondence. The weight is supposed to reflect the quality of a correspon...
Definition: FrameRelativeAdapter.hpp:178
Header file for the Estimator class. This does all the backend work.
opengv::bearingVectors_t bearingVectors2_
The bearing vectors of the correspondences in frame 2.
Definition: FrameRelativeAdapter.hpp:186
virtual opengv::bearingVector_t getBearingVector1(size_t index) const
Retrieve the bearing vector of a correspondence in viewpoint 1.
Definition: FrameRelativeAdapter.cpp:248
double getSigmaAngle1(size_t index)
Obtain the angular standard deviation of the correspondence in frame 1 in [rad].
Definition: FrameRelativeAdapter.cpp:297
EIGEN_MAKE_ALIGNED_OPERATOR_NEW FrameRelativeAdapter(const okvis::Estimator &estimator, const okvis::cameras::NCameraSystem &nCameraSystem, uint64_t multiFrameIdA, size_t camIdA, uint64_t multiFrameIdB, size_t camIdB)
Constructor.
Definition: FrameRelativeAdapter.cpp:52
std::vector< Match > Matches
Definition: FrameTypedefs.hpp:134
okvis::Matches matches_
The matching keypoints of both frames.
Definition: FrameRelativeAdapter.hpp:188