29 #include <Eigen/Geometry>
30 #include <console_bridge/console.h>
42 Eigen::Isometry3d test1;
43 Eigen::Isometry3d test2;
44 Eigen::VectorXd seed_angles(manip.
numJoints());
45 Eigen::VectorXd joint_angles2(manip.
numJoints());
48 const int nj =
static_cast<int>(manip.
numJoints());
50 std::vector<std::vector<double>> passed_data;
51 std::vector<std::vector<double>> failed_data;
52 int translation_failures{ 0 };
53 int angular_failures{ 0 };
54 double translation_max{ 0 };
55 double angular_max{ 0 };
57 std::vector<std::pair<std::string, std::string>> checks;
58 checks.reserve(tip_links.size() + working_frames.size());
60 for (
const auto& tip_link : tip_links)
61 checks.emplace_back(working_frames[0], tip_link);
63 for (
const auto& working_frame : working_frames)
64 checks.emplace_back(working_frame, tip_links[0]);
66 for (
const auto& check : checks)
68 seed_angles.setZero();
69 joint_angles2.setZero();
71 for (
int t = 0; t < nj; ++t)
73 joint_angles2[t] = M_PI_4;
76 test1 = poses1.at(check.first).inverse() * poses1.at(check.second);
79 for (
const auto& sol : sols)
82 test2 = poses2.at(check.first).inverse() * poses2.at(check.second);
84 double translation_distance = (test1.translation() - test2.translation()).norm();
85 double angular_distance =
86 Eigen::Quaterniond(test1.linear()).angularDistance(Eigen::Quaterniond(test2.linear()));
87 if (translation_distance > tol || angular_distance > tol)
89 if (translation_distance > tol)
90 ++translation_failures;
92 if (angular_distance > tol)
95 if (angular_distance > angular_max)
96 angular_max = angular_distance;
98 if (translation_distance > translation_max)
99 translation_max = translation_distance;
101 std::vector<double> data{ translation_distance, tol, angular_distance, tol };
102 for (Eigen::Index i = 0; i < sol.rows(); ++i)
103 data.push_back(sol(i));
105 failed_data.push_back(data);
109 std::vector<double> data{ translation_distance, tol, angular_distance, tol };
110 for (Eigen::Index i = 0; i < sol.rows(); ++i)
111 data.push_back(sol(i));
113 passed_data.push_back(data);
117 joint_angles2[t] = 0;
122 if (!failed_data.empty())
124 CONSOLE_BRIDGE_logError(
"checkKinematics failed %d out of %d\n Translation failures %d out of %d (max: "
125 "%f)\n Angular failures %d out of %d (max: %f)",
127 (failed_data.size() + passed_data.size()),
128 translation_failures,
134 std::stringstream msg;
136 msg <<
"*****************************\n";
137 msg <<
"******** Failed Data ********\n";
138 msg <<
"*****************************\n";
140 std::string header =
"Trans. Dist. (m), tol, Angle Dist. (rad), tol";
144 msg << header <<
"\n";
145 for (
const auto& d : failed_data)
147 for (
const auto& val : d)
152 msg <<
"*****************************\n";
153 msg <<
"******** Passed Data ********\n";
154 msg <<
"*****************************\n";
155 if (passed_data.empty())
162 for (
const auto& d : passed_data)
164 for (
const auto& val : d)
170 CONSOLE_BRIDGE_logError(
"%s", msg.str().c_str());