37 #include <gtest/gtest.h> 42 TEST(CostmapCoordinates, easy_coordinates_test)
48 EXPECT_DOUBLE_EQ(wx, 0.5);
49 EXPECT_DOUBLE_EQ(wy, 0.5);
51 EXPECT_DOUBLE_EQ(wx, 1.5);
52 EXPECT_DOUBLE_EQ(wy, 2.5);
54 unsigned int umx, umy;
56 ASSERT_TRUE(costmap.
worldToMap(wx, wy, umx, umy));
65 EXPECT_FALSE(costmap.
worldToMap(wx, wy, umx, umy));
74 EXPECT_TRUE(costmap.
worldToMap(0.0, wy, umx, umy));
76 EXPECT_TRUE(costmap.
worldToMap(0.25, wy, umx, umy));
78 EXPECT_TRUE(costmap.
worldToMap(0.75, wy, umx, umy));
80 EXPECT_TRUE(costmap.
worldToMap(0.9999, wy, umx, umy));
82 EXPECT_TRUE(costmap.
worldToMap(1.0, wy, umx, umy));
84 EXPECT_TRUE(costmap.
worldToMap(1.25, wy, umx, umy));
86 EXPECT_TRUE(costmap.
worldToMap(1.75, wy, umx, umy));
88 EXPECT_TRUE(costmap.
worldToMap(1.9999, wy, umx, umy));
90 EXPECT_FALSE(costmap.
worldToMap(2.0, wy, umx, umy));
95 TEST(CostmapCoordinates, hard_coordinates_test)
101 EXPECT_DOUBLE_EQ(wx, -0.15);
102 EXPECT_DOUBLE_EQ(wy, 0.25);
104 EXPECT_DOUBLE_EQ(wx, -0.05);
105 EXPECT_DOUBLE_EQ(wy, 0.45);
107 unsigned int umx, umy;
109 EXPECT_TRUE(costmap.
worldToMap(wx, wy, umx, umy));
118 EXPECT_FALSE(costmap.
worldToMap(wx, wy, umx, umy));
127 int main(
int argc,
char** argv)
129 testing::InitGoogleTest( &argc, argv );
130 return RUN_ALL_TESTS();
void worldToMapEnforceBounds(double wx, double wy, int &mx, int &my) const
Convert from world coordinates to map coordinates, constraining results to legal bounds.
TEST(CostmapCoordinates, easy_coordinates_test)
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
Convert from world coordinates to map coordinates.
void worldToMapNoBounds(double wx, double wy, int &mx, int &my) const
Convert from world coordinates to map coordinates without checking for legal bounds.
A 2D costmap provides a mapping between points in the world and their associated "costs".
int main(int argc, char **argv)
void mapToWorld(unsigned int mx, unsigned int my, double &wx, double &wy) const
Convert from map coordinates to world coordinates.