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

Apply Force and Torque GUI plugin #2014

Merged
merged 17 commits into from
Jul 26, 2023

Conversation

Henrique-BO
Copy link
Contributor

@Henrique-BO Henrique-BO commented Jun 14, 2023

🎉 New feature

Partially addresses #306

Summary

Adds a new ApplyForceTorque GUI plugin, essentially implementing the Apply Force and Torque interface that we have in Gazebo Classic.

This allows users to apply a specified force and torque to a chosen link in a model upon pressing a button. The implementation takes advantage of the existing ApplyLinkWrench system, sending the wrenches to the /world/<world_name>/wrench topic. The ApplyLinkWrench system is automatically loaded once this plugin is loaded.

However, a current limitation is that applying the force with an offset from the link origin is not supported, since it is not implemented in ApplyLinkWrench.

Test it

Open any test world.

gz sim src/gz-sim/examples/worlds/apply_link_wrench.sdf

Load the Apply Force Torque plugin from the plugin dropdown.

On the interface, input the desired force and torque. The model is selected from the scene, and the specific link is specified through a dropdown on the interface. Buttons are available to apply either just a force, just a torque or both at the same time.

ezgif com-video-to-gif

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.

Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
@osrf-triage osrf-triage added this to Inbox in Core development Jun 14, 2023
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Jun 14, 2023
Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
@Henrique-BO Henrique-BO marked this pull request as ready for review June 14, 2023 22:21
Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Looks great!! I haven't tested it yet, but wanted to give it a first pass.

Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

Minor documentation related feedback. Which plugin is needed in order to apply the force?

ApplyForceTorque.ApplyAll()
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Knit: New line at end of file.

/// \brief Publish wrench to "/world/apply_link_wrench/wrench" topic.
///
/// ## Configuration
/// This plugin doesn't accept any custom configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Knit: Might be worth mentioning which plugin provides the /world/apply_link_wrench/wrench topic.

gzerr << "World not found" << std::endl;
return false;
});
auto topic = transport::TopicUtils::AsValidTopic(
Copy link
Contributor

Choose a reason for hiding this comment

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

check if topic is valid. it should return an empty string if the function fails

Core development automation moved this from Inbox to In review Jun 16, 2023
Copy link
Contributor

@quarkytale quarkytale left a comment

Choose a reason for hiding this comment

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

Tried it out, works as expected

src/gui/plugins/apply_force_torque/ApplyForceTorque.qrc Outdated Show resolved Hide resolved
src/gui/plugins/apply_force_torque/CMakeLists.txt Outdated Show resolved Hide resolved
@Henrique-BO
Copy link
Contributor Author

Thanks for the feedback. I addressed the requested changes in 6fbbfc0.

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #2014 (ebe79b1) into gz-sim7 (50a99e6) will decrease coverage by 0.03%.
The diff coverage is n/a.

❗ Current head ebe79b1 differs from pull request most recent head 3911d73. Consider uploading reports for the commit 3911d73 to get more accurate results

@@             Coverage Diff             @@
##           gz-sim7    #2014      +/-   ##
===========================================
- Coverage    65.00%   64.98%   -0.03%     
===========================================
  Files          354      354              
  Lines        28667    28667              
===========================================
- Hits         18636    18630       -6     
- Misses       10031    10037       +6     

see 1 file with indirect coverage changes

@quarkytale
Copy link
Contributor

@osrf-jenkins run tests please


#include <string>

#include <gz/gui/Application.hh>
Copy link
Contributor

Choose a reason for hiding this comment

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

alphabetize headers

{
this->dataPtr->changedEntity = false;

this->dataPtr->modelName = "";
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
this->dataPtr->modelName = "";
this->dataPtr->modelName{""};

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 don't think this works, since this is an assignment, not an initialization. I get a compilation error if I try this.

@Henrique-BO
Copy link
Contributor Author

Changes addressed in ca1c904.

Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

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

I checked gazebo-classic once more and it looks like the force/torque is applied in the body fixed frame. I don't want to block this PR on that. Maybe we can add that later, but I think we should indicate that the force/torque is applied in the world frame in the GUI.

src/gui/plugins/apply_force_torque/ApplyForceTorque.cc Outdated Show resolved Hide resolved
Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
@Henrique-BO
Copy link
Contributor Author

You're right, I hadn't noticed that. I changed the application to the body fixed frame and added an indication to the GUI, so it's more consistent with Gazebo-Classic.

Signed-off-by: Henrique-BO <henrique.barrosoliveira@usp.br>
@azeey azeey merged commit fbc3ca8 into gazebosim:gz-sim7 Jul 26, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants