1 #include <gtest/gtest.h> 7 #define GTEST_COUT std::cerr << "[ INFO ] " 9 TEST(SensorMap, active)
14 TEST(SensorMap, friendClass)
40 TEST(SensorMap, correctMapGeometry)
53 TEST(SensorMap, irregularGeometry)
71 TEST(SensorMap, runBeforeinit)
77 EXPECT_EQ(-1, map.
once());
81 TEST(SensorMap, runAfterinit)
87 EXPECT_EQ(0, map.
init());
88 EXPECT_EQ(0, map.
once());
99 EXPECT_EQ(0, map.
init());
101 nav_msgs::Odometry odomMsg;
102 odomMsg.pose.pose.position.x = 100;
103 odomMsg.pose.pose.position.y = 100;
104 nav_msgs::Odometry::ConstPtr odomPtr = boost::make_shared<nav_msgs::Odometry>(odomMsg);
105 EXPECT_NO_FATAL_FAILURE(map.
odomCb(odomPtr));
107 EXPECT_TRUE(testMap.
CheckPosition(map, odomMsg.pose.pose.position.x,
108 odomMsg.pose.pose.position.y));
144 TEST(SensorMap, odomCbOutOfMapBounds)
151 EXPECT_EQ(0, map.
init());
153 nav_msgs::Odometry odomMsg;
154 odomMsg.pose.pose.position.x = 100;
155 odomMsg.pose.pose.position.y = 100;
156 nav_msgs::Odometry::ConstPtr odomPtr = boost::make_shared<nav_msgs::Odometry>(odomMsg);
157 EXPECT_NO_FATAL_FAILURE(map.
odomCb(odomPtr));
159 EXPECT_TRUE(testMap.
CheckPosition(map, odomMsg.pose.pose.position.x,
160 odomMsg.pose.pose.position.y));
171 EXPECT_EQ(0, map.
init());
173 EXPECT_EQ(0, map.
moveMap(10, 10));
181 TEST(SensorMap, moveMapOutOfMapBounds)
188 EXPECT_EQ(0, map.
init());
190 EXPECT_EQ(1, map.
moveMap(100, 100));
211 EXPECT_EQ(0, map.
init());
220 cloud.points.push_back(pcl::PointXYZ(2, -2, 0));
221 cloud.points.push_back(pcl::PointXYZ(1, -1, 0));
222 cloud.points.push_back(pcl::PointXYZ(0, 0, 0));
223 cloud.points.push_back(pcl::PointXYZ(0, 0, 0));
224 cloud.points.push_back(pcl::PointXYZ(-2, 1, 0));
225 cloud.points.push_back(pcl::PointXYZ(1, 1, 0));
226 cloud.points.push_back(pcl::PointXYZ(-1, -2, 0));
228 Eigen::MatrixXi answerMat(5,5);
240 EXPECT_TRUE(testMap.
TestMapCells(map,
"ground", answerMat));
250 EXPECT_EQ(0, map.
init());
259 cloud.points.push_back(pcl::PointXYZ(2, -2, 2));
260 cloud.points.push_back(pcl::PointXYZ(1, -1, 0));
261 cloud.points.push_back(pcl::PointXYZ(0, 0, -2));
262 cloud.points.push_back(pcl::PointXYZ(-2, 1, 1));
263 cloud.points.push_back(pcl::PointXYZ(1, 1, 5));
264 cloud.points.push_back(pcl::PointXYZ(1, 1, 2));
265 cloud.points.push_back(pcl::PointXYZ(-1, -2, 0));
268 Eigen::MatrixXf answerMat(5,5);
270 FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, 2,
271 FLT_MAX, 2, FLT_MAX, 0, FLT_MAX,
272 FLT_MAX, FLT_MAX, -2, FLT_MAX, FLT_MAX,
273 FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX, 0,
274 FLT_MAX, 1, FLT_MAX, FLT_MAX, FLT_MAX;
280 EXPECT_TRUE(testMap.
TestMapCells(map,
"elevation_min", answerMat));
284 TEST(SensorMap, nongroundPoints)
292 EXPECT_EQ(0, map.
init());
302 Eigen::MatrixXi cloudPointStorage(7, 3);
314 for (
int i = 0; i < cloudPointStorage.rows(); i++)
316 auto row = cloudPointStorage.row(i);
317 for (
int j = 0; j < row(2); j++)
319 cloud.points.push_back(pcl::PointXYZ(row(0), row(1), 0));
326 Eigen::MatrixXi history0Answers(3,3);
336 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_0", history0Answers));
340 EXPECT_EQ(0, map.
moveMap(-1, 0));
348 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_0", history0Answers));
360 Eigen::MatrixXi history1Answers(3,3);
369 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_0", history0Answers));
370 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_1", history1Answers));
376 TEST(SensorMap, nongroundManyFrames)
384 EXPECT_EQ(0, map.
init());
394 Eigen::MatrixXi cloudPointStorage(7, 3);
406 for (
int i = 0; i < cloudPointStorage.rows(); i++)
408 auto row = cloudPointStorage.row(i);
409 for (
int j = 0; j < row(2); j++)
411 cloud.points.push_back(pcl::PointXYZ(row(0), row(1), 0));
418 Eigen::MatrixXi historyAnswers(3,3);
425 for (
int i = 0; i < 5; i++)
431 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_0", historyAnswers));
432 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_1", historyAnswers));
433 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_2", historyAnswers));
434 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_3", historyAnswers));
435 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_4", historyAnswers));
438 for (
int i = 1; i < 100; i++)
446 EXPECT_TRUE(testMap.
TestMapCells(map, layerName, historyAnswers));
471 EXPECT_EQ(0, map.
init());
481 Eigen::MatrixXi cloudPointStorage(8, 3);
494 for (
int i = 0; i < cloudPointStorage.rows(); i++)
496 auto row = cloudPointStorage.row(i);
497 for (
int j = 0; j < row(2); j++)
499 cloud.points.push_back(pcl::PointXYZ(row(0), row(1), 0));
506 Eigen::MatrixXi history0Answers(5,5);
514 Eigen::MatrixXi nongroundLayerAnswers(5, 5);
515 nongroundLayerAnswers <<
519 30, 100, 100, 100, 30,
525 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_0", history0Answers));
526 EXPECT_TRUE(testMap.
TestMapCells(map,
"nonground", nongroundLayerAnswers));
545 for (
int i = 0; i < cloudPointStorage.rows(); i++)
547 auto row = cloudPointStorage.row(i);
548 for (
int j = 0; j < row(2); j++)
550 cloud2.points.push_back(pcl::PointXYZ(row(0), row(1), 0));
555 Eigen::MatrixXi history1Answers(5,5);
563 nongroundLayerAnswers <<
565 30, 100, 30, 100, 30,
566 30, 100, 30, 100, 30,
567 30, 100, 100, 100, 30,
573 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_0", history0Answers));
574 EXPECT_TRUE(testMap.
TestMapCells(map,
"history_1", history1Answers));
575 EXPECT_TRUE(testMap.
TestMapCells(map,
"nonground", nongroundLayerAnswers));
bool TestMapCells(SensorMap &, std::string, Eigen::MatrixXi)
std::string obstacleFilterNs
Filter chain for filtering sensor data into obstacles.
void odomCb(const nav_msgs::Odometry::ConstPtr)
Odometry callback function to update map position.
std::string mapFrameId
TF frame that the map should use.
grid_map::Length len
Size of the map, assumed to be square.
int updateNongroundPts(const PointCloud &)
Updates cells in the map that may have nonground (obstacle) points.
bool CheckNans(SensorMap &)
double resolution
Cell size of map.
bool CheckGeometry(SensorMap &, grid_map::Length, double resolution)
int updateGroundPts(const PointCloud &)
Records cells in the gridmap where the ground points landed.
std::string historyLayerPrefix
Prefix to use for history layers.
int numHistoryLayers
Number of layers to hold for history.
bool CheckConfigEqual(SensorMap &, MapConfiguration &)
mitre_fast_layered_map::MapConfiguration defaultConfig_
bool CheckPosition(SensorMap &, double x, double y)
bool CheckFrame(SensorMap &, std::string)
int moveMap(double, double)
Move the center of the map to follow ego.
std::string mapOperationsFilterNs
Filter chain for map operations after obstacles have been determined.
mitre_fast_layered_map::MapConfiguration smallMap_
pcl::PointCloud< pcl::PointXYZ > PointCloud