Skip to content
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

SimbodyLink: add and set force and torque #3262

Open
wants to merge 2 commits into
base: gazebo11
Choose a base branch
from

Conversation

jeduardo211
Copy link
Contributor

This PR adds the implementation of methods for applying forces and torques to links when using the Simbody physics engine.

The following methods are now implemented in the SimbodyLink class:

  • AddForce
  • AddRelativeForce
  • AddForceAtWorldPosition
  • AddForceAtRelativePosition
  • AddLinkForce
  • AddTorque
  • AddRelativeTorque

Additionally, the implementation of the SetForce, and SetTorque methods was modified to ensure that setting the force applied to the body do not alter the torque currently applied to the body and vice versa.

In order to test the above methods, the AddForce test of the physics_link integration tests is now enabled for Simbody. Please note that Simbody required an additional step to update the pose of the link and its inertial origin, and thus the AddForce test was modified to reflect this.

Note: The OnWrenchMsg test is still disabled for Simbody.
There is an easy way to enable this test, by adding a "auto_reset_forces" parameter to the SimbodyPhysics and checking the value of this parameter in the SimbodyPhysics::UpdatePhysics method to determine if the forces and torques applied should be cleared before the next step.
However, the SimbodyPhysics class is not following the PIMPL pattern, and thus adding this parameter would introduce breaking changes in the API. Because of this these modifications were not included and the OnWrenchMsg test remains disabled for simbody.
If this change is acceptable please advise and I will create a new PR to enable this test.

Solves issue #1478.

The following methods are now implemented in the SimbodyLink class:

- AddForce
- AddRelativeForce
- AddForceAtWorldPosition
- AddForceAtRelativePosition
- AddLinkForce
- AddTorque
- AddRelativeTorque

Additionally, the implementation of the SetForce, and SetTorque methods was modified to ensure that setting the force applied to the body do not alter the torque currently applied to the body and vice versa.

In order to test the above methods, the AddForce test of the physics_link integration tests is now enabled for Simbody.

Solves issue gazebosim#1478.
@jeduardo211
Copy link
Contributor Author

@scpeters Could you please review this PR?

{
gzerr << "Not implemented.\n";
auto const worldForce = this->WorldPose().Rot().RotateVector(_force);
this->AddTorque(worldForce);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why we would call AddTorque from the AddRelativeForce method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, this is a mistake I made. Line 519 should be a call to this->AddForce. I fixed this in the latest commit.

The implementation of the SimbodyLink::AddRelativeForce was incorrectly calling the AddTorque method. 
This commit changes the implementation to call AddForce instead.
@jeduardo211
Copy link
Contributor Author

Any updates on this?

@scpeters
Copy link
Member

Any updates on this?

sorry I haven't had a chance to finish my review, but I'll try to take a look this week

@azeey azeey added beta and removed beta labels Jul 31, 2023
@talregev
Copy link
Contributor

@jeduardo211 Can you rebase to the latest gazebo11 dev?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

None yet

4 participants