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

Force offset and vector magnitude support in ApplyForceTorque #2056

Merged
merged 69 commits into from
Aug 25, 2023

Conversation

Henrique-BO
Copy link
Contributor

@Henrique-BO Henrique-BO commented Jul 27, 2023

🎉 New feature

Requires #2051
Requires #2026

Summary

Adds support for specifying the offset of the force application point through the GUI in the ApplyForceTorque plugin. This offset is also reflected in the visualization of the force vector.

Also adds fields for the magnitude of the force and torque vectors on the interface. Changing the components of a vector automatically updates the value of its magnitude, while changing the vector's magnitude automatically scales its components, maintaining its direction.

Test it

Open any test world.

Load the Apply Force Torque plugin from the plugin dropdown.

Select a model or link and specify a force and torque.

Change the values of the offset and magnitudes and observe the effects.

image

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 <[email protected]>
Signed-off-by: Henrique-BO <[email protected]>
Signed-off-by: Henrique-BO <[email protected]>
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Jul 27, 2023
#include <gz/utils/ImplPtr.hh>

#include <gz/math/Vector3.hh>
#include <gz/rendering/RenderTypes.hh>
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: include what you need and not all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I'm using some declarations from those headers shouldn't I need to include them?

#include <gz/gui/Helpers.hh>
#include <gz/gui/MainWindow.hh>
#include <gz/math/Pose3.hh>
#include <gz/math/Quaternion.hh>
#include <gz/math/Vector3.hh>
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
#include <gz/math/Vector3.hh>
#include <gz/math/Vector2.hh>
#include <gz/math/Vector3.hh>

@@ -18,15 +18,27 @@
#include <mutex>
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
#include <mutex>
#include <memory>
#include <mutex>


#include <gz/common/Console.hh>
#include <gz/common/MeshManager.hh>
#include <gz/math/Vector3.hh>
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
#include <gz/math/Vector3.hh>
#include <gz/math/Quaternion.hh>
#include <gz/math/Vector3.hh>

* limitations under the License.
*
*/

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
#include <memory>

#include <gz/common/Console.hh>
#include <gz/common/MeshManager.hh>
#include <gz/math/Vector3.hh>
#include <gz/rendering/ArrowVisual.hh>
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
#include <gz/rendering/ArrowVisual.hh>
#include <gz/rendering/ArrowVisual.hh>
#include <gz/rendering/Material.hh>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in c4819ef

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.

Works pretty well! Just have couple minor comments.

Signed-off-by: Henrique-BO <[email protected]>
@iche033
Copy link
Contributor

iche033 commented Aug 23, 2023

Is there a way to remove the semi-transparent apply force / torque visuals once I'm done using the plugin? Closing the gui plugin does not seem to remove/hide the visuals?

@Henrique-BO
Copy link
Contributor Author

Is there a way to remove the semi-transparent apply force / torque visuals once I'm done using the plugin? Closing the gui plugin does not seem to remove/hide the visuals?

Setting the magnitude (or each component) to zero removes the visual. Do you think that's enough?

Closing the plugin should remove the visuals though, I'll fix that.

@iche033
Copy link
Contributor

iche033 commented Aug 23, 2023

Closing the plugin should remove the visuals though, I'll fix that.

This should be good enough, thanks!

@Henrique-BO
Copy link
Contributor Author

Fixed in 2c83ce2

However, I noticed that this bug also happens in the Transform Control and Tape Measure plugins.

Comment on lines 218 to 225
this->dataPtr->forceVisual->SetVisible(false);
this->dataPtr->forceVisual->Destroy();

this->dataPtr->torqueVisual->SetVisible(false);
this->dataPtr->torqueVisual->Destroy();

this->dataPtr->gizmoVisual->SetVisible(false);
this->dataPtr->gizmoVisual->Destroy();
Copy link
Contributor

Choose a reason for hiding this comment

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

ah yes this works but prefer to use Scene::DestroyNode as it ensures the the visuals are also removed from the scene's internal list of nodes:

Suggested change
this->dataPtr->forceVisual->SetVisible(false);
this->dataPtr->forceVisual->Destroy();
this->dataPtr->torqueVisual->SetVisible(false);
this->dataPtr->torqueVisual->Destroy();
this->dataPtr->gizmoVisual->SetVisible(false);
this->dataPtr->gizmoVisual->Destroy();
this->dataPtr->scene->DestroyNode(this->dataPtr->forceVisual, true);
this->dataPtr->scene->DestroyNode(this->dataPtr->torqueVisual, true);
this->dataPtr->scene->DestroyNode(this->dataPtr->gizmoVisual, true);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, changed it in db942e4

Signed-off-by: Henrique-BO <[email protected]>
@azeey azeey merged commit 2d64e1e into gazebosim:gz-sim7 Aug 25, 2023
4 checks passed
@Henrique-BO Henrique-BO deleted the apply_force_torque_offset branch August 25, 2023 19:07
azeey pushed a commit that referenced this pull request Aug 29, 2023
Adds tutorials for the new ApplyForceTorque plugin (including the features added in #2051 and #2056) and for the new MouseDrag plugin.
---------

Signed-off-by: Henrique-BO <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants