00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "Kuka361DWH.hpp"
00025 #include <math.h>
00026
00027 #define EPSILON 0.00001
00028 #define M_PI_T2 M_PI*2
00029 #define SQRT3d2 0.8660254037844386
00030 #define SQRT3t2 3.46410161513775
00031
00032 namespace OCL{
00033 namespace Kuka361DWH{
00034
00035 void convertGeometric(const std::vector<double>& q_hw,const std::vector<double>& qdot_sw,std::vector<double>& q_sw, std::vector<double>& qdot_hw)
00036 {
00037 q_sw[0]=-q_hw[0];
00038 q_sw[1]=q_hw[1];
00039 q_sw[2]=q_hw[2];
00040
00041 qdot_hw[0]=-qdot_sw[0];
00042 qdot_hw[1]=qdot_sw[1];
00043 qdot_hw[2]=qdot_sw[2];
00044
00045
00046
00047 double c5 = cos(q_hw[4]);
00048 double s5 = sin(q_hw[4]);
00049 double c5_eq = (c5+3.)/4;
00050 double alpha;
00051
00052 if (q_hw[4]<-EPSILON){
00053 alpha = atan2(-s5,SQRT3d2*(c5-1.));
00054 q_sw[4]=-2.*acos(c5_eq);
00055 qdot_hw[ 4 ]=-sqrt((1.-c5)*(7.+c5))*qdot_sw[4]/2./s5;
00056 }else{
00057 if (q_hw[4]<EPSILON){
00058 alpha = M_PI_2;
00059 q_sw[4] = 0.0;
00060 qdot_hw[4]=qdot_sw[4];
00061 }else{
00062 alpha = atan2( s5, SQRT3d2 * ( 1. - c5 ) );
00063 q_sw[4] = 2.*acos(c5_eq);
00064 qdot_hw[4] = sqrt((1.-c5)*(7.+c5))*qdot_sw[4]/2./s5;
00065 }
00066 }
00067
00068 q_sw[ 3 ] = -q_hw[ 3 ] + alpha;
00069 q_sw[ 5 ] = -q_hw[ 5 ] - alpha;
00070
00071 double alphadot = -SQRT3t2/(7.+c5)*qdot_sw[4];
00072
00073 qdot_hw[3] = -qdot_sw[3]-alphadot;
00074 qdot_hw[5] = -qdot_sw[5]+alphadot;
00075
00076 }
00077
00078 }
00079 }
00080