38 #include <gtest/gtest.h>
39 #include <jsoncpp/json/json.h>
53 "moveit_calibration_plugins",
"moveit_handeye_calibration::HandEyeSolverBase"));
59 ROS_ERROR_STREAM(
"Exception while creating handeye target plugin: " << ex.what());
64 std::string moveit_calibration_plugins_package_path =
ros::package::getPath(
"moveit_calibration_plugins");
65 moveit_calibration_plugins_package_path +=
"/handeye_calibration_solver/test/pose_samples.json";
66 std::ifstream ifs(moveit_calibration_plugins_package_path);
70 if (reader.parse(ifs,
root_))
86 pluginlib::UniquePtr<moveit_handeye_calibration::HandEyeSolverBase>
solver_;
87 std::unique_ptr<pluginlib::ClassLoader<moveit_handeye_calibration::HandEyeSolverBase>>
solver_plugins_loader_;
95 ASSERT_TRUE(solver_ok_);
96 ASSERT_EQ(root_.size(), 50);
101 const std::vector<std::string>& solver_names = solver_->getSolverNames();
102 ASSERT_EQ(solver_names.size(), 3);
103 ASSERT_EQ(solver_names[0],
"Daniilidis1999");
104 ASSERT_EQ(solver_names[1],
"ParkBryan1994");
105 ASSERT_EQ(solver_names[2],
"TsaiLenz1989");
110 std::vector<Eigen::Isometry3d> eef_wrt_world(root_.size(), Eigen::Isometry3d::Identity());
111 std::vector<Eigen::Isometry3d> obj_wrt_sensor(root_.size(), Eigen::Isometry3d::Identity());
113 for (
int i = 0; i < root_.size(); ++i)
115 Json::Value json_eef_wrt_world = root_[i][0];
116 ASSERT_EQ(json_eef_wrt_world.size(), 4);
117 for (
int m = 0; m < json_eef_wrt_world.size(); ++m)
119 ASSERT_EQ(json_eef_wrt_world[m].size(), 4);
120 for (
int n = 0; n < json_eef_wrt_world[m].size(); ++n)
121 eef_wrt_world[i](m, n) = json_eef_wrt_world[m][n].asDouble();
124 Json::Value json_obj_wrt_sensor = root_[i][1];
125 ASSERT_EQ(json_obj_wrt_sensor.size(), 4);
126 for (
int m = 0; m < json_obj_wrt_sensor.size(); ++m)
128 ASSERT_EQ(json_obj_wrt_sensor[m].size(), 4);
129 for (
int n = 0; n < json_obj_wrt_sensor[m].size(); ++n)
130 obj_wrt_sensor[i](m, n) = json_obj_wrt_sensor[m][n].asDouble();
134 const std::vector<std::string>& solver_names = solver_->getSolverNames();
135 for (
const std::string& name : solver_names)
139 std::string error_message;
146 Eigen::Vector3d
t(0.659, -0.249, 0.830);
147 Eigen::Vector3d
r(0.230, -2.540, 1.950);
148 Eigen::Isometry3d ret = solver_->getCameraRobotPose();
149 ASSERT_TRUE(ret.translation().isApprox(t, 0.01));
150 ASSERT_TRUE(ret.rotation().eulerAngles(0, 1, 2).isApprox(r, 0.01));
154 int main(
int argc,
char** argv)
156 testing::InitGoogleTest(&argc, argv);
157 return RUN_ALL_TESTS();