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

Visualization tools for ApplyForceTorque #2051

Merged
merged 35 commits into from
Aug 23, 2023

Conversation

Henrique-BO
Copy link
Contributor

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

🎉 New feature

Requires #2014

Summary

Adds visualization tools to the new ApplyForceTorque GUI plugin. This allows the user to see the force (represented by an arrow) and the torque (represented by a circle) displayed on the scene at their application point before applying them.

When one of the vectors (force or torque) is clicked, a rotation tool (represented by a gizmo) is displayed. This allows the user to freely rotate the selected vector. Still WIP.

TODO:

  • Improve torque visualization
  • Implement rotation tool for the vectors (like in Classic)

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 or torque to see its direction on the scene.

Click on the force or torque vector to display the rotation tool, and click and drag the circles to rotate.

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]>
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Jul 26, 2023
@azeey azeey self-requested a review July 26, 2023 16:50
@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Merging #2051 (434e4f1) into gz-sim7 (b0ddc34) will decrease coverage by 0.05%.
Report is 20 commits behind head on gz-sim7.
The diff coverage is 57.08%.

❗ Current head 434e4f1 differs from pull request most recent head 419b34f. Consider uploading reports for the commit 419b34f to get more accurate results

@@             Coverage Diff             @@
##           gz-sim7    #2051      +/-   ##
===========================================
- Coverage    65.01%   64.97%   -0.05%     
===========================================
  Files          353      356       +3     
  Lines        28618    28783     +165     
===========================================
+ Hits         18606    18701      +95     
- Misses       10012    10082      +70     
Files Changed Coverage Δ
include/gz/sim/Link.hh 100.00% <ø> (ø)
include/gz/sim/Util.hh 100.00% <ø> (ø)
include/gz/sim/rendering/WrenchVisualizer.hh 0.00% <0.00%> (ø)
.../plugins/component_inspector/ComponentInspector.cc 5.57% <0.00%> (-0.05%) ⬇️
.../gui/plugins/transform_control/TransformControl.cc 6.01% <0.00%> (-0.12%) ⬇️
src/rendering/RenderUtil.cc 39.03% <0.00%> (ø)
src/rendering/WrenchVisualizer.cc 0.00% <0.00%> (ø)
src/systems/apply_link_wrench/ApplyLinkWrench.hh 100.00% <ø> (ø)
src/systems/buoyancy/Buoyancy.cc 82.25% <0.00%> (ø)
.../systems/environment_preload/EnvironmentPreload.cc 69.69% <0.00%> (ø)
... and 20 more

... and 2 files with indirect coverage changes

@arjo129
Copy link
Contributor

arjo129 commented Jul 28, 2023

@Henrique-BO this is really cool. It would be nice if we could extract the rendering logic out to some common area so it can be shared by other plugins. #1898 seeks to do visualizations but on arbitrary objects. It would be nice to have a consistent visual language between these two PRs. Perhaps if you were to create a new utility class called "Force Visuallization" and make the material configurable, we would be able to reuse this code in #1898.

src/gui/plugins/apply_force_torque/ApplyForceTorque.cc Outdated Show resolved Hide resolved

math::Vector3d startPos;
this->ray->SetFromCamera(this->camera, start);
if (auto v = plane.Intersection(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use {}


math::Vector3d endPos;
this->ray->SetFromCamera(this->camera, end);
if (auto v = plane.Intersection(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use {}

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 bfbb1bd

@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 31, 2023
@Henrique-BO
Copy link
Contributor Author

@arjo129 I think that's a great idea. I created a WrenchVisualizer utility class that creates and updates the force and torque visuals I'm using. What do you think?

@Henrique-BO Henrique-BO marked this pull request as ready for review August 3, 2023 18:03
@arjo129
Copy link
Contributor

arjo129 commented Aug 4, 2023

Sounds awesome!

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 wasn't able to get the 3D Scene interaction to work. Can you try it again? Otherwise, just a few minor comments.

include/gz/sim/rendering/WrenchVisualizer.hh Outdated Show resolved Hide resolved
include/gz/sim/rendering/WrenchVisualizer.hh Outdated Show resolved Hide resolved
include/gz/sim/rendering/WrenchVisualizer.hh Outdated Show resolved Hide resolved
include/gz/sim/rendering/WrenchVisualizer.hh Outdated Show resolved Hide resolved
src/rendering/WrenchVisualizer.cc Outdated Show resolved Hide resolved
src/gui/plugins/apply_force_torque/ApplyForceTorque.cc Outdated Show resolved Hide resolved
src/gui/plugins/apply_force_torque/ApplyForceTorque.cc Outdated Show resolved Hide resolved
@Henrique-BO
Copy link
Contributor Author

Changes addressed in b5cafc3.

The 3D scene interaction is working on my end, like this:

Screencast.2023-08-16.16.31.46.mp4

Is this not working for you?

for (unsigned int i = 0; i < this->scene->NodeCount(); ++i)
{
auto cam = std::dynamic_pointer_cast<rendering::Camera>(
this->scene->NodeByIndex(i));
Copy link
Contributor

Choose a reason for hiding this comment

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

Camera is registered as a Sensor gz-rendering so you can reduce the search space by using SensorCount and SensorByIndex since there's probably only one camera in the scene.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, changed it in d6afb10

@azeey
Copy link
Contributor

azeey commented Aug 22, 2023

Changes addressed in b5cafc3.

The 3D scene interaction is working on my end, like this:

Screencast.2023-08-16.16.31.46.mp4
Is this not working for you?

Ah, I didn't click on the arrow, I thought it would appear with the arrow. I also tried to drag the arrow but that didn't help. I think a helpful message in the GUI card would be good to add.

@Henrique-BO
Copy link
Contributor Author

Good point, I added a message to the GUI in 419b34f

Copy link
Contributor

@iche033 iche033 left a comment

Choose a reason for hiding this comment

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

nice, the tool works well for me

@azeey azeey merged commit 30eeb62 into gazebosim:gz-sim7 Aug 23, 2023
4 checks passed
@Henrique-BO Henrique-BO deleted the apply_force_torque_vis branch August 23, 2023 13:41
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.

5 participants