Skip to content

Commit

Permalink
Merge pull request #731 from dartsim/grey/fix_mass
Browse files Browse the repository at this point in the history
Update total mass when removing bodies
  • Loading branch information
jslee02 committed Jun 1, 2016
2 parents f53cb4d + 22444c0 commit d6e2d3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dart/dynamics/Skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,8 @@ void Skeleton::unregisterBodyNode(BodyNode* _oldBodyNode)
mSoftBodyNodes.end(), soft),
mSoftBodyNodes.end());
}

updateTotalMass();
}

//==============================================================================
Expand Down
10 changes: 10 additions & 0 deletions unittests/testSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,16 @@ TEST(Skeleton, Updating)
screw->setPitch(3);
J0f = screw->getRelativeJacobian();
EXPECT_FALSE(equals(J0i, J0f));

// Regression test for Pull Request #731
const double originalMass = skeleton->getMass();
BodyNode* lastBn = skeleton->getBodyNode(skeleton->getNumBodyNodes()-1);
const double removedMass = lastBn->getMass();
EXPECT_FALSE(removedMass == 0.0);
lastBn->remove();
const double newMass = skeleton->getMass();
EXPECT_FALSE(originalMass == newMass);
EXPECT_TRUE(newMass == originalMass - removedMass);
}

int main(int argc, char* argv[])
Expand Down

0 comments on commit d6e2d3d

Please sign in to comment.