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

Visualize joints #961

Merged
merged 19 commits into from
Aug 26, 2021
Merged

Visualize joints #961

merged 19 commits into from
Aug 26, 2021

Conversation

atharva-18
Copy link
Contributor

@atharva-18 atharva-18 commented Aug 9, 2021

🎉 New feature

Closes #106
Requires gazebosim/gz-rendering#366

Summary

Adds the ability to visualize joints of simulation models, similar to Gazebo Classic
visualize_joints

Test it

Test it by right-clicking on a model and selecting View -> Joints

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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

@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Aug 9, 2021
include/ignition/gazebo/rendering/SceneManager.hh Outdated Show resolved Hide resolved
src/rendering/RenderUtil.cc Outdated Show resolved Hide resolved
src/rendering/RenderUtil.cc Outdated Show resolved Hide resolved
src/rendering/RenderUtil.cc Outdated Show resolved Hide resolved
src/rendering/SceneManager.cc Outdated Show resolved Hide resolved
src/rendering/SceneManager.cc Outdated Show resolved Hide resolved
@chapulina chapulina added GUI Gazebo's graphical interface (not pure Ignition GUI) rendering Involves Ignition Rendering needs upstream release Blocked by a release of an upstream library labels Aug 9, 2021
@ahcorde
Copy link
Contributor

ahcorde commented Aug 19, 2021

friendly ping @chapulina @iche033

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

So great to see we're about to have joint visuals!

I tested with this model:

https://app.ignitionrobotics.org/OpenRobotics/fuel/models/Demo%20Joint%20Types

I see that the revolute, revolute2 and universal joints seem to be missing the joint pose offset:

rev_vis

@@ -1040,6 +1046,32 @@ void IgnRenderer::Render(RenderSync *_renderSync)
}
}

// View inertia
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
// View inertia
// View joints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The joint visual pose should be fixed by 101a1e7
revolute

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.

looking good, have a few optimization suggestions.

/// \param[in] _ecm The entity-component manager
public: void FindJointModels(const EntityComponentManager &_ecm);

/// \brief A list of models used to create new inertia visuals
Copy link
Contributor

Choose a reason for hiding this comment

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

inertia -> joint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

auto axis1UseParentFrame =
(_joint.Axis(0)->XyzExpressedIn() == "__model__")? true : false;
auto axis2UseParentFrame =
(_joint.Axis(1)->XyzExpressedIn() == "__model__")? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the logic can be be simplified to something like:

bool axis2UseParentFrame =
        _joint.Axis(1)->XyzExpressedIn() == "__model__";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 1295 to 1297
if (this->dataPtr->visuals.find(_parentId) != this->dataPtr->visuals.end())
{
auto parentName = this->dataPtr->visuals[_parentId]->Name();
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: store the find result to avoid a second lookup:

    auto it = this->dataPtr->visuals.find(_parentId);
    if (it != this->dataPtr->visuals.end())
    {
      auto parentName = it->second->Name();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{
auto axis1 = _joint.Axis(0)->Xyz();
auto axis1UseParentFrame =
(_joint.Axis(0)->XyzExpressedIn() == "__model__")? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as before about simplifying the logic here

bool axis1UseParentFrame =
        _joint.Axis(0)->XyzExpressedIn() == "__model__";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

!= this->dataPtr->wireBoxes.end())
{
ignition::rendering::WireBoxPtr wireBox =
this->dataPtr->wireBoxes[jointEntity];
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: store find result to avoid second lookup:

      auto wireBoxIt = this->dataPtr->wireBoxes.find(jointEntity);
      if (wireBoxIt != this->dataPtr->wireBoxes.end())
      {
        ignition::rendering::WireBoxPtr wireBox = wireBoxIt->second;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iche033
Copy link
Contributor

iche033 commented Aug 20, 2021

I tested changing a revolute joint to fixed and commenting out the <axis> tag, and the visual becomes quite large:

joint_visual_fixed_large

If I add the <axis> tag back, then the size is correct but the arrow of the axis is highlighted in yellow - I think it should not be highlighted as it's a fixed joint. Here's what it looks like in gazebo-classic:

joint_visual_fixed_classic

@atharva-18
Copy link
Contributor Author

I tested changing a revolute joint to fixed and commenting out the <axis> tag, and the visual becomes quite large:

joint_visual_fixed_large

If I add the <axis> tag back, then the size is correct but the arrow of the axis is highlighted in yellow - I think it should not be highlighted as it's a fixed joint. Here's what it looks like in gazebo-classic:

joint_visual_fixed_classic

The scaling and <axis> tag issues should be fixed by 10f9fd5
fixed joint

@iche033
Copy link
Contributor

iche033 commented Aug 20, 2021

the fixed joint scale issue is fixed, thanks.

I'm testing with the Demo Joint Types model and noticed that revolute2 and universal joints don't show the 2nd yellow axis? Here's comparison with gazebo classic?

joint_visual_rot_axis

Signed-off-by: Atharva Pusalkar <[email protected]>
@atharva-18
Copy link
Contributor Author

The axis2 pose issue should be fixed by 0b74bf4

Here's the revolute2 joint:
Revolute2

I am able to visualize the universal joint demo for the demo_joint_types.sdf file present in the test/worlds/ folder, and not for the model present on Fuel. Maybe it's an issue with the model on Fuel?
This is how the universal joint visual looks like:
universal

@codecov
Copy link

codecov bot commented Aug 23, 2021

Codecov Report

Merging #961 (3eb52a1) into main (e3ee0af) will decrease coverage by 0.88%.
The diff coverage is 49.15%.

❗ Current head 3eb52a1 differs from pull request most recent head fa080c4. Consider uploading reports for the commit fa080c4 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #961      +/-   ##
==========================================
- Coverage   64.66%   63.78%   -0.89%     
==========================================
  Files         242      246       +4     
  Lines       19014    19996     +982     
==========================================
+ Hits        12296    12755     +459     
- Misses       6718     7241     +523     
Impacted Files Coverage Δ
include/ignition/gazebo/EntityComponentManager.hh 100.00% <ø> (ø)
include/ignition/gazebo/Link.hh 100.00% <ø> (ø)
include/ignition/gazebo/Server.hh 100.00% <ø> (ø)
include/ignition/gazebo/gui/GuiEvents.hh 0.00% <0.00%> (ø)
include/ignition/gazebo/rendering/RenderUtil.hh 100.00% <ø> (ø)
include/ignition/gazebo/rendering/SceneManager.hh 100.00% <ø> (ø)
src/SdfEntityCreator.cc 84.53% <0.00%> (-0.89%) ⬇️
src/gui/Gui.cc 65.35% <ø> (+0.23%) ⬆️
src/gui/GuiRunner.cc 85.91% <0.00%> (-0.34%) ⬇️
src/gui/plugins/scene3d/Scene3D.hh 50.00% <ø> (ø)
... and 65 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81f3da9...fa080c4. Read the comment docs.

@iche033
Copy link
Contributor

iche033 commented Aug 24, 2021

Maybe it's an issue with the model on Fuel?

yep, I just fixed the model on Fuel. It should now show the axis. You'll need to clear the one in your fuel cache (~/.ignition/fuel/fuel.ignitionrobotics.org/openrobotics/models/) and rerun ign-gazebo to download the new one.

This is how the universal joint visual looks like

I was able to see what you have now! Just one minor detail - the red axis is missing an arrow head.

demo_joint_types_missing_arrow_head

@atharva-18
Copy link
Contributor Author

I see. For that the ign-rendering class would require a small patch in the UpdateAxis method, to avoid changing the axis head visibility for our case.
atharva-18/ign-rendering@f301591
This is how it looks with the fix:
Universal

@iche033
Copy link
Contributor

iche033 commented Aug 24, 2021

atharva-18/ign-rendering@f301591

ok I see, can you create a pull request for this?

@atharva-18
Copy link
Contributor Author

Created a PR - gazebosim/gz-rendering#387

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.

looks good to me!

@ahcorde
Copy link
Contributor

ahcorde commented Aug 25, 2021

@osrf-jenkins retest this please

@ahcorde ahcorde merged commit 1334b5c into gazebosim:main Aug 26, 2021
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/google-summer-of-code-2021-new-gui-widgets-in-ignition-gazebo/1081/1

@chapulina chapulina mentioned this pull request Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress GUI Gazebo's graphical interface (not pure Ignition GUI) needs upstream release Blocked by a release of an upstream library rendering Involves Ignition Rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants