8 #include <gtest/gtest.h> 12 #include "../include/cost_map_core/cost_map.hpp" 21 map.
add(
"layer", 0.0);
23 std::vector<BufferRegion> regions;
27 EXPECT_EQ(3, startIndex(0));
28 EXPECT_EQ(2, startIndex(1));
37 EXPECT_EQ(2, regions.size());
38 EXPECT_EQ(0, regions[0].getStartIndex()[0]);
39 EXPECT_EQ(0, regions[0].getStartIndex()[1]);
40 EXPECT_EQ(3, regions[0].getSize()[0]);
41 EXPECT_EQ(5, regions[0].getSize()[1]);
42 EXPECT_EQ(0, regions[1].getStartIndex()[0]);
43 EXPECT_EQ(0, regions[1].getStartIndex()[1]);
44 EXPECT_EQ(8, regions[1].getSize()[0]);
45 EXPECT_EQ(2, regions[1].getSize()[1]);
49 TEST(AddDataFrom, extendMapAligned)
66 EXPECT_TRUE(map1.
exists(
"two"));
68 EXPECT_DOUBLE_EQ(6.0, map1.
getLength().x());
69 EXPECT_DOUBLE_EQ(6.0, map1.
getLength().y());
77 TEST(AddDataFrom, extendMapNotAligned)
81 map1.
add(
"no_information");
87 map2.
add(
"no_information", 1);
92 std::vector<std::string> stringVector;
93 stringVector.push_back(
"no_information");
94 map1.
addDataFrom(map2,
true,
false,
false, stringVector);
98 EXPECT_FALSE(map1.
exists(
"two"));
100 EXPECT_DOUBLE_EQ(8.0, map1.
getLength().x());
101 EXPECT_DOUBLE_EQ(8.0, map1.
getLength().y());
104 EXPECT_FALSE(map1.
isValid(index,
"no_information"));
106 EXPECT_DOUBLE_EQ(1, static_cast<int>(map1.
atPosition(
"no_information",
Position(3.0, 3.0))));
113 map1.
add(
"zero", 0.0);
118 map2.
add(
"one", 1.0);
119 map2.
add(
"two", 2.0);
126 EXPECT_TRUE(map1.
exists(
"two"));
128 EXPECT_DOUBLE_EQ(5.0, map1.
getLength().x());
129 EXPECT_DOUBLE_EQ(5.0, map1.
getLength().y());
133 EXPECT_FALSE(map1.
isValid(index,
"one"));
137 int main(
int argc,
char **argv)
139 testing::InitGoogleTest(&argc, argv);
141 return RUN_ALL_TESTS();
const Length & getLength() const
bool isValid(const Index &index) const
void add(const std::string &layer, const DataType value=NO_INFORMATION)
bool addDataFrom(const CostMap &other, bool extendMap, bool overwriteData, bool copyAllLayers, std::vector< std::string > layers=std::vector< std::string >())
int main(int argc, char **argv)
void setGeometry(const Length &length, const double resolution, const Position &position=Position::Zero())
void setBasicLayers(const std::vector< std::string > &basicLayers)
DataType & atPosition(const std::string &layer, const Position &position)
bool getPosition(const Index &index, Position &position) const
bool move(const Position &position, std::vector< BufferRegion > &newRegions)
bool exists(const std::string &layer) const
const Index & getStartIndex() const
const std::vector< std::string > & getLayers() const
bool isInside(const Position &position) const
bool getIndex(const Position &position, Index &index) const