3#include <NDEVR/RWLock.h>
4#include "OrbSLAM/Headers/MapPoint.h"
5#include "OrbSLAM/Thirdparty/DBoW2/DBoW2/BowVector.h"
6#include "OrbSLAM/Headers/ORBVocabulary.h"
7#include "OrbSLAM/Headers/ORBextractor.h"
8#include "OrbSLAM/Headers/Frame.h"
9#include <NDEVR/IntegratedRotation.h>
10#include <NDEVR/GlobalPosition.h>
11#include "GraphOptimization/Headers/GeometricCamera.h"
12#include "Base/Headers/Buffer.hpp"
13#include "Base/Headers/Set.h"
42 void setPose(
const Sophus::SE3<g_type>& Tcw)
final override;
54 void setDoNotReduce(
bool do_not_reduce)
const { m_do_not_reduce = do_not_reduce; }
58 Sophus::SE3<g_type>
pose()
const override;
68 std::unique_lock<std::mutex> lock(m_mutex_pose);
71 Sophus::SE3<g_type> poseInverse()
const
73 std::unique_lock<std::mutex> lock(m_mutex_pose);
78 Sophus::SE3<g_type> Trw;
80 while (pKF && pKF->isBad())
82 Trw = Trw * pKF->
mTcp;
86 Trw = Trw * pKF->
mTcw;
88 Sophus::SE3<g_type> Tcw = lit * Trw;
91 std::mutex& poseMutex()
const {
return m_mutex_pose; }
94 std::unique_lock<std::mutex> lock(m_mutex_pose);
95 return mTwc.translation();
100 Sophus::SE3<g_type>
imuPose() const final override;
103 std::unique_lock<std::mutex> lock(m_mutex_pose);
104 return mTcw.rotationMatrix();
108 std::unique_lock<std::mutex> lock(m_mutex_pose);
109 return mTcw.translation();
112 bool isVelocitySet() const;
179 bool isFirstConnection()
const
181 return mbFirstConnection;
234 static bool weightComp(
const std::pair<uint04, KeyFrame*>& a,
const std::pair<uint04, KeyFrame*>& b)
236 return a.first > b.first;
302 Sophus::SE3<g_type> mTcwGBA;
303 Sophus::SE3<g_type> mTcwBefGBA;
304 Eigen::Vector3<g_type> mVwbGBA;
306 uint04 mnBAGlobalForKF = 0U;
309 Sophus::SE3<g_type> mTcwMerge;
310 Sophus::SE3<g_type> mTcwBefMerge;
311 Sophus::SE3<g_type> mTwcBefMerge;
312 Eigen::Vector3<g_type> mVwbMerge;
313 Eigen::Vector3<g_type> mVwbBefMerge;
314 IMU::Bias mBiasMerge;
315 uint04 mnBALocalForMerge = 0U;
326 bool m_has_global_position_measurement =
false;
338 bool mbFirstConnection =
false;
344 std::map<double, Sophus::SE3f> frameRelativePoses;
345 std::map<double, Sophus::SE3f> posesRelativeToKF;
347 bool mbNotErase =
false;
348 bool mbToBeErased =
false;
350 mutable bool m_do_not_reduce =
false;
351 Map* mpMap =
nullptr;
355 mutable std::mutex m_mutex_gps;
356 mutable std::mutex m_mutex_pose;
357 mutable std::mutex mMutexConnections;
358 mutable std::mutex mMutexMap;
The equivelent of std::vector but with a bit more control.
A hash-based key-value store, useful for quick associative lookups.
Represents a single image frame with extracted features and pose information.
Frame()=default
Default constructor.
uint04 id
Unique frame ID.
KeyFrame * mpReferenceKF
Reference keyframe.
Sophus::SE3< g_type > mTcw
World-to-camera transform.
Sophus::SE3< g_type > mTwc
Camera-to-world transform (inverse of mTcw).
const Eigen::Vector3< g_type > & cameraCenter() const
Returns the camera center in world coordinates.
uint04 N
Number of keypoints.
Abstract interface for geometric camera models (pinhole, fisheye, etc.).
A light-weight base class for Log that allows processes to update, without the need for additional in...
Database of keyframes for place recognition and relocalization.
A keyframe in the SLAM map, derived from Frame.
void updateBestCovisibles()
Sorts covisible keyframes by weight.
Eigen::Vector3f GetRightTranslation()
Returns the right camera translation vector.
Eigen::Vector3< g_type > GetImuPosition() const final override
Returns the IMU position in world coordinates.
uint04 keyframe_id
Unique keyframe ID.
void ChangeParent(KeyFrame *pKF)
Changes the parent of this keyframe in the spanning tree.
Buffer< const GlobalPosition * > getGlobalPositionMeas() const
Returns global position measurements associated with this keyframe.
void setLinearVelocity(const Eigen::Vector3< g_type > &Vw_) final override
Sets the IMU linear velocity (thread-safe).
Map * GetMap()
Returns the map this keyframe belongs to.
void EraseChild(KeyFrame *pKF)
Removes a child keyframe from the spanning tree.
Set< KeyFrame * > GetMergeEdges()
Returns all merge edges.
void bestCovisibilityKeyFrames(Buffer< KeyFrame * > &frames, uint04 N=Constant< uint04 >::Max) const
Returns the N best covisible keyframes by weight.
Sophus::SE3< float > GetRightPose()
Returns the right camera pose in world coordinates.
Eigen::Vector3< g_type > GetTranslation() const final override
Returns the camera translation vector (camera-to-world).
Map * map() const
Returns the map this keyframe belongs to.
Sophus::SE3< g_type > mTcp
Pose relative to parent (computed when bad flag is set).
static volatile uint04 s_next_kf_id
Global keyframe ID counter.
void SetNotErase()
Prevents this keyframe from being erased.
void SetBadFlag()
Marks this keyframe as bad and removes it from the map.
KeyFrameScore scores[4]
Scores indexed by ScoreEnum.
Eigen::Vector3< g_type > linearVelocity() const final override
Returns the linear velocity of the frame.
void setPose(const Sophus::SE3< g_type > &Tcw) final override
Sets the camera pose (thread-safe).
Set< KeyFrame * > GetChilds()
Returns the children of this keyframe in the spanning tree.
Sophus::SE3f GetRelativePoseTrl()
Returns the relative pose from right to left camera.
uint04 frame_id
Original frame ID.
Eigen::Matrix< float, 3, 3 > GetRightRotation()
Returns the right camera rotation matrix.
uint04 mnFuseTargetForKF
Fuse target keyframe ID for tracking.
bool hasChild(KeyFrame *pKF)
Checks whether a keyframe is a child of this one.
Set< KeyFrame * > GetConnectedKeyFrames()
Returns all connected keyframes in the covisibility graph.
Sophus::SE3< g_type > inversePose() const override
Returns the inverse camera pose (camera-to-world transform).
Eigen::Vector3f GetGyroBias()
Returns the gyroscope bias.
Eigen::Vector3f GetRightCameraCenter()
Returns the right camera center in world coordinates.
void processGlobalPositionMeas()
Processes global position measurements for this keyframe.
float ComputeSceneMedianDepth(const int q)
Computes the median scene depth.
void SetFirstConnection(bool bFirst)
Sets the first-connection flag.
KeyFrame * mPrevKF
Previous keyframe in temporal order.
Set< KeyFrame * > GetLoopEdges()
Returns all loop closure edges.
ScoreEnum
Enumerates the types of place-recognition scoring.
@ e_place_recognition
General place recognition score.
@ e_merge
Merge detection score.
@ e_relocation
Relocalization score.
@ e_loop
Loop detection score.
void eraseMapPoint(MapPoint *pMP)
Removes a map point observation from this keyframe.
void SetErase()
Allows this keyframe to be erased.
void AddMergeEdge(KeyFrame *pKF)
Adds a merge edge to another keyframe.
void covisiblesByWeight(uint04 w, Buffer< KeyFrame * > &frames) const
Returns keyframes with covisibility weight at least w.
uint04 weight(KeyFrame *pKF) const
Returns the covisibility weight with another keyframe.
bool doNotReduce() const
Checks whether this keyframe should not be reduced/culled.
void SetKeyFrameDatabase(KeyFrameDatabase *pKFDB)
Sets the keyframe database for this keyframe.
KeyFrame * parent() const
Returns the parent keyframe in the spanning tree.
void SetNewBias(const IMU::Bias &b)
Updates the IMU bias for this keyframe.
bool bImu
Whether this keyframe uses IMU data.
void EraseConnection(KeyFrame *pKF)
Removes a covisibility connection.
Sophus::SE3< g_type > pose() const override
Returns the camera pose (thread-safe).
void SetORBVocabulary(ORBVocabulary *pORBVoc)
Sets the ORB vocabulary for this keyframe.
Eigen::Vector3f GetAccBias()
Returns the accelerometer bias.
KeyFrame(Frame &F, Map *pMap, KeyFrameDatabase *pKFDB)
Constructs a KeyFrame from a Frame.
void addConnection(KeyFrame *pKF, uint04 weight)
Adds a covisibility connection to another keyframe.
void updateConnections()
Updates all covisibility connections based on shared map points.
KeyFrame * mNextKF
Next keyframe in temporal order.
Eigen::Matrix3< g_type > GetRotation() const final override
Returns the camera rotation matrix (camera-to-world).
bool IsInImage(const float &x, const float &y) const
Checks whether a point is within the image bounds.
void AddLoopEdge(KeyFrame *pKF)
Adds a loop closure edge to another keyframe.
void addGlobalPositionMeas(const GlobalPosition *meas)
Adds a global position measurement to this keyframe.
void UpdateMap(Map *pMap)
Updates the map association for this keyframe.
Sophus::SE3< float > GetRightPoseInverse()
Returns the inverse of the right camera pose.
Sophus::SE3< g_type > imuPose() const final override
Returns the IMU pose as an SE3 transform.
Sophus::SE3f GetRelativePoseTlr()
Returns the relative pose from left to right camera.
uint04 mnBAFixedForKF
Fixed BA keyframe ID marker.
IMU::Bias GetImuBias()
Returns the full IMU bias (gyroscope + accelerometer).
void setDoNotReduce(bool do_not_reduce) const
Sets whether this keyframe should not be reduced/culled.
uint04 mnBALocalForKF
Local BA keyframe ID marker.
void AddChild(KeyFrame *pKF)
Adds a child keyframe in the spanning tree.
Eigen::Matrix3< g_type > GetImuRotation() const final override
Returns the IMU rotation matrix.
A 3D point in the SLAM map observed by multiple keyframes.
Represents a single SLAM map containing keyframes and map points.
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
TemplatedVocabulary< FORB::TDescriptor, FORB > ORBVocabulary
ORB visual vocabulary type for Bag-of-Words place recognition.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Stores place-recognition query scores for a keyframe.
fltp04 score
Similarity score.
uint04 query_id
Query keyframe ID.
uint04 word_count
Shared word count.