58 ColumnVector ZeroValue(3);
59 ZeroValue<<0.0<<0.0<<0.0;
86 b = InitLink.Rows(1,3);
87 ap = InitLink.Rows(4,6);
94 Lenght1 = InitLink(13);
95 Lenght2 = InitLink(14);
97 ColumnVector ZeroValue(3);
98 ZeroValue<<0.0<<0.0<<0.0;
113 aPos = Find_a(wRp,q);
115 UnitV = Find_UnitV();
189 if(Newb.Nrows() == 3)
192 cerr<<
"LinkStewart::set_b: wrong size in input vector."<< endl;
198 if(NewAp.Nrows()== 3)
201 cerr<<
"LinkStewart::set_Ap: wrong size in input vector."<< endl;
243 Lenght1 = NewLenght1;
249 Lenght2 = NewLenght2;
319 aPos = Find_a(wRp,q);
321 UnitV = Find_UnitV();
327 const Real dl,
const Real ddl)
338 da = Find_da(dq,Omega);
339 AngularKin = Find_AngularKin(dl, ddl);
340 LOmega = AngularKin.Column(1);
341 LAlpha = AngularKin.Column(2);
345 const ColumnVector Alpha,
const Real dl,
const Real ddl)
357 dda = Find_dda(ddq,Omega,Alpha);
358 AngularKin = Find_AngularKin(dl, ddl);
359 LOmega = AngularKin.Column(1);
360 LAlpha = AngularKin.Column(2);
371 ACM1 = Find_ACM1(dl,ddl);
395 a = q.Rows(1,3) + wRp*ap;
439 da = dq.Rows(1,3) + CrossProduct(Omega,aPos);
464 dda = ddq.Rows(1,3) + CrossProduct(Alpha,aPos) +
465 CrossProduct(Omega,CrossProduct(Omega,aPos));
485 return sqrt(DotProduct((aPos - b),(aPos - b)));
504 u(1) = -UnitV(1)/sqrt(UnitV(1)*UnitV(1) + UnitV(3)*UnitV(3));
506 u(3) = -UnitV(3)/sqrt(UnitV(1)*UnitV(1) + UnitV(3)*UnitV(3));
527 v = CrossProduct(Vu,UnitV)/(CrossProduct(Vu,UnitV).NormFrobenius());
547 return CrossProduct(Vu, Vv);
585 ColumnVector tmp_dda(3), omega(3), alpha(3);
588 wu = DotProduct(-(da-dl*UnitV),Vv/(DotProduct(L*UnitV,Vc)));
589 wv = DotProduct((da-dl*UnitV),Vu/(DotProduct(L*UnitV,Vc)));
591 omega = wu*Vu + wv*Vv;
593 tmp_dda = dda - wu*wv*L*CrossProduct(Vc,UnitV)-ddl*UnitV-2*dl*CrossProduct(omega,UnitV)
594 -L*CrossProduct(omega,CrossProduct(omega,UnitV));
596 au = DotProduct(-tmp_dda,Vv/(L*DotProduct(UnitV,Vc)));
597 av = DotProduct(tmp_dda,Vu/(L*DotProduct(UnitV,Vc)));
599 alpha = au*Vu + av*Vv + wu*wv*Vc;
601 Temp.Column(1) = omega; Temp.Column(2) = alpha;
603 Temp.Release();
return Temp;
640 ColumnVector Accel2(3);
641 Matrix Fn(3,1), N_N(3,1), I1(3,3), I2(3,3);
644 gravity(2) = -Gravity;
646 Accel2 = Lenght2*CrossProduct(LOmega,CrossProduct(LOmega, UnitV))
647 + Lenght2*CrossProduct(LAlpha,UnitV);
649 IdentityMatrix Identity(3);
651 I1 = I1aa*UnitV*UnitV.t() + I1nn*(Identity - UnitV*UnitV.t());
652 I2 = I2aa*UnitV*UnitV.t() + I2nn*(Identity - UnitV*UnitV.t());
654 N_N = -m1*(L-Lenght1)*CrossProduct(UnitV, gravity) - m2*Lenght2*CrossProduct(UnitV, gravity) +
655 (I1+I2)*LAlpha - (I1+I2)*CrossProduct(LOmega,LOmega)
656 + m1*(L-Lenght1)*CrossProduct(UnitV,ACM1)
657 +m2*Lenght2*CrossProduct(UnitV,Accel2);
679 M = DotProduct(N, UnitV)/DotProduct(Vc, UnitV);
701 Fn = (CrossProduct(N, UnitV) - CrossProduct(Moment(), UnitV))/L;
730 Fa = tmp(Index)*UnitV;
757 const int Index,
const Real Gravity)
763 gravity(2) = -Gravity;
765 Fa = AxialForce(J1, C, Index);
776 f = m1*DotProduct(ACM1,UnitV) - fa - m1*DotProduct(gravity, UnitV);
803 Accel1 = (L-Lenght1)*CrossProduct(LOmega, CrossProduct(LOmega, UnitV)) +
804 (L-Lenght1)*CrossProduct(LAlpha,UnitV) +
805 CrossProduct(2*LOmega,dl*UnitV)+ddl*UnitV;
820 dq = ColumnVector(6);
822 ddq = ColumnVector(6);
824 pR = ColumnVector(3);
852 ColumnVector InitLink (14);
853 Matrix Inertia (3,3);
855 pR = InitPlatt.SubMatrix(7,7,1,3).t();
858 Inertia(1,1) = InitPlatt(7,4);
859 Inertia(2,2) = InitPlatt(7,5);
860 Inertia(3,3) = InitPlatt(7,6);
865 bs = InitPlatt(7,10);
866 bm = InitPlatt(7,11);
869 Kb = InitPlatt(7,14);
872 Kt = InitPlatt(7,17);
874 UJointAtBase = Joint;
876 q = ColumnVector(6); q <<0.0 <<0.0 <<1.0 <<0.0 <<M_PI/2 <<0.0;
877 dq = ColumnVector(6); dq =0.0;
878 ddq = ColumnVector(6); ddq =0.0;
882 gravity = ColumnVector(3);
885 for (
int i =0; i<6; i++)
887 InitLink = InitPlatt.Row(i+1).t();
900 pR = ColumnVector(3);
907 ColumnVector InitLink(14);
910 ifstream inconffile(FileName.c_str(), std::ios::in);
913 cerr <<
"Stewart::Stewart: can not read input config file" << endl;
916 platData.
select(PlatFormName,
"mp", mp);
917 platData.
select(PlatFormName,
"Joint", UJointAtBase);
918 platData.
select(PlatFormName,
"pRx", pR(1));
919 platData.
select(PlatFormName,
"pRy", pR(2));
920 platData.
select(PlatFormName,
"pRz", pR(3));
921 platData.
select(PlatFormName,
"Ixx", pIp(1,1));
922 platData.
select(PlatFormName,
"Iyy", pIp(2,2));
923 platData.
select(PlatFormName,
"Izz", pIp(3,3));
924 platData.
select(PlatFormName,
"Js", Js);
925 platData.
select(PlatFormName,
"Jm", Jm);
926 platData.
select(PlatFormName,
"bs", bs);
927 platData.
select(PlatFormName,
"bm", bm);
928 platData.
select(PlatFormName,
"p", p);
929 platData.
select(PlatFormName,
"n", n);
930 platData.
select(PlatFormName,
"Kb", Kb);
931 platData.
select(PlatFormName,
"L", L);
932 platData.
select(PlatFormName,
"R", R);
933 platData.
select(PlatFormName,
"Kt", Kt);
935 q = ColumnVector(6); q <<0.0 <<0.0 <<1.0 <<0.0 <<M_PI/2 <<0.0;
936 dq = ColumnVector(6); dq =0.0;
937 ddq = ColumnVector(6); ddq =0.0;
941 for(
int j = 1; j <= 6; j++)
943 string platformName_link;
945 ostr << PlatFormName <<
"_LINK" << j;
946 platformName_link = ostr.str();
948 platData.
select(platformName_link,
"bx", InitLink(1));
949 platData.
select(platformName_link,
"by", InitLink(2));
950 platData.
select(platformName_link,
"bz", InitLink(3));
951 platData.
select(platformName_link,
"ax", InitLink(4));
952 platData.
select(platformName_link,
"ay", InitLink(5));
953 platData.
select(platformName_link,
"az", InitLink(6));
954 platData.
select(platformName_link,
"Iaa1", InitLink(7));
955 platData.
select(platformName_link,
"Inn1", InitLink(8));
956 platData.
select(platformName_link,
"Iaa2", InitLink(9));
957 platData.
select(platformName_link,
"Inn2", InitLink(10));
958 platData.
select(platformName_link,
"m1", InitLink(11));
959 platData.
select(platformName_link,
"m2", InitLink(12));
960 platData.
select(platformName_link,
"L1", InitLink(13));
961 platData.
select(platformName_link,
"L2", InitLink(14));
974 Links[i] = x.
Links[i];
1004 for (
int i=0; i<6; i++)
1005 Links[i] = x.
Links[i];
1030 UJointAtBase = Joint;
1042 cerr<<
"Stewart::set_q: wrong size in input vector."<< endl;
1052 Omega = Find_Omega();
1056 for(
int i =0; i<6; i++)
1057 Links[i].d_LTransform(dq,
Omega, dl(i+1),ddl(i+1));
1060 cerr<<
"Stewart::set_dq: wrong size in input vector."<< endl;
1066 if(_ddq.Nrows()== 6)
1070 Omega = Find_Omega();
1071 Alpha = Find_Alpha();
1073 for(
int i =0; i<6; i++)
1074 Links[i].dd_LTransform(ddq,
Omega,Alpha, dl(i+1),ddl(i+1));
1077 cerr<<
"Stewart::set_ddq: wrong size in input vector."<< endl;
1086 cerr<<
"Stewart::set_pR: wrong size in input vector."<< endl;
1092 if((_pIp.Nrows()== 3)&&(_pIp.Ncols() == 3))
1095 cerr<<
"Stewart::set_pIp: wrong size in input vector."<< endl;
1107 return UJointAtBase;
1161 for(
int i=0; i<6; i++)
1162 Links[i].LTransform(wRp, q);
1164 IJ1 = Find_InvJacob1();
1165 IJ2 = Find_InvJacob2();
1166 Jacobian = jacobian();
1187 _wRp(1,1) = cos(q(6))*cos(q(4)) - cos(q(5))*sin(q(4))*sin(q(6));
1188 _wRp(1,2) = -sin(q(6))*cos(q(4)) - cos(q(5))*sin(q(4))*cos(q(6));
1189 _wRp(1,3) = sin(q(5))*sin(q(4));
1190 _wRp(2,1) = sin(q(6))*cos(q(4)) + cos(q(5))*sin(q(4))*cos(q(6));
1191 _wRp(2,2) = -sin(q(6))*sin(q(4)) + cos(q(6))*cos(q(4))*cos(q(5));
1192 _wRp(2,3) = -sin(q(5))*cos(q(4));
1193 _wRp(3,1) = sin(q(6))*sin(q(5));
1194 _wRp(3,2) = sin(q(5))*cos(q(6));
1195 _wRp(3,3) = cos(q(5));
1224 w(1) = cos(q(4))*dq(5) + sin(q(4))*cos(q(5))*dq(6);
1225 w(2) = sin(q(4))*dq(5) - cos(q(4))*sin(q(5))*dq(6);
1226 w(3) = dq(4) + cos(q(5))*dq(6);
1260 Matrix A, Temp(3,3),Temp2(3,3);
1262 Temp = 0.0; Temp(3,1) = 1; Temp(1,2) = cos(q(4)); Temp(2,2) = sin(q(4));
1263 Temp(1,3) = sin(q(4))*cos(q(5)); Temp(2,3)=-cos(q(4))*sin(q(5)); Temp(3,3) = cos(q(5));
1265 Temp2 = 0.0; Temp2(1,2) = -dq(4)*sin(q(4)); Temp2(2,2) = dq(4)*cos(q(4));
1266 Temp2(1,3) = dq(4)*cos(q(4))*sin(q(5))+dq(5)*sin(q(4))*cos(q(5));
1267 Temp2(2,3) = dq(4)*sin(q(4))*sin(q(5))-dq(5)*cos(q(4))*cos(q(5));
1268 Temp2(3,3) = -dq(5)*sin(q(5));
1270 A = Temp*ddq.Rows(4,6) + Temp2*dq.Rows(4,6);
1291 _Jacobi = (IJ1*IJ2).i();
1315 Matrix tmp_Jacobi1 (6,6);
1317 for(
int i = 0; i<6; i++)
1318 tmp_Jacobi1.Row(i+1) = Links[i].UnitV.t() | CrossProduct(wRp*Links[i].ap,Links[i].UnitV).t();
1320 tmp_Jacobi1.Release();
1345 tmp_Jacobi2 = IdentityMatrix(6);
1346 tmp_Jacobi2(4,4) = 0;
1347 tmp_Jacobi2(6,4) = 1;
1348 tmp_Jacobi2(4,5) = cos(q(4));
1349 tmp_Jacobi2(5,5) = sin(q(4));
1350 tmp_Jacobi2(4,6) = sin(q(4))*sin(q(5));
1351 tmp_Jacobi2(5,6) = -cos(q(4))*sin(q(5));
1352 tmp_Jacobi2(6,6) = cos(q(5));
1354 tmp_Jacobi2.Release();
1388 Matrix tmp_dJ2(6,6), tmp_dn(6,3), tmp_sol(6,3), tmp_dJ1(6,6), tmp_dJ(6,6);
1389 ColumnVector VctNorm, a;
1392 tmp_dJ2(4,5) = -dq(4)*sin(q(4));
1393 tmp_dJ2(5,5) = dq(4)*cos(q(4));
1394 tmp_dJ2(4,6) = dq(4)*cos(q(4))*sin(q(5))+dq(5)*sin(q(4))*cos(q(5));
1395 tmp_dJ2(5,6) = dq(4)*sin(q(4))*sin(q(5))-dq(5)*cos(q(4))*cos(q(5));
1396 tmp_dJ2(6,6) = -dq(5)*sin(q(5));
1398 for (
int i = 0; i<6; i++)
1400 tmp_dn.Row(i+1) = ((Links[i].UnitV*Links[i].L -
1401 dl(i+1)*Links[i].UnitV)/Links[i].L).t();
1402 tmp_sol.Row(i+1) = (CrossProduct(CrossProduct(
Omega,Links[i].aPos.t()),
1403 Links[i].UnitV.t()) +
1404 (CrossProduct(Links[i].aPos,tmp_dn.Row(i+1)))).t();
1407 for (
int j = 1; j < 7; j++)
1408 for(
int k = 1; k < 4; k++)
1410 tmp_dJ1(j,k) = tmp_dn(j,k);
1411 tmp_dJ1(j,k+3) = tmp_sol(j,k);
1414 tmp_dJ = tmp_dJ1*IJ2 + IJ1*tmp_dJ2;
1428 ColumnVector Vct_L(6);
1430 for (
int i = 1; i < 7; i++)
1431 Vct_L(i) = Links[i-1].L;
1433 Vct_L.Release();
return Vct_L;
1450 ColumnVector tmp_dl;
1451 tmp_dl = Jacobian.i()*dq;
1471 ColumnVector tmp_ddl;
1472 tmp_ddl = Jacobian.i() * ddq + jacobian_dot() * dq;
1511 Matrix C(6,1), I(3,3);
1512 ColumnVector Sum(3), Sum2(3), Sum3(3), ddxg(3), LNormalForce(3);
1515 gravity(2) = -Gravity;
1517 ddxg = ddq.Rows(1,3) + CrossProduct(Alpha,wRp*pR) + CrossProduct(
Omega,CrossProduct(
Omega,wRp*pR));
1518 I = wRp*pIp*(wRp.t());
1523 for (
int i=0; i<6; i++)
1525 LNormalForce = Links[i].NormalForce();
1526 Sum = Sum + LNormalForce;
1527 Sum2 = Sum2 + CrossProduct(Links[i].aPos,LNormalForce);
1530 Sum3 = Sum3 +Links[i].Moment();
1534 C.Rows(1,3) = mp*gravity - mp*ddxg - Sum;
1535 C.Rows(4,6) = mp*CrossProduct(wRp*pR, gravity) - mp*CrossProduct(wRp*pR,ddxg)-I*Alpha
1565 const Real tolerance)
1567 ColumnVector next_q, tmp_long(6);
1571 while (Diff>tolerance)
1573 for(
int i=0; i<6; i++)
1574 tmp_long(i+1) = Links[i].L - l_given(i+1);
1576 next_q = q - Jacobian*(tmp_long);
1577 Diff = (next_q - q).MaximumAbsoluteValue();
1594 Matrix F(6,1), C, IJ1(6,6);
1596 IJ1 = Find_InvJacob1();
1597 C = Find_C(Gravity);
1599 for (
int i =0; i<6; i++)
1601 F(i+1,1) = Links[i].ActuationForce(IJ1, C, i+1, Gravity);
1626 for(
int i=0;i<6;i++)
1627 Links[i].tau_LTransform(dl(i+1), ddl(i+1), Gravity);
1629 T = Jacobian.i().t()*JointSpaceForceVct(Gravity);
1645 ColumnVector _ddq(6);
1648 return Torque(Gravity);
1663 ColumnVector _ddq(6), _dq(6), tmpdq(6);
1670 for (
int i = 1; i < 7; i++)
1675 M.Column(i) = Torque (0.0);
1702 _ddq = Find_M().i()*(T - Find_h(Gravity));
1735 Matrix G, Ka(6,6), Ma(6,6), Va(6,6), dJacobian(6,6);
1736 dJacobian = jacobian_dot();
1738 Ka = p/(2*M_PI*n)*IdentityMatrix(6);
1739 Ma = (2*M_PI/(n*p))*(Js + n*n*Jm)*IdentityMatrix(6);
1740 Va = (2*M_PI/(n*p))*(bs + n*n*bm)*IdentityMatrix(6);
1742 Mc = Ka*Jacobian.t() * Find_M() + Ma*Jacobian.i();
1744 Nc = Ka*Jacobian.t()*Find_h(0.0) + (Va*Jacobian.i()+Ma*dJacobian)*dq;
1746 ColumnVector _dq(6), _tmpdq(6);
1751 Gc = Ka *Jacobian.t()*Find_h();
1792 Matrix Nc,Gc,Mc, tmp1,tmp2;
1794 Find_Mc_Nc_Gc(Mc,Nc,Gc);
1796 tmp1 = (Command - (Jacobian.i()*dq*(2*M_PI/p)*Kb));
1797 tmp2 = (IdentityMatrix(6)*Kt/L*exp(-R*t/L))*tmp1;
1799 _ddq = Mc.i()*(tmp2 - Nc - Gc);
1805 #ifdef use_namespace