Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00050 #include "client.h"
00051 #include <geometry_msgs/Transform.h>
00052 #include "visp_hand2eye_calibration/TransformArray.h"
00053 #include <visp_bridge/3dpose.h>
00054 #include "names.h"
00055
00056 #include <visp/vpCalibration.h>
00057 #include <visp/vpExponentialMap.h>
00058
00059 namespace visp_hand2eye_calibration
00060 {
00061 Client::Client()
00062 {
00063 camera_object_publisher_
00064 = n_.advertise<geometry_msgs::Transform> (visp_hand2eye_calibration::camera_object_topic, 1000);
00065 world_effector_publisher_
00066 = n_.advertise<geometry_msgs::Transform> (visp_hand2eye_calibration::world_effector_topic, 1000);
00067
00068 reset_service_
00069 = n_.serviceClient<visp_hand2eye_calibration::reset> (visp_hand2eye_calibration::reset_service);
00070 compute_effector_camera_service_
00071 = n_.serviceClient<visp_hand2eye_calibration::compute_effector_camera> (
00072 visp_hand2eye_calibration::compute_effector_camera_service);
00073 compute_effector_camera_quick_service_
00074 = n_.serviceClient<visp_hand2eye_calibration::compute_effector_camera_quick> (
00075 visp_hand2eye_calibration::compute_effector_camera_quick_service);
00076 }
00077
00078 void Client::initAndSimulate()
00079 {
00080 ROS_INFO("Waiting for topics...");
00081 ros::Duration(1.).sleep();
00082 while(!reset_service_.call(reset_comm)){
00083 if(!ros::ok()) return;
00084 ros::Duration(1).sleep();
00085 }
00086
00087
00088
00089 const int N = 6;
00090
00091 vpHomogeneousMatrix cMo;
00092 vpHomogeneousMatrix wMe;
00093 vpHomogeneousMatrix eMc;
00094
00095
00096 vpTranslationVector etc(0.1, 0.2, 0.3);
00097 vpThetaUVector erc;
00098 erc[0] = vpMath::rad(10);
00099 erc[1] = vpMath::rad(-10);
00100 erc[2] = vpMath::rad(25);
00101
00102 eMc.buildFrom(etc, erc);
00103 ROS_INFO("1) GROUND TRUTH:");
00104
00105 ROS_INFO_STREAM("hand to eye transformation: " <<std::endl<<visp_bridge::toGeometryMsgsTransform(eMc)<<std::endl);
00106
00107 vpColVector v_c(6);
00108 for (int i = 0; i < N; i++)
00109 {
00110 v_c = 0;
00111 if (i == 0)
00112 {
00113
00114 cMo.buildFrom(0, 0, 0.5, 0, 0, 0);
00115 wMe.buildFrom(0, 0, 0, 0, 0, 0);
00116 }
00117 else if (i == 1)
00118 v_c[3] = M_PI / 8;
00119 else if (i == 2)
00120 v_c[4] = M_PI / 8;
00121 else if (i == 3)
00122 v_c[5] = M_PI / 10;
00123 else if (i == 4)
00124 v_c[0] = 0.5;
00125 else if (i == 5)
00126 v_c[1] = 0.8;
00127
00128 vpHomogeneousMatrix cMc;
00129 cMc = vpExponentialMap::direct(v_c);
00130 if (i > 0)
00131 {
00132
00133 cMo = cMc.inverse() * cMo;
00134 wMe = wMe * eMc * cMc * eMc.inverse();
00135
00136 }
00137
00138 geometry_msgs::Transform pose_c_o;
00139 pose_c_o = visp_bridge::toGeometryMsgsTransform(cMo);
00140 geometry_msgs::Transform pose_w_e;
00141 pose_w_e = visp_bridge::toGeometryMsgsTransform(wMe);
00142 camera_object_publisher_.publish(pose_c_o);
00143 world_effector_publisher_.publish(pose_w_e);
00144 emc_quick_comm.request.camera_object.transforms.push_back(pose_c_o);
00145 emc_quick_comm.request.world_effector.transforms.push_back(pose_w_e);
00146
00147 }
00148 ros::Duration(1.).sleep();
00149
00150 }
00151
00152 void Client::computeUsingQuickService()
00153 {
00154 vpHomogeneousMatrix eMc;
00155 vpThetaUVector erc;
00156 ROS_INFO("2) QUICK SERVICE:");
00157 if (compute_effector_camera_quick_service_.call(emc_quick_comm))
00158 {
00159 ROS_INFO_STREAM("hand_camera: "<< std::endl << emc_quick_comm.response.effector_camera);
00160 }
00161 else
00162 {
00163 ROS_ERROR("Failed to call service");
00164 }
00165 }
00166
00167 void Client::computeFromTopicStream()
00168 {
00169 vpHomogeneousMatrix eMc;
00170 vpThetaUVector erc;
00171 ROS_INFO("3) TOPIC STREAM:");
00172 if (compute_effector_camera_service_.call(emc_comm))
00173 {
00174 ROS_INFO_STREAM("hand_camera: " << std::endl << emc_comm.response.effector_camera);
00175 }
00176 else
00177 {
00178 ROS_ERROR("Failed to call service");
00179 }
00180
00181 }
00182 }
00183
00184
00185
00186
00187
00188