4 OPW_IGNORE_WARNINGS_PUSH
7 #include <gtest/gtest.h>
10 OPW_IGNORE_WARNINGS_POP
24 static constexpr
const char*
const NAME =
"float";
31 static constexpr
const char*
const NAME =
"double";
41 T translation_distance = (Ta.translation() - Tb.translation()).norm();
42 T angular_distance = Eigen::Quaternion<T>(Ta.linear()).angularDistance(Eigen::Quaternion<T>(Tb.linear()));
44 EXPECT_NEAR(
static_cast<double>(translation_distance), 0, tolerance);
45 EXPECT_NEAR(
static_cast<double>(angular_distance), 0, tolerance);
51 static std::default_random_engine en{ 42 };
52 static std::uniform_real_distribution<T> rg{ T(-M_PI), T(M_PI) };
67 const static unsigned int number_of_tests = 1000;
70 std::array<T, 6> q_rand;
73 for (
unsigned j = 0; j < number_of_tests; ++j)
83 for (
const auto& s : sols)
100 const static unsigned int number_of_tests = 10000;
102 std::vector<Transform<T>, Eigen::aligned_allocator<Transform<T>>> poses;
103 poses.resize(number_of_tests);
107 std::vector<std::array<T, 6>> random_joint_values;
108 random_joint_values.resize(number_of_tests);
110 for (std::size_t i = 0; i < number_of_tests; ++i)
116 const auto fk_start_tm = std::chrono::steady_clock::now();
117 for (std::size_t i = 0; i < number_of_tests; ++i)
121 const auto fk_end_tm = std::chrono::steady_clock::now();
124 const auto fk_dt_us = std::chrono::duration_cast<std::chrono::microseconds>(fk_end_tm - fk_start_tm).count();
125 std::cout <<
"Forward Kinematics " <<
TestTolerance<T>::NAME <<
" generated " << number_of_tests <<
" poses in "
126 << fk_dt_us <<
" us\n";
127 std::cout <<
"Average us per fk solve: " <<
static_cast<double>(fk_dt_us) / number_of_tests <<
"\n";
131 const auto ik_start_tm = std::chrono::steady_clock::now();
132 for (std::size_t i = 0; i < number_of_tests; ++i)
136 const auto ik_end_tm = std::chrono::steady_clock::now();
138 const auto ik_dt_us = std::chrono::duration_cast<std::chrono::microseconds>(ik_end_tm - ik_start_tm).count();
139 std::cout <<
"Inverse Kinematics " <<
TestTolerance<T>::NAME <<
" generated " << number_of_tests <<
" poses in "
140 << ik_dt_us <<
" us\n";
141 std::cout <<
"Average us per ik solve: " <<
static_cast<double>(ik_dt_us) / number_of_tests <<
"\n";
144 TEST(kuka_kr6, random_reachable_poses_double)
146 const auto kukaKR6_R700_sixx = opw_kinematics::makeKukaKR6_R700_sixx<double>();
150 TEST(kuka_kr6, random_reachable_poses_float)
152 const auto kukaKR6_R700_sixx = opw_kinematics::makeKukaKR6_R700_sixx<float>();
156 TEST(kuka_kr6, throughput_tests_float)
158 const auto params = opw_kinematics::makeKukaKR6_R700_sixx<float>();
162 TEST(kuka_kr6, throughput_tests_double)
164 const auto params = opw_kinematics::makeKukaKR6_R700_sixx<double>();
168 TEST(abb_2400, throughput_tests_float)
170 const auto params = opw_kinematics::makeIrb2400_10<float>();
174 TEST(abb_2400, random_reachable_poses_double)
176 const auto params = opw_kinematics::makeIrb2400_10<double>();
180 TEST(abb_2400, random_reachable_poses_float)
182 const auto params = opw_kinematics::makeIrb2400_10<float>();
186 TEST(abb_2400, throughput_tests_double)
188 const auto params = opw_kinematics::makeIrb2400_10<double>();
192 TEST(abb_2600, throughput_tests_float)
194 const auto params = opw_kinematics::makeIrb2600_12_165<float>();
198 TEST(abb_2600, random_reachable_poses_double)
200 const auto params = opw_kinematics::makeIrb2600_12_165<double>();
204 TEST(abb_2600, random_reachable_poses_float)
206 const auto params = opw_kinematics::makeIrb2600_12_165<float>();
210 TEST(abb_2600, throughput_tests_double)
212 const auto params = opw_kinematics::makeIrb2600_12_165<double>();
216 TEST(abb_2600, numerical_issue_double)
218 const auto params = opw_kinematics::makeIrb2600_12_165<double>();
219 std::array<double, 6> jv{ 0, M_PI_4, 0, 0, 0, 0 };
223 pose2(0, 0) = -0.707106781186547;
225 pose2(2, 0) = -0.707106781186548;
226 pose2(0, 1) = 4.9065389333868E-018;
228 pose2(2, 1) = -4.9065389333868E-018;
229 pose2(0, 2) = 0.707106781186548;
231 pose2(2, 2) = -0.707106781186547;
232 pose2(0, 3) = 1.3485459941112;
234 pose2(2, 3) = 0.399038059222874;
239 for (
const auto& s : sols)
246 TEST(abb_2600, numerical_issue2_double)
248 const auto params = opw_kinematics::makeIrb2600_12_165<double>();
249 std::array<double, 6> jv{ M_PI_4, 0, 0, 0, 0, 0 };
253 pose2(0, 0) = 1.5700924586837752e-16;
254 pose2(1, 0) = 1.570092458683775e-16;
256 pose2(0, 1) = -0.7071067811865475;
257 pose2(1, 1) = 0.7071067811865476;
259 pose2(0, 2) = 0.7071067811865476;
260 pose2(1, 2) = 0.7071067811865475;
261 pose2(2, 2) = 2.220446049250313e-16;
262 pose2(0, 3) = 0.7283199846221441;
263 pose2(1, 3) = 0.728319984622144;
269 for (
const auto& s : sols)
276 TEST(abb_4600, numerical_issue_double)
278 const auto params = opw_kinematics::makeIrb4600_60_205<double>();
281 pose2(0, 0) = 3.46244636694609e-12;
282 pose2(1, 0) = 3.46244625852587e-12;
284 pose2(0, 1) = -0.707106781186547;
285 pose2(1, 1) = 0.707106781186547;
287 pose2(0, 2) = 0.707106781186547;
288 pose2(1, 2) = 0.707106781186547;
289 pose2(2, 2) = 4.89663875852947e-12;
290 pose2(0, 3) = 0.898025612106916;
291 pose2(1, 3) = 0.898025612106915;
295 for (
const auto& s : sols)
302 OPW_IGNORE_WARNINGS_PUSH
303 TEST(fanuc_r2000, random_reachable_poses_double)
305 const auto params = opw_kinematics::makeFanucR2000iB_200R<double>();
309 TEST(fanuc_r2000, random_reachable_poses_float)
311 const auto params = opw_kinematics::makeFanucR2000iB_200R<float>();
315 TEST(fanuc_r2000, throughput_tests_float)
317 const auto params = opw_kinematics::makeFanucR2000iB_200R<float>();
321 TEST(fanuc_r2000, throughput_tests_double)
323 const auto params = opw_kinematics::makeFanucR2000iB_200R<double>();
326 OPW_IGNORE_WARNINGS_POP
328 int main(
int argc,
char** argv)
330 testing::InitGoogleTest(&argc, argv);
331 return RUN_ALL_TESTS();