37 #include <gtest/gtest.h> 47 const float angular_resolution = M_PI * 2 / angle;
48 const float linear_resolution = 0.5;
53 linear_resolution, angular_resolution, range,
57 const int xy_yaw_straight[][3] =
64 for (
auto& xy_yaw : xy_yaw_straight)
66 for (
int i = 1; i <= range + 1; ++i)
69 i * xy_yaw[0], i * xy_yaw[1], xy_yaw[2]);
70 const auto c = cache.
find(xy_yaw[2], goal);
73 ASSERT_EQ(c, cache.
end(xy_yaw[2]));
76 ASSERT_NE(c, cache.
end(xy_yaw[2]));
77 for (
const auto& p : c->second.getMotion())
81 ASSERT_EQ(xy_yaw[0], 0);
83 ASSERT_GE(p[0] * xy_yaw[0], 0);
85 ASSERT_EQ(xy_yaw[1], 0);
87 ASSERT_GE(p[1] * xy_yaw[1], 0);
89 ASSERT_EQ(c->second.getDistance(), i);
90 ASSERT_EQ(static_cast<int>(c->second.getMotion().size()), i);
95 const int xy_syaw_gyaw_90[][4] =
106 for (
auto& xy_syaw_gyaw : xy_syaw_gyaw_90)
108 for (
int i = 1; i <= range + 1; ++i)
111 i * xy_syaw_gyaw[0], i * xy_syaw_gyaw[1], xy_syaw_gyaw[3]);
112 const auto c = cache.
find(xy_syaw_gyaw[2], goal);
113 if (i * std::sqrt(2.0) >= range)
115 ASSERT_EQ(c, cache.
end(xy_syaw_gyaw[2]));
118 ASSERT_NE(c, cache.
end(xy_syaw_gyaw[2]));
120 for (
const auto& p : c->second.getMotion())
123 ASSERT_GE(p[0] * xy_syaw_gyaw[0], 0);
124 ASSERT_GE(p[1] * xy_syaw_gyaw[1], 0);
127 const float arc_length = i * 2 * M_PI / 4;
128 EXPECT_NEAR(c->second.getDistance(), arc_length, 0.1);
135 int main(
int argc,
char** argv)
137 testing::InitGoogleTest(&argc, argv);
139 return RUN_ALL_TESTS();
std::function< void(CyclicVecInt< DIM, NONCYCLIC >, size_t &, size_t &)> getAddressor() const
const Cache::const_iterator end(const int start_yaw) const
TEST(CostmapBBF, ForEach)
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
void reset(const float linear_resolution, const float angular_resolution, const int range, const std::function< void(CyclicVecInt< 3, 2 >, size_t &, size_t &)> gm_addr)
int main(int argc, char **argv)
const Cache::const_iterator find(const int start_yaw, const CyclicVecInt< 3, 2 > &goal) const