84 using namespace NEWMAT;
95 kine(Rot,pos,dof+fix);
106 if(j < 1 || j > dof+fix) error(
"j must be 1 <= j <= dof+fix");
110 for (
int i = 2; i <= j; i++) {
111 pos = pos + Rot*links[i].p;
112 Rot = Rot*links[i].R;
121 thomo = kine(dof+fix);
122 thomo.Release();
return thomo;
128 Matrix Rot, thomo(4,4);
133 thomo.SubMatrix(1,3,1,3) = Rot;
134 thomo.SubMatrix(1,3,4,4) = pos;
135 thomo.Release();
return thomo;
150 Matrix temp(3,5), Rot;
151 ColumnVector pos, pos_dot;
154 error(
"j must be 1 <= j <= dof");
156 kine_pd(Rot, pos, pos_dot, j);
158 temp.SubMatrix(1,3,1,3) = Rot;
159 temp.SubMatrix(1,3,4,4) = pos;
160 temp.SubMatrix(1,3,5,5) = pos_dot;
197 Matrix jacob_inv_DLS, U, V;
199 SVD(jacobian(ref), Q, U, V);
202 jacob_inv_DLS = V*Q.i()*U.t();
205 Q(6,6) += (1 - pow(Q(6,6)/eps,2))*lambda_max*lambda_max;
206 jacob_inv_DLS = V*Q.i()*U.t();
209 jacob_inv_DLS.Release();
210 return(jacob_inv_DLS);
227 error(
"j must be 1 <= j <= dof");
229 if( (pos.Nrows()!=3) || (pos.Ncols()!=1) )
230 pos = ColumnVector(3);
231 if( (pos_dot.Nrows()!=3) || (pos_dot.Ncols()!=1) )
232 pos_dot = ColumnVector(3);
236 for(
int i = 1; i <= j; i++)
238 R[i] = R[i-1]*links[i].R;
239 pos = pos + R[i-1]*links[i].p;
240 pos_dot = pos_dot + CrossProduct(R[i]*w[i], R[i-1]*links[i].p);
291 if(i < 1 || i > dof) error(
"i must be 1 <= i <= dof");
292 if(links[i].get_immobile()) {
297 }
else if(links[i].get_joint_type() == 0) {
300 Matrix R2 = links[i].R;
301 ColumnVector p2 = links[i].p;
304 for(j = 1; j < i; j++) {
305 dRot = dRot*links[j].R;
308 for(j = 1; j <= 3; j++) {
310 dR(j,2) = -dRot(j,1);
312 for(j = i+1; j <= dof; j++) {
313 p2 = p2 + R2*links[j].p;
324 for(j = i-1; j >= 1; j--) {
338 Matrix dRot, thomo(4,4);
341 dTdqi(dRot, dpos, i);
343 thomo.SubMatrix(1,3,1,3) = dRot;
344 thomo.SubMatrix(1,3,4,4) = dpos;
345 thomo.Release();
return thomo;
399 const int adof=get_available_dof(endlink);
401 Matrix pr, temp(3,1);
403 if(ref < 0 || ref > dof) error(
"invalid referential");
405 for(i = 1; i <= dof; i++) {
406 R[i] = R[i-1]*links[i].R;
407 p[i] = p[i-1]+R[i-1]*links[i].p;
410 for(i=1,j=1; j <= adof; i++) {
411 if(links[i].get_immobile())
413 if(links[i].get_joint_type() == 0) {
414 temp(1,1) = R[i-1](1,3);
415 temp(2,1) = R[i-1](2,3);
416 temp(3,1) = R[i-1](3,3);
418 temp = CrossProduct(temp,pr);
419 jac(1,j) = temp(1,1);
420 jac(2,j) = temp(2,1);
421 jac(3,j) = temp(3,1);
422 jac(4,j) = R[i-1](1,3);
423 jac(5,j) = R[i-1](2,3);
424 jac(6,j) = R[i-1](3,3);
426 jac(1,j) = R[i-1](1,3);
427 jac(2,j) = R[i-1](2,3);
428 jac(3,j) = R[i-1](3,3);
429 jac(4,j) = jac(5,j) = jac(6,j) = 0.0;
437 Matrix RT = R[ref].t();
439 Rot = ((RT & zeros) | (zeros & RT));
442 jac.Release();
return jac;
495 const int adof=get_available_dof();
496 Matrix jacdot(6,adof);
497 ColumnVector e(3), temp, pr, ppr;
499 if(ref < 0 || ref > dof)
500 error(
"invalid referential");
502 for(i = 1; i <= dof; i++)
504 R[i] = R[i-1]*links[i].R;
505 p[i] = p[i-1] + R[i-1]*links[i].p;
506 pp[i] = pp[i-1] + CrossProduct(R[i]*w[i], R[i-1]*links[i].p);
509 for(i=1,j=1; j <= adof; i++) {
510 if(links[i].get_immobile())
512 if(links[i].get_joint_type() == 0)
515 ppr = pp[dof]-pp[i-1];
519 temp = CrossProduct(R[i-1]*w[i-1], e);
520 jacdot(4,j) = temp(1);
521 jacdot(5,j) = temp(2);
522 jacdot(6,j) = temp(3);
523 temp = CrossProduct(temp,pr) + CrossProduct(e,ppr);
524 jacdot(1,j) = temp(1);
525 jacdot(2,j) = temp(2);
526 jacdot(3,j) = temp(3);
529 jacdot(1,j) = jacdot(2,j) = jacdot(3,j) =
530 jacdot(4,j) = jacdot(5,j) = jacdot(6,j) = 0.0;
537 Matrix RT = R[ref].t();
539 Rot = ((RT & zeros) | (zeros & RT));
543 jacdot.Release();
return jacdot;
559 if(j < 1 || j > dof+fix)
560 error(
"j must be 1 <= j <= dof+fix");
562 if( (pos.Nrows()!=3) || (pos.Ncols()!=1) )
563 pos = ColumnVector(3);
564 if( (pos_dot.Nrows()!=3) || (pos_dot.Ncols()!=1) )
565 pos_dot = ColumnVector(3);
569 for(
int i = 1; i <= j; i++)
571 pos = pos + R[i-1]*links[i].p;
572 pos_dot = pos_dot + R[i-1]*CrossProduct(w[i-1], links[i].p);
573 R[i] = R[i-1]*links[i].R;
616 if(i < 1 || i > dof) error(
"i must be 1 <= i <= dof");
617 if(links[i].get_immobile()) {
622 }
else if(links[i].get_joint_type() == 0) {
623 Matrix dR(3,3), R2(3,3), p2(3,1);
627 for(j = 1; j <= i; j++) {
628 dRot = dRot*links[j].R;
631 for(j = 1; j <= 3; j++) {
633 dR(j,2) = -dRot(j,1);
642 for(j = i+1; j <= dof; j++) {
643 p2 = p2 + R2*links[j].p;
654 for(j = i; j >= 1; j--) {
668 Matrix dRot, thomo(4,4);
671 dTdqi(dRot, dpos, i);
673 thomo.SubMatrix(1,3,1,3) = dRot;
674 thomo.SubMatrix(1,3,4,4) = dpos;
675 thomo.Release();
return thomo;
686 const int adof=get_available_dof(endlink);
688 ColumnVector pr(3), temp(3);
690 if(ref < 0 || ref > dof+fix)
691 error(
"invalid referential");
693 for(i = 1; i <= dof+fix; i++) {
694 R[i] = R[i-1]*links[i].R;
695 p[i] = p[i-1] + R[i-1]*links[i].p;
698 for(i=1,j=1; j <= adof; i++) {
699 if(links[i].get_immobile())
701 if(links[i].get_joint_type() == 0){
705 pr = p[dof+fix]-p[i];
706 temp = CrossProduct(temp,pr);
710 jac(4,j) = R[i](1,3);
711 jac(5,j) = R[i](2,3);
712 jac(6,j) = R[i](3,3);
714 jac(1,j) = R[i](1,3);
715 jac(2,j) = R[i](2,3);
716 jac(3,j) = R[i](3,3);
717 jac(4,j) = jac(5,j) = jac(6,j) = 0.0;
724 Matrix RT = R[ref].t();
726 Rot = ((RT & zeros) | (zeros & RT));
729 jac.Release();
return jac;
740 const int adof=get_available_dof();
741 Matrix jacdot(6,adof);
742 ColumnVector e(3), temp, pr, ppr;
744 if(ref < 0 || ref > dof+fix)
745 error(
"invalid referential");
747 for(i = 1; i <= dof+fix; i++)
749 R[i] = R[i-1]*links[i].R;
750 p[i] = p[i-1] + R[i-1]*links[i].p;
751 pp[i] = pp[i-1] + R[i-1]*CrossProduct(w[i-1], links[i].p);
754 for(i=1,j=1; j <= adof; i++) {
755 if(links[i].get_immobile())
757 if(links[i].get_joint_type() == 0)
759 pr = p[dof+fix]-p[i];
760 ppr = pp[dof+fix]-pp[i];
765 temp = CrossProduct(R[i-1]*w[i-1], e);
766 jacdot(4,j) = temp(1);
767 jacdot(5,j) = temp(2);
768 jacdot(6,j) = temp(3);
770 temp = CrossProduct(temp,pr) + CrossProduct(e,ppr);
771 jacdot(1,j) = temp(1);
772 jacdot(2,j) = temp(2);
773 jacdot(3,j) = temp(3);
776 jacdot(1,j) = jacdot(2,j) = jacdot(3,j) =
777 jacdot(4,j) = jacdot(5,j) = jacdot(6,j) = 0.0;
784 Matrix RT = R[ref].t();
786 Rot = ((RT & zeros) | (zeros & RT));
790 jacdot.Release();
return jacdot;
806 if(j < 1 || j > dof+fix)
807 error(
"j must be 1 <= j <= dof+fix");
809 if( (pos.Nrows()!=3) || (pos.Ncols()!=1) )
810 pos = ColumnVector(3);
811 if( (pos_dot.Nrows()!=3) || (pos_dot.Ncols()!=1) )
812 pos_dot = ColumnVector(3);
816 for(
int i = 1; i <= j; i++)
818 pos = pos + R[i-1]*links[i].p;
819 pos_dot = pos_dot + R[i-1]*CrossProduct(w[i-1], links[i].p);
820 R[i] = R[i-1]*links[i].R;
839 if(i < 1 || i > dof) error(
"i must be 1 <= i <= dof");
840 if(links[i].get_immobile()) {
845 }
else if(links[i].get_joint_type() == 0) {
846 Matrix dR(3,3), R2, p2(3,1);
850 for(j = 1; j <= i; j++) {
851 dRot = dRot*links[j].R;
854 for(j = 1; j <= 3; j++) {
856 dR(j,2) = -dRot(j,1);
865 for(j = i+1; j <= dof; j++) {
866 p2 = p2 + R2*links[j].p;
877 for(j = i; j >= 1; j--) {
891 Matrix dRot, thomo(4,4);
894 dTdqi(dRot, dpos, i);
896 thomo.SubMatrix(1,3,1,3) = dRot;
897 thomo.SubMatrix(1,3,4,4) = dpos;
898 thomo.Release();
return thomo;
909 const int adof=get_available_dof(endlink);
911 ColumnVector pr(3), temp(3);
913 if(ref < 0 || ref > dof+fix)
914 error(
"invalid referential");
916 for(i = 1; i <= dof+fix; i++) {
917 R[i] = R[i-1]*links[i].R;
918 p[i] = p[i-1] + R[i-1]*links[i].p;
921 for(i=1,j=1; j<=adof; i++) {
922 if(links[i].get_immobile())
924 if(links[i].get_joint_type() == 0){
929 pr = p[dof+fix]-p[i];
930 temp = CrossProduct(temp,pr);
934 jac(4,j) = R[i](1,3);
935 jac(5,j) = R[i](2,3);
936 jac(6,j) = R[i](3,3);
938 jac(1,j) = R[i](1,3);
939 jac(2,j) = R[i](2,3);
940 jac(3,j) = R[i](3,3);
941 jac(4,j) = jac(5,j) = jac(6,j) = 0.0;
948 Matrix RT = R[ref].t();
950 Rot = ((RT & zeros) | (zeros & RT));
954 jac.Release();
return jac;
965 const int adof=get_available_dof();
966 Matrix jacdot(6,adof);
967 ColumnVector e(3), temp, pr, ppr;
969 if(ref < 0 || ref > dof+fix)
970 error(
"invalid referential");
972 for(i = 1; i <= dof+fix; i++)
974 R[i] = R[i-1]*links[i].R;
975 p[i] = p[i-1] + R[i-1]*links[i].p;
976 pp[i] = pp[i-1] + R[i-1]*CrossProduct(w[i-1], links[i].p);
979 for(i=1,j=1; j <= dof; i++) {
980 if(links[i].get_immobile())
982 if(links[i].get_joint_type() == 0)
984 pr = p[dof+fix]-p[i];
985 ppr = pp[dof+fix]-pp[i];
990 temp = CrossProduct(R[i-1]*w[i-1], e);
991 jacdot(4,j) = temp(1);
992 jacdot(5,j) = temp(2);
993 jacdot(6,j) = temp(3);
995 temp = CrossProduct(temp,pr) + CrossProduct(e,ppr);
996 jacdot(1,j) = temp(1);
997 jacdot(2,j) = temp(2);
998 jacdot(3,j) = temp(3);
1001 jacdot(1,j) = jacdot(2,j) = jacdot(3,j) =
1002 jacdot(4,j) = jacdot(5,j) = jacdot(6,j) = 0.0;
1009 Matrix RT = R[ref].t();
1011 Rot = ((RT & zeros) | (zeros & RT));
1012 jacdot = Rot*jacdot;
1015 jacdot.Release();
return jacdot;
1018 #ifdef use_namespace