test_filter_threshold.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include "filters.hpp"
3 #include <filters/filter_chain.h>
4 #include <math.h>
5 #include <Eigen/Dense>
6 
7 #define GTEST_COUT std::cerr << "[ INFO ] "
8 
9 TEST(ThresholdFilter, active)
10 {
11  EXPECT_EQ(0, 0);
12 }
13 
18 TEST(ThresholdFilter, layers_dont_exist)
19 {
20  ros::NodeHandle nh("~");
21 
22  grid_map::GridMap gridMap({"random_layer"});
23  gridMap.setFrameId("random");
24  gridMap.setGeometry(grid_map::Length(3, 3), 1);
25 
26  filters::FilterChain<grid_map::GridMap> filterChain("grid_map::GridMap");
27 
28  if (!filterChain.configure("mitre_fast_layered_map_filters_threshold", nh))
29  {
30  GTEST_FATAL_FAILURE_("Unable to configure filter chain."); // We should never get here
31  }
32 
33  EXPECT_FALSE(filterChain.update(gridMap, gridMap));
34 
35  // Bayes filter needs current_probability and obstacle_detected layers
36  gridMap.add("current_probability", 0);
37  EXPECT_FALSE(filterChain.update(gridMap, gridMap));
38 
39  gridMap.add("nonground", 0);
40  EXPECT_TRUE(filterChain.update(gridMap, gridMap));
41 
42 }
43 
44 // /***
45 // * All of the tests below this point are just checking that the math
46 // * comes out as expected. You can use this to refer to the expected performance
47 // * given the settings.
48 // */
49 
50 // /**
51 // * Ensure its outputting expected values when a reading is given as 1 or 0
52 // */
53 TEST(BayesUpdate, binary)
54 {
55  ros::NodeHandle nh("~");
56 
57  // NOTE: Current probability will be filled with nans, but the filter should take care of it
58  grid_map::GridMap gridMap({"current_probability", "nonground"});
59  gridMap.setFrameId("random");
60  gridMap.setGeometry(grid_map::Length(3, 3), 1);
61 
62  filters::FilterChain<grid_map::GridMap> filterChain("grid_map::GridMap");
63 
64  if (!filterChain.configure("mitre_fast_layered_map_filters_threshold", nh))
65  {
66  GTEST_FATAL_FAILURE_("Unable to configure filter chain."); // We should never get here
67  }
68 
69  // Initialize obstacle detected, only two cells have detection in first frame
70  gridMap["current_probability"] <<
71  0, 0.1, 0.2,
72  0.3, 0.4, 0.5,
73  0.6, 0.7, 0.8;
74 
75 
76  // Create matrix of expected output to compare to
77  Eigen::MatrixXf answerMat(3, 3);
78  answerMat << 0, 0, 0,
79  0, 100, 100,
80  100, 100, 100;
81 
82  if (!filterChain.update(gridMap, gridMap))
83  {
84  GTEST_FATAL_FAILURE_("Unable to update grid map.");
85  }
86 
87  for (grid_map::GridMapIterator it(gridMap); !it.isPastEnd(); ++it)
88  {
89  const grid_map::Index index(*it);
90 
91  EXPECT_FLOAT_EQ(answerMat(index(0), index(1)), gridMap.at("nonground", index)) << "Index: " << index(0) << " " << index(1);
92  }
93 
94 }
Eigen::Array2i Index
bool update(const T &data_in, T &data_out)
bool configure(std::string param_name, ros::NodeHandle node=ros::NodeHandle())
Filters that operate on a grid map instance.
TEST(ThresholdFilter, active)
void setFrameId(const std::string &frameId)
Eigen::Array2d Length


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