src/test_map.cpp
Go to the documentation of this file.
1 
7 #include "sensor_map.hpp"
8 
10 {
12  {}
13 
15  {}
16 
18  {
19  std::cout << "Inside of check map equal" << std::endl;
20  }
21 
23  {
24  MapConfiguration mapConfig = _map.config_;
25  return mapConfig == _config;
26  }
27 
28  bool TestMap::CheckGeometry(SensorMap& _map, grid_map::Length _len, double _resolution)
29  {
30  grid_map::Length mapLen = _map.gridMap_.getLength();
31 
32  return (mapLen(0) == _len(0)) &&
33  (mapLen(1) == _len(1)) &&
34  (_map.gridMap_.getResolution() == _resolution);
35  }
36 
37  bool TestMap::CheckFrame(SensorMap& _map, std::string _frameId)
38  {
39  return _map.gridMap_.getFrameId() == _frameId;
40  }
41 
42  bool TestMap::CheckPosition(SensorMap& _map, double _x, double _y)
43  {
45  return (pos(0) == _x) && (pos(1) == _y);
46  }
47 
49  {
50  grid_map::GridMap gridMap = _map.gridMap_;
51  for(grid_map::GridMapIterator it(gridMap); !it.isPastEnd(); ++it)
52  {
53  // Check ground, nonground, and permanent layers for nan
54  const grid_map::Index index(*it);
55 
56  if (std::isnan(gridMap.at("ground", index)) || std::isnan(gridMap.at("nonground", index)) ||
57  std::isnan(gridMap.at("permanent", index)))
58  {
59  return false; // Found a nan
60  }
61  }
62 
63  return true;
64  }
65 
66  bool TestMap::TestMapCells(SensorMap& _map, std::string _layer, Eigen::MatrixXi _answerMat)
67  {
68 
69  for (grid_map::GridMapIterator it(_map.gridMap_); !it.isPastEnd(); ++it)
70  {
71  const grid_map::Index index(*it);
72 
73  if (_map.gridMap_.at(_layer, index) != _answerMat(index(0), index(1)))
74  {
75  // std::cerr << "Index " << index(0) << "," << index(1) << std::endl;
76  std::cerr << "Map: " << _map.gridMap_[_layer] << std::endl;
77  std::cerr << "Answer Mat: " << _answerMat << std::endl;
78  return false;
79  }
80  }
81 
82  return true;
83  }
84 
85  bool TestMap::TestMapCells(SensorMap& _map, std::string _layer, Eigen::MatrixXf _answerMat)
86  {
87 
88  for (grid_map::GridMapIterator it(_map.gridMap_); !it.isPastEnd(); ++it)
89  {
90  const grid_map::Index index(*it);
91 
92  if (_map.gridMap_.at(_layer, index) != _answerMat(index(0), index(1)))
93  {
94  // std::cerr << "Index " << index(0) << "," << index(1) << std::endl;
95  // std::cerr << "Map: " << _map.gridMap_[_layer] << std::endl;
96  // std::cerr << "Answer Mat: " << _answerMat << std::endl;
97  return false;
98  }
99  }
100 
101  return true;
102  }
103 }
const Length & getLength() const
bool TestMapCells(SensorMap &, std::string, Eigen::MatrixXi)
Eigen::Array2i Index
bool getPosition(const Index &index, Position &position) const
const std::string & getFrameId() const
grid_map::GridMap gridMap_
Mapping data storage container.
Definition: sensor_map.hpp:164
double getResolution() const
Eigen::Vector2d Position
bool CheckGeometry(SensorMap &, grid_map::Length, double resolution)
float & at(const std::string &layer, const Index &index)
bool CheckMapsEqual(SensorMap &, grid_map::GridMap &)
bool CheckConfigEqual(SensorMap &, MapConfiguration &)
bool CheckPosition(SensorMap &, double x, double y)
bool CheckFrame(SensorMap &, std::string)
Eigen::Array2d Length


mitre_fast_layered_map
Author(s):
autogenerated on Thu Mar 11 2021 03:06:49