36 #include <gtest/gtest.h> 56 std::vector<Vec> results;
57 for (
const auto& original_primitives : original_primitives_vector)
59 for (
const auto& original_primitive : original_primitives)
65 primitive = original_primitive;
68 primitive =
Vec(original_primitive[1], -original_primitive[0], original_primitive[2]);
72 primitive =
Vec(-original_primitive[0], -original_primitive[1], original_primitive[2]);
76 primitive =
Vec(-original_primitive[1], original_primitive[0], original_primitive[2]);
82 results.push_back(primitive);
83 const Vec opposite =
Vec(-primitive[0], -primitive[1], primitive[2]);
84 results.push_back(opposite);
88 for (
int i = 1; i < 16; ++i)
90 results.push_back(
Vec(0, 0, i));
92 std::sort(results.begin(), results.end(), &
compareVecs);
99 const std::vector<Vec> expected_0deg_straight_primitives =
106 const std::vector<Vec> expected_0deg_rotation_1_primitives =
113 const std::vector<Vec> expected_0deg_rotation_2_primitives =
120 const std::vector<Vec> expected_0deg_rotation_3_primitives =
127 const std::vector<std::vector<Vec>> expected_0deg_primitives =
129 expected_0deg_straight_primitives,
130 expected_0deg_rotation_1_primitives,
131 expected_0deg_rotation_2_primitives,
132 expected_0deg_rotation_3_primitives,
135 const std::vector<Vec> expected_23deg_straight_primitives =
141 const std::vector<Vec> expected_23deg_rotation_1_primitives =
148 const std::vector<Vec> expected_23deg_rotation_2_primitives =
156 const std::vector<Vec> expected_23deg_rotation_3_primitives =
164 const std::vector<std::vector<Vec>> expected_23deg_primitives =
166 expected_23deg_straight_primitives,
167 expected_23deg_rotation_1_primitives,
168 expected_23deg_rotation_2_primitives,
169 expected_23deg_rotation_3_primitives,
172 const std::vector<Vec> expected_45deg_straight_primitives =
179 const std::vector<Vec> expected_45deg_rotation_1_primitives =
186 const std::vector<Vec> expected_45deg_rotation_2_primitives =
195 const std::vector<Vec> expected_45deg_rotation_3_primitives =
204 const std::vector<std::vector<Vec>> expected_45deg_primitives =
206 expected_45deg_straight_primitives,
207 expected_45deg_rotation_1_primitives,
208 expected_45deg_rotation_2_primitives,
209 expected_45deg_rotation_3_primitives,
212 const std::vector<Vec> expected_67deg_straight_primitives =
218 const std::vector<Vec> expected_67deg_rotation_1_primitives =
225 const std::vector<Vec> expected_67deg_rotation_2_primitives =
233 const std::vector<Vec> expected_67deg_rotation_3_primitives =
241 const std::vector<std::vector<Vec>> expected_67deg_primitives =
243 expected_67deg_straight_primitives,
244 expected_67deg_rotation_1_primitives,
245 expected_67deg_rotation_2_primitives,
246 expected_67deg_rotation_3_primitives,
249 const std::vector<std::vector<std::vector<Vec>>> expected_original_primitives =
251 expected_0deg_primitives,
252 expected_23deg_primitives,
253 expected_45deg_primitives,
254 expected_67deg_primitives,
258 costmap_cspace_msgs::MapMetaData3D map_info;
259 map_info.linear_resolution = 0.1f;
260 map_info.angular_resolution =
static_cast<float>(M_PI / 8);
268 const std::vector<std::vector<MotionPrimitiveBuilder::Vec>> motion_primitives =
271 EXPECT_EQ(map_info.angle, static_cast<unsigned int>(motion_primitives.size()));
272 for (
size_t i = 0; i < motion_primitives.size(); ++i)
274 std::vector<Vec> current_primitives = motion_primitives[i];
275 std::sort(current_primitives.begin(), current_primitives.end(), &
compareVecs);
277 ASSERT_EQ(expected_primitives.size(), current_primitives.size());
278 for (
size_t j = 0; j < current_primitives.size(); ++j)
280 const Vec& expected_prim = expected_primitives[j];
281 const Vec& actual_prim = current_primitives[j];
283 EXPECT_EQ(expected_prim, actual_prim)
284 <<
"Error at " << i <<
"," << j <<
"\n" 285 <<
" Expected: (" << expected_prim[0] <<
"," << expected_prim[1] <<
"," << expected_prim[2] <<
")\n" 286 <<
" Actual: (" << actual_prim[0] <<
"," << actual_prim[1] <<
"," << actual_prim[2] <<
")\n";
294 int main(
int argc,
char** argv)
296 testing::InitGoogleTest(&argc, argv);
298 return RUN_ALL_TESTS();
TEST(CostmapBBF, ForEach)
void cycleUnsigned(const int res, const ArgList &...rest)
bool compareVecs(const Vec &v1, const Vec &v2)
int main(int argc, char **argv)
MotionPrimitiveBuilder::Vec Vec
float angle_resolution_aspect_
std::vector< Vec > buildExpectedPrimitives(const std::vector< std::vector< Vec >> original_primitives_vector, const int quadrant)
static std::vector< std::vector< Vec > > build(const costmap_cspace_msgs::MapMetaData3D &map_info, const CostCoeff &cc, const int range)