Skip to content

Commit

Permalink
Add Baumgarte corrector for contact 6D
Browse files Browse the repository at this point in the history
This corrects the desired contact acceleration, by accouting for drift
in position and velocity
  • Loading branch information
LudovicDeMatteis committed Sep 24, 2024
1 parent 0f702b5 commit cbaace3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions include/crocoddyl/multibody/contacts/contact-6d-loop.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ void ContactModel6DLoopTpl<Scalar>::calc(
d->f1af2 = d->f1Mf2.act(d->f2af2);
d->a0 =
(d->f1af1 - d->f1Mf2.act(d->f2af2) + d->f1vf1.cross(d->f1vf2)).toVector();

if (gains_[0] != 0.) {
d->a0 += gains_[0] * (-pinocchio::log6(d->f1Mf2).toVector());
}
if (gains_[1] != 0.) {
d->a0 += gains_[1] * (d->f1vf1 - d->f1vf2).toVector();
}
}

template <typename Scalar>
Expand Down Expand Up @@ -163,6 +170,24 @@ void ContactModel6DLoopTpl<Scalar>::calcDiff(
(joint2_placement_.toActionMatrixInverse() * d->a2_partial_dv) -
d->f1vf2.toActionMatrix() * d->f1Jf1 +
d->f1vf1.toActionMatrix() * d->f1Xf2 * d->f2Jf2;
if (gains_[0] != 0.) {
Matrix6s f1Mf2_log6;
pinocchio::Jlog6(d->f1Mf2, f1Mf2_log6);
d->da0_dx.leftCols(nv) +=
gains_[0] * (-f1Mf2_log6 * (-d->oMf2.toActionMatrixInverse() *
d->oMf1.toActionMatrix() * d->f1Jf1 +
d->f2Jf2));
}
if (gains_[1] != 0.) {
d->da0_dx.leftCols(nv) +=
gains_[1] *
(joint1_placement_.toActionMatrixInverse() * d->v1_partial_dq -
d->f1Mf2.act(d->f2vf2).toActionMatrix() *
(d->f1Jf1 - d->f1Xf2 * d->f2Jf2) -
d->f1Xf2 * joint2_placement_.toActionMatrixInverse() *
d->v2_partial_dq);
d->da0_dx.rightCols(nv) += gains_[1] * (d->f1Jf1 - d->f1Xf2 * d->f2Jf2);
}
}

template <typename Scalar>
Expand Down

0 comments on commit cbaace3

Please sign in to comment.