Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on #9 , I found that
getLinearAcceleration
did not return the correct value. Investigating that further, I found that the integration fix in #5 did not apply when constraint impulses are involved. Furthermore, I found problems with the integration of position inFreeJoint::integratePosition
when the COM of a body is not at the origin. This PR fixes both issues and adds a test for the COM offset issue. I wasn't able to create a simple test for the first issue, but I will update #9 to usegetLinearAcceleration
in the test.The linear acceleration issue is fixed by a Coriolis term from the acceleration before integrating it to obtain a new velocity. My intuition for this is that the
FreeJoint::integratePosition
updates the spatial velocity based on the newly integrated position. This update to spatial velocity is in itself an acceleration and it does what the Coriolis term would have done had weFreeJoint::integratePosition
not updated the spatial velocity.The COM offset issue is fixed by transforming all quantities into the COM frame before integration. After integration, the values are transformed back into the body's origin frame.
I have tested this PR with Gazebo-classic and it fixes the test
AddForce
test inINTEGRATION_physics_link
. I was even able to remove the tolerance adjustment in https://github.com/osrf/gazebo/blob/a9f093f2fc7fa7fc49efa73719f6536ad28f8af7/test/integration/physics_link.cc#L164