SaDVIO
amap.h
Go to the documentation of this file.
1 #ifndef AMAP_H
2 #define AMAP_H
3 
4 #include <deque>
5 
6 #include "isaeslam/data/frame.h"
7 #include "isaeslam/typedefs.h"
8 
9 namespace isae {
10 
16 class AMap {
17  public:
18  AMap() = default;
19 
26  virtual void addFrame(std::shared_ptr<isae::Frame> &frame) = 0;
27 
28  std::deque<std::shared_ptr<Frame>> &getFrames() { return _frames; }
29 
33  std::shared_ptr<isae::Frame> getLastFrame() {
34  if (_frames.empty())
35  return nullptr;
36  return _frames.back();
37  }
38 
42  void getLastNFramesIn(size_t N, std::vector<std::shared_ptr<isae::Frame>> &dest) {
43  for (uint i = 0; i < std::min(N, _frames.size()); ++i) {
44  dest.push_back(_frames.at(_frames.size() - 1 - i));
45  }
46  }
47 
49  size_t getMapSize() { return _frames.size(); }
50 
54  void pushLandmarks(std::shared_ptr<isae::Frame> &frame) {
55  typed_vec_landmarks all_ldmks = frame->getLandmarks();
56 
57  // For all type of landmarks to add
58  for (auto &typed_ldmks : all_ldmks) {
59  for (auto &ldmk : typed_ldmks.second) {
60  if (!(!ldmk->isInitialized() || ldmk->isInMap() || ldmk->getFeatures().empty())) {
61  {
62  ldmk->setInMap();
63  _landmarks[ldmk->_label].push_back(ldmk);
64  }
65  }
66  }
67  }
68  }
69 
70  protected:
71  std::deque<std::shared_ptr<Frame>> _frames;
73 };
74 
75 } // namespace isae
76 
77 #endif // AMAP_H
isae::AMap::getLastFrame
std::shared_ptr< isae::Frame > getLastFrame()
Get the last frame added to the map.
Definition: amap.h:33
isae::AMap::getFrames
std::deque< std::shared_ptr< Frame > > & getFrames()
Definition: amap.h:28
isae::AMap::getLastNFramesIn
void getLastNFramesIn(size_t N, std::vector< std::shared_ptr< isae::Frame >> &dest)
Provides the last N frames added to the map.
Definition: amap.h:42
isae::AMap::_frames
std::deque< std::shared_ptr< Frame > > _frames
A deque of frames in the map, ordered by time.
Definition: amap.h:71
isae::AMap::getMapSize
size_t getMapSize()
Definition: amap.h:49
isae::AMap::getLandmarks
typed_vec_landmarks & getLandmarks()
Definition: amap.h:48
isae::AMap::_landmarks
typed_vec_landmarks _landmarks
All types of landmark in the map stored as std vectors.
Definition: amap.h:72
typedefs.h
isae::AMap::pushLandmarks
void pushLandmarks(std::shared_ptr< isae::Frame > &frame)
Add all the landmarks of a frame to the map.
Definition: amap.h:54
isae::AMap::addFrame
virtual void addFrame(std::shared_ptr< isae::Frame > &frame)=0
Add a frame to the map.
frame.h
isae
Definition: AFeature2D.h:8
isae::typed_vec_landmarks
std::unordered_map< std::string, std::vector< std::shared_ptr< isae::ALandmark > > > typed_vec_landmarks
A typed vector of landmarks to handle hetereogeneous landmark sets.
Definition: typedefs.h:30
isae::AMap::AMap
AMap()=default
isae::AMap
Abstract class for a Map.
Definition: amap.h:16