Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
MapClasses.hpp
Go to the documentation of this file.
1 #ifndef MAP_CLASSES_HPP
2 #define MAP_CLASSES_HPP
3 
4 #include <galaxis/linatypes.hpp>
5 
6 #include <vector>
7 #include <map>
8 #include <mutex>
9 
10 namespace galaxis { namespace map {
11  namespace data {
12 
13  template <typename T>
14  class LinePoints {
15  private:
16  // Both Maps contain same information but in different representations therefore must be consistent
17  std::map<T, std::vector<T>> m_pointsXY;
18  std::map<T, std::vector<T>> m_pointsYX;
19 
20  std::mutex m_mtx;
21 
22  public:
24 
25  void clear() {
26  m_mtx.lock();
27 
28  m_pointsXY.clear();
29  m_pointsYX.clear();
30 
31  m_mtx.unlock();
32  }
33 
34  void insert(T x, T y) {
35  m_mtx.lock();
36 
37  auto itX = m_pointsXY.find(x);
38  if(itX == m_pointsXY.end()) {
39  // insert new vector
40  m_pointsXY.insert(std::pair<T, std::vector<T>>(x, std::vector<T>{ y }));
41  } else {
42  itX->second.push_back(y);
43  }
44 
45  auto itY = m_pointsYX.find(y);
46  if(itY == m_pointsYX.end()) {
47  // insert new vector
48  m_pointsYX.insert(std::pair<T, std::vector<T>>(y, std::vector<T>{ x }));
49  }
50  else {
51  itY->second.push_back(x);
52  }
53 
54  m_mtx.unlock();
55  }
56 
57  std::map<T, std::vector<T>>& getPointsXY() {
58  return m_pointsXY;
59  }
60  std::map<T, std::vector<T>>& getPointsYX() {
61  return m_pointsYX;
62  }
63  };
64 
65  template <typename T>
66  class LinesObject {
67  public:
71 
72  Eigen::Rotation2Df rotationMatrix;
73  Eigen::Rotation2Df reverseRotationMatrix;
74 
76 
77  void clear() {
78  leftLine.clear();
79  centerLine.clear();
80  rightLine.clear();
81  }
82  };
83 
84  } // namespace classes
85 } // namespace map
86 } // namespace galaxis
87 #endif
galaxis::map::data::LinePoints::LinePoints
LinePoints()
Definition: MapClasses.hpp:23
galaxis::map::data::LinesObject::clear
void clear()
Definition: MapClasses.hpp:77
galaxis::map::data::LinePoints::insert
void insert(T x, T y)
Definition: MapClasses.hpp:34
galaxis::map::data::LinesObject::reverseRotationMatrix
Eigen::Rotation2Df reverseRotationMatrix
Definition: MapClasses.hpp:73
galaxis::map::data::LinesObject::leftLine
LinePoints< T > leftLine
Definition: MapClasses.hpp:68
galaxis::map::data::LinesObject::rotationMatrix
Eigen::Rotation2Df rotationMatrix
Definition: MapClasses.hpp:72
galaxis::map::data::LinePoints::getPointsXY
std::map< T, std::vector< T > > & getPointsXY()
Definition: MapClasses.hpp:57
galaxis::map::data::LinePoints::getPointsYX
std::map< T, std::vector< T > > & getPointsYX()
Definition: MapClasses.hpp:60
galaxis::map::data::LinePoints::m_mtx
std::mutex m_mtx
Definition: MapClasses.hpp:20
galaxis::map::data::LinePoints
Definition: MapClasses.hpp:14
galaxis::map::data::LinePoints::m_pointsXY
std::map< T, std::vector< T > > m_pointsXY
Definition: MapClasses.hpp:17
galaxis::map::data::LinePoints::clear
void clear()
Definition: MapClasses.hpp:25
galaxis
Definition: MapClasses.hpp:10
galaxis::map::data::LinesObject::centerLine
LinePoints< T > centerLine
Definition: MapClasses.hpp:69
galaxis::map::data::LinesObject::rightLine
LinePoints< T > rightLine
Definition: MapClasses.hpp:70
linatypes.hpp
map
Definition: MapClasses.hpp:15
galaxis::map::data::LinePoints::m_pointsYX
std::map< T, std::vector< T > > m_pointsYX
Definition: MapClasses.hpp:18
galaxis::map::data::LinesObject::LinesObject
LinesObject()
Definition: MapClasses.hpp:75
galaxis::map::data::LinesObject
Definition: MapClasses.hpp:66