32 #include <gtest/gtest.h> 42 const float angular_resolution = M_PI * 2 / angle;
43 const float linear_resolution = 0.5;
48 linear_resolution, angular_resolution, range,
52 const int xy_yaw_straight[][3] =
59 for (
auto& xy_yaw : xy_yaw_straight)
61 for (
int i = 1; i <= range + 1; ++i)
64 i * xy_yaw[0], i * xy_yaw[1], xy_yaw[2]);
65 const auto c = cache.
find(xy_yaw[2], goal);
68 ASSERT_EQ(c, cache.
end(xy_yaw[2]));
71 ASSERT_NE(c, cache.
end(xy_yaw[2]));
72 for (
const auto& p : c->second.getMotion())
76 ASSERT_EQ(xy_yaw[0], 0);
78 ASSERT_GE(p[0] * xy_yaw[0], 0);
80 ASSERT_EQ(xy_yaw[1], 0);
82 ASSERT_GE(p[1] * xy_yaw[1], 0);
84 ASSERT_EQ(c->second.getDistance(), i);
85 ASSERT_EQ(static_cast<int>(c->second.getMotion().size()), i);
90 const int xy_syaw_gyaw_90[][4] =
101 for (
auto& xy_syaw_gyaw : xy_syaw_gyaw_90)
103 for (
int i = 1; i <= range + 1; ++i)
106 i * xy_syaw_gyaw[0], i * xy_syaw_gyaw[1], xy_syaw_gyaw[3]);
107 const auto c = cache.
find(xy_syaw_gyaw[2], goal);
108 if (i *
sqrt(2) >= range)
110 ASSERT_EQ(c, cache.
end(xy_syaw_gyaw[2]));
113 ASSERT_NE(c, cache.
end(xy_syaw_gyaw[2]));
115 for (
const auto& p : c->second.getMotion())
118 ASSERT_GE(p[0] * xy_syaw_gyaw[0], 0);
119 ASSERT_GE(p[1] * xy_syaw_gyaw[1], 0);
122 const float arc_length = i * 2 * M_PI / 4;
123 EXPECT_NEAR(c->second.getDistance(), arc_length, 0.1);
128 int main(
int argc,
char** argv)
130 testing::InitGoogleTest(&argc, argv);
132 return RUN_ALL_TESTS();
const Cache::const_iterator end(const int start_yaw) const
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
const Cache::const_iterator find(const int start_yaw, const CyclicVecInt< 3, 2 > &goal) const
TEST(MotionCache, Generate)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
std::function< void(CyclicVecInt< 3, 2 >, size_t &, size_t &)> getAddressor() const
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)