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

Add AddLinkForce Function to Apply Forces in Link Frame #2816

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Vedant87
Copy link

@Vedant87 Vedant87 commented Mar 7, 2025

🎉 New feature

Closes #2713

Summary

Function added: to apply force relative to the center of mass of the link frame, the function converts the force to a force with respect to the world coordinates. It uses the AddWorldForce method to apply force either at the center of mass of the link or at an offset from the center of mass, based on user input.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@Vedant87 Vedant87 requested a review from mjcarroll as a code owner March 7, 2025 16:12
@github-actions github-actions bot added the 🪵 jetty Gazebo Jetty label Mar 7, 2025
@iche033
Copy link
Contributor

iche033 commented Mar 7, 2025

The CI picked up some lint issues - can you remove trailing whitespace and limit lines to 80 char? I also made some minor comments on removing empty lines.

.gitignore Outdated
@@ -20,3 +20,4 @@ build_*
# Python cache
__pycache__
*.pyc

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

src/Link.cc Outdated



Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty lines

Suggested change

src/Link.cc Outdated

// Apply Force using AddWorldForce method
this->AddWorldForce(_ecm, worldForce);

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

Suggested change

src/Link.cc Outdated
const math::Vector3d &_force,
const math::Vector3d &_position) const
{

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

src/Link.cc Outdated
Comment on lines 470 to 466



Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

src/Link.cc Outdated
// so we need to compute the force expressed in world coordinates
math::Vector3d worldForce = worldPose.Rot() * _force;


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

src/Link.cc Outdated

// Apply Force using AddWorldForce method
this->AddWorldForce(_ecm, worldForce, _position);

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

/// and applied at the center of mass of the link.
/// \param[in] _ecm Mutable Entity-component manager.
/// \param[in] _force Force to be applied expressed in link's center of mass coordinates
public: void AddLinkForce(EntityComponentManager &_ecm,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just AddForce, which is more consistent with gazebo-classic's API. Do you have any preference on the API name, @scpeters?.

@Vedant87 Vedant87 requested a review from iche033 March 8, 2025 03:35
@Vedant87 Vedant87 force-pushed the add_link_force_api branch 4 times, most recently from 0cbdd0f to 4e44110 Compare March 8, 2025 09:37
Vedant87 and others added 5 commits March 8, 2025 09:41
Signed-off-by: Vedant87 <Vedantsr3@gmail.com>
Signed-off-by: Vedant87 <Vedantsr3@gmail.com>
Signed-off-by: Vedant87 <Vedantsr3@gmail.com>
… to 80 characters

Signed-off-by: Vedant87 <Vedantsr3@gmail.com>
… to 80 characters

Signed-off-by: Vedant87 <Vedantsr3@gmail.com>
@Vedant87 Vedant87 force-pushed the add_link_force_api branch from 4e44110 to 9660d0c Compare March 8, 2025 09:45
@@ -19,4 +19,4 @@ build_*

# Python cache
__pycache__
*.pyc
*.pyc
Copy link
Contributor

Choose a reason for hiding this comment

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

May I understand why this file was touched?

Copy link
Author

Choose a reason for hiding this comment

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

I had forgotten to fetch the changes from my remote repository and merge them into my local branch, which led to merge conflicts. As a result, I had to modify this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just add a new line at the end of the file so that the ci tests pass and this does not show up. It seems you have removed the end of line marker on the file.

}

//////////////////////////////////////////////////
void Link::AddLinkForce(EntityComponentManager &_ecm,
Copy link
Contributor

@arjo129 arjo129 Mar 11, 2025

Choose a reason for hiding this comment

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

Can you add a unit test for this?

You can find other tests for the link class here: https://github.com/gazebosim/gz-sim/blob/gz-sim9/src/Link_TEST.cc

@arjo129
Copy link
Contributor

arjo129 commented Mar 11, 2025

Once you decide on the naming, it'll also be good to update the python API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪵 jetty Gazebo Jetty
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants