54 static const char rcsid[] =
"$Id: comp_dq.cpp,v 1.17 2004/07/06 02:16:36 gourdeau Exp $";
61 using namespace NEWMAT;
77 if(q.
Ncols() != 1 || q.
Nrows() != dof) error(
"q has wrong dimension");
78 if(qp.
Ncols() != 1 || qp.
Nrows() != dof) error(
"qp has wrong dimension");
79 if(qpp.
Ncols() != 1 || qpp.
Nrows() != dof) error(
"qpp has wrong dimension");
80 if(dq.
Ncols() != 1 || qpp.
Nrows() != dof) error(
"dq has wrong dimension");
87 z0(1) = 0.0; z0(2) = 0.0; z0(3) = 1.0;
93 for(i = 1; i <= dof; i++)
97 p[i](1) = links[i].get_a();
98 p[i](2) = links[i].get_d() * Rt(2,3);
99 p[i](3) = links[i].get_d() * Rt(3,3);
100 if(links[i].get_joint_type() != 0)
107 if(links[i].get_joint_type() == 0)
109 w[i] = Rt*(w[i-1] + z0*qp(i));
110 dw[i] = Rt*(dw[i-1] - Q*w[i-1]*dq(i));
111 wp[i] = Rt*(wp[i-1] + z0*qpp(i)
113 dwp[i] = Rt*(dwp[i-1]
123 + Rt*(dvp[i-1] - Q*vp[i-1]*dq(i));
130 dwp[i] = Rt*dwp[i-1];
131 vp[i] = Rt*(vp[i-1] + z0*qpp(i)
135 dvp[i] = Rt*(dvp[i-1]
153 for(i = dof; i >= 1; i--)
155 F[i] =
a[i] * links[i].m;
156 N[i] = links[i].I*wp[i] +
CrossProduct(w[i],links[i].I*w[i]);
157 dF[i] = da[i] * links[i].m;
158 dN[i] = links[i].I*dwp[i] +
CrossProduct(dw[i],links[i].I*w[i])
168 if(links[i].get_joint_type() != 0)
173 f[i] = links[i+1].R*f[i+1] + F[i];
174 df[i] = links[i+1].R*df[i+1] + dF[i];
175 if(links[i+1].get_joint_type() == 0)
176 df[i] += Q*links[i+1].R*f[i+1]*dq(i+1);
182 if(links[i+1].get_joint_type() == 0)
183 dn[i] += Q*links[i+1].R*n[i+1]*dq(i+1);
187 if(links[i].get_joint_type() == 0)
189 temp = ((z0.
t()*links[i].R)*n[i]);
190 ltorque(i) = temp(1,1);
191 temp = ((z0.
t()*links[i].R)*dn[i]);
192 dtorque(i) = temp(1,1);
196 temp = ((z0.
t()*links[i].R)*f[i]);
197 ltorque(i) = temp(1,1);
198 temp = ((z0.
t()*links[i].R)*df[i]);
199 dtorque(i) = temp(1,1);
217 if(q.
Ncols() != 1 || q.
Nrows() != dof) error(
"q has wrong dimension");
218 if(qp.
Ncols() != 1 || qp.
Nrows() != dof) error(
"qp has wrong dimension");
219 if(qpp.
Ncols() != 1 || qpp.
Nrows() != dof) error(
"qpp has wrong dimension");
220 if(dq.
Ncols() != 1 || dq.
Nrows() != dof) error(
"dq has wrong dimension");
227 z0(1) = 0.0; z0(2) = 0.0; z0(3) = 1.0;
232 for(i = 1; i <= dof; i++)
236 if(links[i].get_joint_type() != 0)
243 if(links[i].get_joint_type() == 0)
245 w[i] = Rt*w[i-1] + z0*qp(i);
246 dw[i] = Rt*dw[i-1] - Q*Rt*w[i-1]*dq(i);
249 dwp[i] = Rt*dwp[i-1] +
CrossProduct(Rt*dw[i-1],z0*qp(i))
250 - (Q*Rt*wp[i-1] +
CrossProduct(Q*Rt*w[i-1],z0*qp(i)))*dq(i);
265 dwp[i] = Rt*dwp[i-1];
285 for(i = dof; i >= 1; i--) {
286 F[i] =
a[i] * links[i].m;
287 N[i] = links[i].I*wp[i] +
CrossProduct(w[i],links[i].I*w[i]);
288 dF[i] = da[i] * links[i].m;
289 dN[i] = links[i].I*dwp[i] +
CrossProduct(dw[i],links[i].I*w[i])
301 f[i] = links[i+1].R*f[i+1] + F[i];
302 df[i] = links[i+1].R*df[i+1] + dF[i];
303 if(links[i+1].get_joint_type() == 0)
304 df[i] += links[i+1].R*Q*f[i+1]*dq(i+1);
306 n[i] = links[i+1].R*n[i+1] +
CrossProduct(p[i+1],links[i+1].R*f[i+1])
308 dn[i] = links[i+1].R*dn[i+1] +
CrossProduct(p[i+1],links[i+1].R*df[i+1])
310 if(links[i+1].get_joint_type() == 0)
311 dn[i] += (links[i+1].R*Q*n[i+1] +
314 dn[i] +=
CrossProduct(dp[i+1],links[i+1].R*f[i+1])*dq(i+1);
317 if(links[i].get_joint_type() == 0)
320 ltorque(i) = temp(1,1);
322 dtorque(i) = temp(1,1);
327 ltorque(i) = temp(1,1);
329 dtorque(i) = temp(1,1);
347 if(q.
Ncols() != 1 || q.
Nrows() != dof) error(
"q has wrong dimension");
348 if(qp.
Ncols() != 1 || qp.
Nrows() != dof) error(
"qp has wrong dimension");
349 if(qpp.
Ncols() != 1 || qpp.
Nrows() != dof) error(
"qpp has wrong dimension");
350 if(dq.
Ncols() != 1 || dq.
Nrows() != dof) error(
"dq has wrong dimension");
357 z0(1) = 0.0; z0(2) = 0.0; z0(3) = 1.0;
362 for(i = 1; i <= dof; i++)
366 if(links[i].get_joint_type() != 0)
373 if(links[i].get_joint_type() == 0)
375 w[i] = Rt*w[i-1] + z0*qp(i);
376 dw[i] = Rt*dw[i-1] - Q*Rt*w[i-1]*dq(i);
379 dwp[i] = Rt*dwp[i-1] +
CrossProduct(Rt*dw[i-1],z0*qp(i))
380 - (Q*Rt*wp[i-1] +
CrossProduct(Q*Rt*w[i-1],z0*qp(i)))*dq(i);
395 dwp[i] = Rt*dwp[i-1];
407 for(i = dof; i >= 1; i--) {
408 F[i] = vp[i]*links[i].m +
CrossProduct(wp[i], links[i].mc) +
410 dF[i] = dvp[i]*links[i].m +
CrossProduct(dwp[i],links[i].mc)
413 N[i] = links[i].I*wp[i] +
CrossProduct(w[i],links[i].I*w[i])
415 dN[i] = links[i].I*dwp[i] +
CrossProduct(dw[i],links[i].I*w[i])
428 f[i] = links[i+1].R*f[i+1] + F[i];
429 df[i] = links[i+1].R*df[i+1] + dF[i];
430 if(links[i+1].get_joint_type() == 0)
431 df[i] += links[i+1].R*Q*f[i+1]*dq(i+1);
433 n[i] = links[i+1].R*n[i+1] +
CrossProduct(p[i+1],links[i+1].R*f[i+1])
435 dn[i] = links[i+1].R*dn[i+1] +
CrossProduct(p[i+1],links[i+1].R*df[i+1])
437 if(links[i+1].get_joint_type() == 0)
438 dn[i] += (links[i+1].R*Q*n[i+1] +
441 dn[i] +=
CrossProduct(dp[i+1],links[i+1].R*f[i+1])*dq(i+1);
444 if(links[i].get_joint_type() == 0)
447 ltorque(i) = temp(1,1);
449 dtorque(i) = temp(1,1);
454 ltorque(i) = temp(1,1);
456 dtorque(i) = temp(1,1);
Robots class definitions.
virtual void dq_torque(const ColumnVector &q, const ColumnVector &qp, const ColumnVector &qpp, const ColumnVector &dq, ColumnVector &torque, ColumnVector &dtorque)
Delta torque due to delta joint position.
TransposedMatrix t() const
Matrix CrossProduct(const Matrix &A, const Matrix &B)
The usual rectangular matrix.
FloatVector FloatVector * a
static const char rcsid[]
RCS/CVS version.
virtual void dq_torque(const ColumnVector &q, const ColumnVector &qp, const ColumnVector &qpp, const ColumnVector &dq, ColumnVector &torque, ColumnVector &dtorque)
Delta torque due to delta joint position.
virtual void dq_torque(const ColumnVector &q, const ColumnVector &qp, const ColumnVector &qpp, const ColumnVector &dq, ColumnVector &torque, ColumnVector &dtorque)
Delta torque due to delta joint position.