Skip to content

Commit

Permalink
fix for manipulator dynamics derivatives in mex (from Frank).
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.csail.mit.edu/locomotion/robotlib/trunk@6227 c9849af7-e679-4ec6-a44e-fc146a885bd3
  • Loading branch information
russt committed Jun 4, 2013
1 parent 7eb05de commit 978f06c
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions systems/plants/RigidBodyManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ void RigidBodyManipulator::HandC(double * const q, double * const qd, MatrixBase
for (k=0; k < NB; k++) {
dIC[parent[i]][k] += Xup[i].transpose()*dIC[i][k]*Xup[i];
}
dIC[parent[i]][n] += dXupdq[i].transpose()*IC[i]*Xup[i] + Xup[i].transpose()*IC[i]*dXupdq[i];
dIC[parent[i]][i] += dXupdq[i].transpose()*IC[i]*Xup[i] + Xup[i].transpose()*IC[i]*dXupdq[i];
}

if (dC) {
Expand All @@ -1074,30 +1074,33 @@ void RigidBodyManipulator::HandC(double * const q, double * const qd, MatrixBase
H(np,n) = H(n,np);
}
}

if (dH) {
for (i=0; i < NB; i++) {
n = dofnum[i];
for (k=0; k < NB; k++) {
for (k=0; k < NB; k++) {
for (i=0; i < NB; i++) {
n = dofnum[i];
fh = IC[i] * S[i];
dfh = dIC[i][k] * S[i]; //dfh/dqk
dfh = dIC[i][k] * S[i]; //dfh/dqk
(*dH)(n + n*NB,k) = S[i].transpose() * dfh;
j = i; np=n;
while (parent[j] >= 0) {
dfh = Xup[j].transpose() * dfh;
if (np==k) {
dfh += dXupdq[j].transpose() * fh;
if (j==k) {
dfh = Xup[j].transpose() * dfh + dXupdq[k].transpose() * fh;
} else {
dfh = Xup[j].transpose() * dfh;
}
fh = Xup[j].transpose() * fh;

j = parent[j];
np = dofnum[j];
(*dH)(n + np*NB,k) = S[j].transpose() * dfh;
(*dH)(np + n*NB,k) = (*dH)(n + np*NB,k);
(*dH)(n + (np)*NB,k) = S[j].transpose() * dfh;
(*dH)(np + (n)*NB,k) = (*dH)(n + np*NB,k);
}
}
}
}


}


Expand Down

0 comments on commit 978f06c

Please sign in to comment.