Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <gtest/gtest.h>
00035 #include <dlux_global_planner/kernel_function.h>
00036
00037 using dlux_global_planner::CardinalDirection;
00038
00039 TEST(KernelFunction, cardinal_addition)
00040 {
00041 EXPECT_EQ(CardinalDirection::NORTHWEST, CardinalDirection::NORTH + CardinalDirection::WEST);
00042 EXPECT_EQ(CardinalDirection::SOUTHWEST, CardinalDirection::SOUTH + CardinalDirection::WEST);
00043 EXPECT_EQ(CardinalDirection::NORTHEAST, CardinalDirection::NORTH + CardinalDirection::EAST);
00044 EXPECT_EQ(CardinalDirection::SOUTHEAST, CardinalDirection::SOUTH + CardinalDirection::EAST);
00045 }
00046
00047 TEST(KernelFunction, cardinal_and)
00048 {
00049 EXPECT_TRUE(CardinalDirection::NORTHWEST & CardinalDirection::NORTH);
00050 EXPECT_TRUE(CardinalDirection::NORTHWEST & CardinalDirection::NORTHWEST);
00051 EXPECT_TRUE(CardinalDirection::NORTHWEST & CardinalDirection::WEST);
00052 EXPECT_FALSE(CardinalDirection::NORTHWEST & CardinalDirection::SOUTH);
00053 EXPECT_FALSE(CardinalDirection::NORTHWEST & CardinalDirection::SOUTHEAST);
00054 EXPECT_FALSE(CardinalDirection::NORTHWEST & CardinalDirection::EAST);
00055 }
00056
00057 TEST(KernelFunction, some_kernel_values)
00058 {
00059 nav_grid::NavGridInfo info;
00060 info.width = 6;
00061 info.height = 6;
00062 dlux_global_planner::PotentialGrid p(dlux_global_planner::HIGH_POTENTIAL);
00063 p.setInfo(info);
00064 p.reset();
00065
00066 p.setValue(4, 4, 0.0f);
00067 CardinalDirection upstream;
00068 EXPECT_FLOAT_EQ(5.0f, dlux_global_planner::calculateKernel(p, 5, 4, 3, &upstream));
00069 EXPECT_EQ(CardinalDirection::NORTH, upstream);
00070
00071 EXPECT_FLOAT_EQ(5.0f, dlux_global_planner::calculateKernel(p, 5, 3, 4, &upstream));
00072 EXPECT_EQ(CardinalDirection::EAST, upstream);
00073
00074 p.setValue(4, 3, 5.0f);
00075
00076 EXPECT_FLOAT_EQ(11.0f, dlux_global_planner::calculateKernel(p, 6, 3, 3, &upstream));
00077 EXPECT_EQ(CardinalDirection::EAST, upstream);
00078
00079 p.setValue(3, 4, 5.0f);
00080
00081 EXPECT_FLOAT_EQ(9.224, dlux_global_planner::calculateKernel(p, 6, 3, 3, &upstream));
00082 EXPECT_EQ(CardinalDirection::NORTHEAST, upstream);
00083 }
00084
00085 int main(int argc, char **argv)
00086 {
00087 testing::InitGoogleTest(&argc, argv);
00088 return RUN_ALL_TESTS();
00089 }