-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix velocity and position integration for FreeJoint #1437
Fix velocity and position integration for FreeJoint #1437
Conversation
The main fix is in the expression used to integrate velocities. The secondary fix is to update spatial accelerations after integrating velocities and to update both spatial velocities and accelerations after integrating positions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct fix for the numerical inaccuracy of FreeJoint is to change the dynamics equation to use the global frame. Currently, DART uses local frame (or body attached frame) that leads to that the linear acceleration depends on the angular velocity, which doesn't exist in the global frame version.
This PR is resolving the issue by reverting the velocity and acceleration that are computed by the forward dynamics (represented in body frame). It may fix the issue but not the root cause.
Let me rework on the dynamics equations switching the reference frame to global frame, but this could take some time. In the meantime, I might be okay to accept this PR as long as it doesn't break the current behavior but resolving the issue.
Sorry for taking too long in response.
Sounds good to me. |
Yes, I think doing the dynamics in the global frame would probably be a better fix.
Is it reverting? My understanding was that it was updating the velocity and acceleration to be in the updated (after integration) body frame. |
Sorry, "overwriting" would be a better word. I intended to say that the function additionally updates the velocity and acceleration that are already computed by other functions. |
If you have a better fix ready, we can use that one, but if we are going to merge a short-term fix, would it be acceptable to modify |
Yes, it would work. |
* Fix issue dartsim#1433 The main fix is in the expression used to integrate velocities. The secondary fix is to update spatial accelerations after integrating velocities and to update both spatial velocities and accelerations after integrating positions. * Add regression test for issue dartsim#1193 * Remove main in test, fix style
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
While working on #1505 (a copy of gazebo-forks#9) , I found that 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 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. |
@jslee02 any updates on this one and when it will be fixed in DART main repo? |
Let me take a look this PR this weekend |
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
I've updated the PR with the changes we've made on our fork. I've relaxed the tolerances in |
My apologies for the supre late response. Left a few comments, one build related one and mostly style fixes. As pointed out in gazebo-forks#28 (comment), changing the reference frame would require lots of work and need throught tests to make sure it doesn't introduce unforeseen side effects. Let me merge this change as it's currently the best solution. Thank you for the fix with the decent tests! |
dart/dynamics/FreeJoint.cpp
Outdated
|
||
setVelocitiesStatic(math::AdR(Qdiff.inverse(), getVelocitiesStatic())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we cache math::AdR(Qdiff.inverse())
to compute it only once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cached Qdiff.inverse()
in the variable QdiffInv
in 5091a56. I hope that's what you meant.
auto comLinearVel = rootBn->getCOMLinearVelocity(); | ||
// TODO (addisu) Improve FreeJoint integration so that a higher tolerance is | ||
// not necessary here. | ||
EXPECT_NEAR(0.01, comLinearVel.x(), tol * 1e2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Would it be better to change 0.01
to 10 * dt
to give hint on where the expected value come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I added a variable extForce
and then used the x component of that in the expectation. 5091a56
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for being patient with me! LGTM
This resolves issue #1433 and possibly the other issues mentioned in there. The two changes made in this PR are:
When integrating a FreeJoint's velocity, an additional term is added to account for changing linear velocity in the inertial frame.
The joint velocities of FreeJoint are in se3 and since they are expressed in the body frame, they have to be updated after the joint's positions (SE3) are updated. The same is true for accelerations after velocities are integrated.
This PR breaks a test in
test_Dynamics.cpp
because integration of the joint positions ofFreeJoint
updates joint velocities unlike other joint types. I left this as WIP to get some feedback on what to do about this test failure.Before creating a pull request
clang-format
Before merging a pull request
CHANGELOG.md