30 static const char rcsid[] =
"$Id: stewart.cpp,v 1.6 2006/05/16 19:24:26 gourdeau Exp $";
62 ZeroValue<<0.0<<0.0<<0.0;
89 b = InitLink.
Rows(1,3);
90 ap = InitLink.
Rows(4,6);
97 Lenght1 = InitLink(13);
98 Lenght2 = InitLink(14);
101 ZeroValue<<0.0<<0.0<<0.0;
116 aPos = Find_a(wRp,q);
118 UnitV = Find_UnitV();
192 if(Newb.
Nrows() == 3)
195 cerr<<
"LinkStewart::set_b: wrong size in input vector."<< endl;
201 if(NewAp.
Nrows()== 3)
204 cerr<<
"LinkStewart::set_Ap: wrong size in input vector."<< endl;
246 Lenght1 = NewLenght1;
252 Lenght2 = NewLenght2;
322 aPos = Find_a(wRp,q);
324 UnitV = Find_UnitV();
341 da = Find_da(dq,Omega);
342 AngularKin = Find_AngularKin(dl, ddl);
343 LOmega = AngularKin.
Column(1);
344 LAlpha = AngularKin.
Column(2);
360 dda = Find_dda(ddq,Omega,Alpha);
361 AngularKin = Find_AngularKin(dl, ddl);
362 LOmega = AngularKin.
Column(1);
363 LAlpha = AngularKin.
Column(2);
374 ACM1 = Find_ACM1(dl,ddl);
398 a = q.
Rows(1,3) + wRp*ap;
488 return sqrt(
DotProduct((aPos - b),(aPos - b)));
507 u(1) = -UnitV(1)/sqrt(UnitV(1)*UnitV(1) + UnitV(3)*UnitV(3));
509 u(3) = -UnitV(3)/sqrt(UnitV(1)*UnitV(1) + UnitV(3)*UnitV(3));
594 omega = wu*Vu + wv*Vv;
602 alpha = au*Vu + av*Vv + wu*wv*Vc;
644 Matrix Fn(3,1), N_N(3,1), I1(3,3), I2(3,3);
647 gravity(2) = -Gravity;
654 I1 = I1aa*UnitV*UnitV.t() + I1nn*(Identity - UnitV*UnitV.
t());
655 I2 = I2aa*UnitV*UnitV.
t() + I2nn*(Identity - UnitV*UnitV.
t());
733 Fa = tmp(Index)*UnitV;
760 const int Index,
const Real Gravity)
766 gravity(2) = -Gravity;
768 Fa = AxialForce(J1, C, Index);
861 Inertia(1,1) = InitPlatt(7,4);
862 Inertia(2,2) = InitPlatt(7,5);
863 Inertia(3,3) = InitPlatt(7,6);
868 bs = InitPlatt(7,10);
869 bm = InitPlatt(7,11);
872 Kb = InitPlatt(7,14);
875 Kt = InitPlatt(7,17);
877 UJointAtBase = Joint;
888 for (
int i =0; i<6; i++)
890 InitLink = InitPlatt.
Row(i+1).
t();
913 ifstream inconffile(FileName.c_str(), std::ios::in);
916 cerr <<
"Stewart::Stewart: can not read input config file" << endl;
919 platData.
select(PlatFormName,
"mp", mp);
920 platData.
select(PlatFormName,
"Joint", UJointAtBase);
921 platData.
select(PlatFormName,
"pRx", pR(1));
922 platData.
select(PlatFormName,
"pRy", pR(2));
923 platData.
select(PlatFormName,
"pRz", pR(3));
924 platData.
select(PlatFormName,
"Ixx", pIp(1,1));
925 platData.
select(PlatFormName,
"Iyy", pIp(2,2));
926 platData.
select(PlatFormName,
"Izz", pIp(3,3));
927 platData.
select(PlatFormName,
"Js", Js);
928 platData.
select(PlatFormName,
"Jm", Jm);
929 platData.
select(PlatFormName,
"bs", bs);
930 platData.
select(PlatFormName,
"bm", bm);
931 platData.
select(PlatFormName,
"p", p);
932 platData.
select(PlatFormName,
"n", n);
933 platData.
select(PlatFormName,
"Kb", Kb);
934 platData.
select(PlatFormName,
"L", L);
935 platData.
select(PlatFormName,
"R", R);
936 platData.
select(PlatFormName,
"Kt", Kt);
944 for(
int j = 1; j <= 6; j++)
946 string platformName_link;
948 ostr << PlatFormName <<
"_LINK" << j;
949 platformName_link = ostr.str();
951 platData.
select(platformName_link,
"bx", InitLink(1));
952 platData.
select(platformName_link,
"by", InitLink(2));
953 platData.
select(platformName_link,
"bz", InitLink(3));
954 platData.
select(platformName_link,
"ax", InitLink(4));
955 platData.
select(platformName_link,
"ay", InitLink(5));
956 platData.
select(platformName_link,
"az", InitLink(6));
957 platData.
select(platformName_link,
"Iaa1", InitLink(7));
958 platData.
select(platformName_link,
"Inn1", InitLink(8));
959 platData.
select(platformName_link,
"Iaa2", InitLink(9));
960 platData.
select(platformName_link,
"Inn2", InitLink(10));
961 platData.
select(platformName_link,
"m1", InitLink(11));
962 platData.
select(platformName_link,
"m2", InitLink(12));
963 platData.
select(platformName_link,
"L1", InitLink(13));
964 platData.
select(platformName_link,
"L2", InitLink(14));
977 Links[i] = x.
Links[i];
1007 for (
int i=0; i<6; i++)
1008 Links[i] = x.
Links[i];
1033 UJointAtBase = Joint;
1045 cerr<<
"Stewart::set_q: wrong size in input vector."<< endl;
1055 Omega = Find_Omega();
1059 for(
int i =0; i<6; i++)
1060 Links[i].d_LTransform(dq,
Omega, dl(i+1),ddl(i+1));
1063 cerr<<
"Stewart::set_dq: wrong size in input vector."<< endl;
1069 if(_ddq.
Nrows()== 6)
1073 Omega = Find_Omega();
1074 Alpha = Find_Alpha();
1076 for(
int i =0; i<6; i++)
1077 Links[i].dd_LTransform(ddq,
Omega,Alpha, dl(i+1),ddl(i+1));
1080 cerr<<
"Stewart::set_ddq: wrong size in input vector."<< endl;
1089 cerr<<
"Stewart::set_pR: wrong size in input vector."<< endl;
1098 cerr<<
"Stewart::set_pIp: wrong size in input vector."<< endl;
1110 return UJointAtBase;
1164 for(
int i=0; i<6; i++)
1165 Links[i].LTransform(wRp, q);
1167 IJ1 = Find_InvJacob1();
1168 IJ2 = Find_InvJacob2();
1169 Jacobian = jacobian();
1190 _wRp(1,1) = cos(q(6))*cos(q(4)) - cos(q(5))*sin(q(4))*sin(q(6));
1191 _wRp(1,2) = -sin(q(6))*cos(q(4)) - cos(q(5))*sin(q(4))*cos(q(6));
1192 _wRp(1,3) = sin(q(5))*sin(q(4));
1193 _wRp(2,1) = sin(q(6))*cos(q(4)) + cos(q(5))*sin(q(4))*cos(q(6));
1194 _wRp(2,2) = -sin(q(6))*sin(q(4)) + cos(q(6))*cos(q(4))*cos(q(5));
1195 _wRp(2,3) = -sin(q(5))*cos(q(4));
1196 _wRp(3,1) = sin(q(6))*sin(q(5));
1197 _wRp(3,2) = sin(q(5))*cos(q(6));
1198 _wRp(3,3) = cos(q(5));
1227 w(1) = cos(q(4))*dq(5) + sin(q(4))*cos(q(5))*dq(6);
1228 w(2) = sin(q(4))*dq(5) - cos(q(4))*sin(q(5))*dq(6);
1229 w(3) = dq(4) + cos(q(5))*dq(6);
1263 Matrix A, Temp(3,3),Temp2(3,3);
1265 Temp = 0.0; Temp(3,1) = 1; Temp(1,2) = cos(q(4)); Temp(2,2) = sin(q(4));
1266 Temp(1,3) = sin(q(4))*cos(q(5)); Temp(2,3)=-cos(q(4))*sin(q(5)); Temp(3,3) = cos(q(5));
1268 Temp2 = 0.0; Temp2(1,2) = -dq(4)*sin(q(4)); Temp2(2,2) = dq(4)*cos(q(4));
1269 Temp2(1,3) = dq(4)*cos(q(4))*sin(q(5))+dq(5)*sin(q(4))*cos(q(5));
1270 Temp2(2,3) = dq(4)*sin(q(4))*sin(q(5))-dq(5)*cos(q(4))*cos(q(5));
1271 Temp2(3,3) = -dq(5)*sin(q(5));
1273 A = Temp*ddq.
Rows(4,6) + Temp2*dq.
Rows(4,6);
1294 _Jacobi = (IJ1*IJ2).i();
1318 Matrix tmp_Jacobi1 (6,6);
1320 for(
int i = 0; i<6; i++)
1321 tmp_Jacobi1.
Row(i+1) = Links[i].UnitV.
t() |
CrossProduct(wRp*Links[i].ap,Links[i].UnitV).
t();
1349 tmp_Jacobi2(4,4) = 0;
1350 tmp_Jacobi2(6,4) = 1;
1351 tmp_Jacobi2(4,5) = cos(q(4));
1352 tmp_Jacobi2(5,5) = sin(q(4));
1353 tmp_Jacobi2(4,6) = sin(q(4))*sin(q(5));
1354 tmp_Jacobi2(5,6) = -cos(q(4))*sin(q(5));
1355 tmp_Jacobi2(6,6) = cos(q(5));
1391 Matrix tmp_dJ2(6,6), tmp_dn(6,3), tmp_sol(6,3), tmp_dJ1(6,6), tmp_dJ(6,6);
1395 tmp_dJ2(4,5) = -dq(4)*sin(q(4));
1396 tmp_dJ2(5,5) = dq(4)*cos(q(4));
1397 tmp_dJ2(4,6) = dq(4)*cos(q(4))*sin(q(5))+dq(5)*sin(q(4))*cos(q(5));
1398 tmp_dJ2(5,6) = dq(4)*sin(q(4))*sin(q(5))-dq(5)*cos(q(4))*cos(q(5));
1399 tmp_dJ2(6,6) = -dq(5)*sin(q(5));
1401 for (
int i = 0; i<6; i++)
1403 tmp_dn.Row(i+1) = ((Links[i].UnitV*Links[i].L -
1404 dl(i+1)*Links[i].UnitV)/Links[i].L).t();
1406 Links[i].UnitV.
t()) +
1410 for (
int j = 1; j < 7; j++)
1411 for(
int k = 1; k < 4; k++)
1413 tmp_dJ1(j,k) = tmp_dn(j,k);
1414 tmp_dJ1(j,k+3) = tmp_sol(j,k);
1417 tmp_dJ = tmp_dJ1*IJ2 + IJ1*tmp_dJ2;
1433 for (
int i = 1; i < 7; i++)
1434 Vct_L(i) = Links[i-1].L;
1436 Vct_L.
Release();
return Vct_L;
1454 tmp_dl = Jacobian.
i()*dq;
1475 tmp_ddl = Jacobian.
i() * ddq + jacobian_dot() * dq;
1518 gravity(2) = -Gravity;
1521 I = wRp*pIp*(wRp.t());
1526 for (
int i=0; i<6; i++)
1528 LNormalForce = Links[i].NormalForce();
1529 Sum = Sum + LNormalForce;
1530 Sum2 = Sum2 +
CrossProduct(Links[i].aPos,LNormalForce);
1533 Sum3 = Sum3 +Links[i].Moment();
1537 C.Rows(1,3) = mp*gravity - mp*ddxg -
Sum;
1568 const Real tolerance)
1574 while (Diff>tolerance)
1576 for(
int i=0; i<6; i++)
1577 tmp_long(i+1) = Links[i].L - l_given(i+1);
1579 next_q = q - Jacobian*(tmp_long);
1597 Matrix F(6,1), C, IJ1(6,6);
1599 IJ1 = Find_InvJacob1();
1600 C = Find_C(Gravity);
1602 for (
int i =0; i<6; i++)
1604 F(i+1,1) = Links[i].ActuationForce(IJ1, C, i+1, Gravity);
1629 for(
int i=0;i<6;i++)
1630 Links[i].tau_LTransform(dl(i+1), ddl(i+1), Gravity);
1632 T = Jacobian.
i().
t()*JointSpaceForceVct(Gravity);
1651 return Torque(Gravity);
1673 for (
int i = 1; i < 7; i++)
1678 M.
Column(i) = Torque (0.0);
1705 _ddq = Find_M().
i()*(T - Find_h(Gravity));
1738 Matrix G, Ka(6,6), Ma(6,6), Va(6,6), dJacobian(6,6);
1739 dJacobian = jacobian_dot();
1745 Mc = Ka*Jacobian.
t() * Find_M() + Ma*Jacobian.
i();
1747 Nc = Ka*Jacobian.
t()*Find_h(0.0) + (Va*Jacobian.i()+Ma*dJacobian)*dq;
1754 Gc = Ka *Jacobian.
t()*Find_h();
1795 Matrix Nc,Gc,Mc, tmp1,tmp2;
1797 Find_Mc_Nc_Gc(Mc,Nc,Gc);
1799 tmp1 = (Command - (Jacobian.i()*dq*(2*
M_PI/p)*Kb));
1802 _ddq = Mc.
i()*(tmp2 - Nc - Gc);
1808 #ifdef use_namespace void set_I2nn(const Real NewI2nn)
Set the value of inertia along the tangent axis of part 2.
void set_Lenght1(const Real NewLenght1)
Set the lenght between platform attachment point and center of mass of part 1.
ColumnVector b
Base coordinates of the link int the global frame.
ReturnMatrix Find_VctV()
Return the unit vector of the universal joint along the second axis of the fixed revolute joint...
ReturnMatrix get_q() const
Return the position of the platform.
ReturnMatrix get_dq() const
Return the speed of the platform.
Real bs
Viscous damping coefficient of the ballscrew.
ColumnVector ACM1
Acceleration of the first center of mass.
Real Sum(const BaseMatrix &B)
void set_I1nn(const Real NewI1nn)
Set the value of inertia along the tangent axis of part 1.
Real L
Lenght of the link.
void set_dq(const ColumnVector _dq)
Set the platform's speed.
void set_Lenght2(const Real NewLenght2)
Set the lenght between base attachment point and center of mass of part 2.
short read_conf(std::ifstream &inconffile)
Read a configuration file.
Real get_Lenght1() const
Return the lenght between platform attachment point and center of mass of part 1. ...
Real n
Gear ratio (links motor)
void set_ddq(const ColumnVector _ddq)
Set the platform's acceleration.
ReturnMatrix ForwardDyn(const ColumnVector Torque, const Real Gravity=GRAVITY)
Return the acceleration vector of the platform (ddq)
void set_mp(const Real _mp)
Set the mass of the platform.
void set_Joint(const bool _Joint)
Set the position of the universal joint on the links.
Real R
Motor armature resistance.
ReturnMatrix jacobian_dot()
Return time deriative of the inverse jacobian matrix of the platform.
ReturnMatrix Find_Alpha()
Return the angular acceleration of the platform.
void set_pIp(const Matrix _pIp)
Set the inertia matrix of the platform.
Real DotProduct(const Matrix &A, const Matrix &B)
Real p
Pitch of the ballscrew (links)
void tau_LTransform(const Real dl, const Real ddl, const Real Gravity)
Recalculate the link's parameters related to the platform dynamics.
Header file for Config class definitions.
Real bm
Viscous damping coefficient of the motor.
ReturnMatrix Find_C(const Real Gravity=GRAVITY)
Return intermediate matrix C for the dynamics calculations.
Real get_m1() const
Return the mass of part 1.
bool get_Joint() const
Return the position of the universal joint (true if at base, false if at platform) ...
void d_LTransform(const ColumnVector dq, const ColumnVector Omega, const Real dl, const Real ddl)
Recalculate the link's parameters related to the platform speed.
Real Js
Moment of inertia (ballscrew)
Real I2nn
Inertia along the tangent axis for part 2.
ReturnMatrix Moment()
Return the moment component transmitted to the link from the base or the platform (depending where is...
LinkStewart()
Default Constructor.
ReturnMatrix NormalForce()
Return the normal component of the reaction force of the platform acting on the link.
ColumnVector ap
Platform coordinates of the link in the local frame.
bool select(const std::string §ion, const std::string ¶meter, T &value) const
Get a parameter data, of a certain section, into the string value.
void set_m1(const Real Newm1)
Set the mass of part 1.
ReturnMatrix Find_ddl()
Return the extension acceleration of the links in a vector.
Handle configuration files.
void set_I1aa(const Real NewI1aa)
Set the value of inertia along the coaxial axis of part 1.
Real get_I1aa() const
Return the value of inertia along the coaxial axis of part 1.
ColumnVector dda
Acceleration of the platform attachment point.
ReturnMatrix Find_M()
Return the intermediate matrix corresponding to the inertia matrix of the machine.
ReturnMatrix Find_dda(const ColumnVector ddq, const ColumnVector Omega, const ColumnVector Alpha)
Return the acceleration of the attachment point of the link on the platform.
void set_m2(const Real Newm2)
Set the mass of part 2.
Real I2aa
Inertia along the coaxial axis for part 2.
ColumnVector N
Intermediate vector for dynamics calculations .
~LinkStewart()
Destructor.
static const char rcsid[]
RCS/CVS version.
ReturnMatrix ForwardKine(const ColumnVector guess_q, const ColumnVector l_given, const Real tolerance=0.001)
Return the position vector of the platform (vector q)
ReturnMatrix get_ddq() const
Return the acceleration of the platform.
GetSubMatrix Column(int f) const
ReturnMatrix AxialForce(const Matrix J1, const ColumnVector C, const int Index)
Return the axial component of the reaction force of the platform acting on the link.
ColumnVector gravity
Gravity vector.
ReturnMatrix Find_a(const Matrix _wRp, const ColumnVector _q)
Return the position of the attachment point on the platform.
const LinkStewart & operator=(const LinkStewart &x)
TransposedMatrix t() const
Real get_m2() const
Return the mass of part 2.
ColumnVector q
Platform position (xyz + euler angles)
void set_q(const ColumnVector _q)
Set the position of the platform.
Real MaximumAbsoluteValue(const BaseMatrix &B)
Real I1aa
Inertia along the coaxial axis for part 1.
Real NormFrobenius() const
Real get_Lenght2() const
Return the lenght between base attachment point and center of mass of part 2.
Matrix CrossProduct(const Matrix &A, const Matrix &B)
ReturnMatrix Find_InvJacob2()
Return the second intermediate jacobian matrix (reverse) of the platform.
ReturnMatrix Find_VctC()
Return the unit vector of the universal joint along the third axis of the fixed revolute joint...
The usual rectangular matrix.
ReturnMatrix Find_InvJacob1()
Return the first intermediate jacobian matrix (reverse) of the platform.
ColumnVector Vc
Unit Vector of the universal joint (Rotational).
bool UJointAtBase
Gives the position of the universal joint (true if at base, false if at platform) ...
ReturnMatrix Find_UnitV()
Return the unit vector of the link direction.
FloatVector FloatVector * a
void LTransform(const Matrix wRp, const ColumnVector q)
Recalculate the link's parameters related to the platform position.
void set_ap(const ColumnVector NewAp)
Set the position vector of platform attachment point.
ReturnMatrix Torque(const Real Gravity=GRAVITY)
Return the torque vector of the platform.
ReturnMatrix Find_dl()
Return the extension rate of the links in a vector.
Stewart()
Default Constructor.
ReturnMatrix Find_ACM1(const Real dl, const Real ddl)
Return the acceleration of the center of mass of the first part of the link.
Real I1nn
Inertia along the tangent axis for part 1.
ColumnVector aPos
Position of the platform attachment point.
GetSubMatrix Row(int f) const
GetSubMatrix SubMatrix(int fr, int lr, int fc, int lc) const
ReturnMatrix Find_wRp()
Return the rotation matrix wRp.
FloatVector FloatVector FloatVector * alpha
ReturnMatrix get_pR() const
Return the postion of the center of mass of the platfom.
Matrix pIp
Platform Inertia (local ref.)
ReturnMatrix Find_da(const ColumnVector dq, const ColumnVector Omega)
Return the speed of the attachment point of the link on the platform.
const Stewart & operator=(const Stewart &x)
Real Jm
Moment of inertia (motor)
ReturnMatrix JointSpaceForceVct(const Real Gravity=GRAVITY)
Return a vector containing the six actuation force components.
Real get_I2aa() const
Return the value of inertia along the coaxial axis of part 2.
ReturnMatrix get_ap() const
Return the position vector of platform attachement point.
void Transform()
Call the functions corresponding to the basic parameters when q changes.
ColumnVector LAlpha
Angular acceleration of the link.
ColumnVector Vu
Unit Vector of the universal joint (Rotational).
Real Find_Lenght()
Return the lenght of the link.
ReturnMatrix InvPosKine()
Return the lenght of the links in a vector.
Real get_mp() const
Return the mass of the platform.
ReturnMatrix Find_VctU()
Return the unit vector of the universal joint along the first axis of the fixed revolute joint...
Real get_I2nn() const
Return the value of inertia along the tangent axis of part 2.
ReturnMatrix Find_N(const Real Gravity=GRAVITY)
Return the intermediate matrix N for force calculation.
ReturnMatrix Find_Omega()
Return the angular speed of the platform.
void set_I2aa(const Real NewI2aa)
Set the value of inertia along the coaxial axis of part 2.
Real Lenght2
Lenght between the mass center (part 2) and the base attachment.
Stewart class definitions.
Real ActuationForce(const Matrix J1, const ColumnVector C, const int Index, const Real Gravity=GRAVITY)
Return the actuation force that power the prismatic joint.
ReturnMatrix get_pIp() const
Return the inertia matrix of the platform.
ColumnVector gravity
Gravity vector.
ColumnVector dq
Platform speed.
ReturnMatrix Find_h(const Real Gravity=GRAVITY)
Return the intermediate matrix corresponding to the Coriolis and centrifugal + gravity force/torque c...
Real Lenght1
Lenght between the mass center (part 1) and the platform attachment.
ColumnVector Vv
Unit Vector of the universal joint (Rotational).
ReturnMatrix ForwardDyn_AD(const ColumnVector Command, const Real t)
Return the acceleration of the platform (Stewart platform mechanism dynamics including actuator dynam...
ColumnVector pR
Platform center of mass (in its own referential)
void dd_LTransform(const ColumnVector ddq, const ColumnVector Omega, const ColumnVector Alpha, const Real dl, const Real ddl)
Recalculate the link's parameters related to the platform acceleration.
void set_b(const ColumnVector Newb)
Set the position vector of the base attachment point.
ColumnVector UnitV
Unit Vector of the link.
Real get_I1nn() const
Return the value of inertia along the tangent axis of part 1.
ColumnVector ddq
Platform acceleration.
GetSubMatrix Rows(int f, int l) const
ReturnMatrix Find_AngularKin(const Real dl, const Real ddl)
Return the angular speed (Column 1) and angular acceleration (Column 2) of the link.
void set_pR(const ColumnVector _pR)
Set the position of the center of mass of the platform.
ReturnMatrix Omega(const Quaternion &q, const Quaternion &q_dot)
Return angular velocity from a quaternion and it's time derivative.
ReturnMatrix get_b() const
Return the position vector of base attachement point.
ColumnVector LOmega
Angular speed of the link.
ReturnMatrix jacobian()
Return the jacobian matrix of the platform.
void Find_Mc_Nc_Gc(Matrix &Mc, Matrix &Nc, Matrix &Gc)
Return(!) the intermediates matrix for forward dynamics with actuator dynamics.
ColumnVector da
Speed of the platform attachment point .
LinkStewart Links[6]
Platform links.