34 #include <gtest/gtest.h> 35 #include <map_server/image_loader.h> 41 std::vector<std::string>
filenames = {
"spectrum.png",
"spectrum.pgm"};
43 bool compareToClassic(
const std::string& filename,
bool should_negate,
double occ_th,
double free_th, MapMode mode)
45 const double resolution = 0.1;
46 double origin[3] = {0.0, 0.0, 0.0};
47 nav_msgs::GetMap::Response map_resp;
51 map_server::loadMapFromFile(&map_resp, path.c_str(), resolution, should_negate, occ_th, free_th, origin, mode);
58 else if (mode == TRINARY)
70 if (the_map.
size() != map_resp.map.data.size())
74 unsigned int correct = 0;
75 for (
unsigned int i=0; i < the_map.
size(); i++)
77 unsigned char original = map_resp.map.data[i];
78 unsigned char updated = the_map[i];
79 if (original == updated)
82 if (correct != the_map.
size())
84 printf(
"%.2f correct\n", correct * 100.0 / the_map.
size());
85 for (
unsigned int i=0; i < the_map.
size(); i++)
87 unsigned char original = map_resp.map.data[i];
88 unsigned char updated = the_map[i];
89 if (original == updated)
91 printf(
"%d) %d %d %c\n", i, updated, original, updated == original ?
' ' :
'x');
95 return correct == the_map.
size();
98 TEST(MapServerComparison, raw)
107 TEST(MapServerComparison, trinary)
118 TEST(MapServerComparison, scale)
129 int main(
int argc,
char** argv)
131 testing::InitGoogleTest(&argc, argv);
132 return RUN_ALL_TESTS();
nav_grid::VectorNavGrid< unsigned char > classicLoadMapFromFile(const std::string &filepath, const double resolution, const bool negate_param, const double occ_th, const double free_th, const std::string &mode)
Load an image from a file, mimicking map_server's loading style Resulting values are [0...
bool compareToClassic(const std::string &filename, bool should_negate, double occ_th, double free_th, MapMode mode)
TEST(MapServerComparison, raw)
std::vector< std::string > filenames
ROSLIB_DECL std::string getPath(const std::string &package_name)
int main(int argc, char **argv)
unsigned int size() const