Skip to content

Commit

Permalink
Fix malloc in updateForce
Browse files Browse the repository at this point in the history
  • Loading branch information
LudovicDeMatteis committed Oct 11, 2024
1 parent 1e408b1 commit 47f1672
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions include/crocoddyl/multibody/contacts/contact-6d-loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ struct ContactData6DLoopTpl : public ContactDataAbstractTpl<_Scalar> {
da0_dq_t3_tmp(6, model->get_state()->get_nv()),
dpos_dq(6, model->get_state()->get_nv()),
dvel_dq(6, model->get_state()->get_nv()),
dtau_dq_tmp(model->get_state()->get_nv(), model->get_state()->get_nv()),
f1Jf1(6, model->get_state()->get_nv()),
f2Jf2(6, model->get_state()->get_nv()),
f1Jf2(6, model->get_state()->get_nv()),
Expand All @@ -270,11 +271,13 @@ struct ContactData6DLoopTpl : public ContactDataAbstractTpl<_Scalar> {
da0_dq_t3_tmp.setZero();
dpos_dq.setZero();
dvel_dq.setZero();
dtau_dq_tmp.setZero();
f1Jf1.setZero();
f2Jf2.setZero();
f1Jf2.setZero();
j1Jj1.setZero();
j2Jj2.setZero();
j2Jj1.setZero();
//
j1Xf1 = SE3ActionMatrix::Identity();
j2Xf2 = SE3ActionMatrix::Identity();
Expand Down Expand Up @@ -324,6 +327,7 @@ struct ContactData6DLoopTpl : public ContactDataAbstractTpl<_Scalar> {

Matrix6xs dpos_dq;
Matrix6xs dvel_dq;
MatrixXs dtau_dq_tmp;
// Placement related data
SE3 oMf1; // Placement of the first contact frame in the world frame
SE3 oMf2; // Placement of the second contact frame in the world frame
Expand All @@ -337,6 +341,7 @@ struct ContactData6DLoopTpl : public ContactDataAbstractTpl<_Scalar> {
Matrix6xs f1Jf2;
Matrix6xs j1Jj1;
Matrix6xs j2Jj2;
Matrix6xs j2Jj1;
// Velocity related data
Motion f1vf1;
Motion f2vf2;
Expand Down
12 changes: 8 additions & 4 deletions include/crocoddyl/multibody/contacts/contact-6d-loop.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ ContactModel6DLoopTpl<Scalar>::ContactModel6DLoopTpl(
"for 6D loop contacts"
<< std::endl;
}
if (joint1_id == 0 || joint2_id == 0) {
std::cerr << "Warning: At least one of the parents joints id is zero"
"you should use crocoddyl::ContactModel6D instead"
<< std::endl;
}
}

template <typename Scalar>
Expand Down Expand Up @@ -193,10 +198,9 @@ void ContactModel6DLoopTpl<Scalar>::updateForce(

SE3 j2Mj1 =
joint2_placement_.act(d->f1Mf2.actInv(joint1_placement_.inverse()));

d->dtau_dq.noalias() =
d->j2Jj2.transpose() *
(-f_cross * (d->j2Jj2 - j2Mj1.toActionMatrix() * d->j1Jj1));
d->j2Jj1.noalias() = j2Mj1.toActionMatrix() * d->j1Jj1;
d->dtau_dq_tmp.noalias() = -f_cross * (d->j2Jj2 - d->j2Jj1);
d->dtau_dq.noalias() = d->j2Jj2.transpose() * d->dtau_dq_tmp;
}

template <typename Scalar>
Expand Down

0 comments on commit 47f1672

Please sign in to comment.