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

Support setting canonical link #142

Merged
merged 13 commits into from
Nov 12, 2020
Merged

Conversation

claireyywang
Copy link
Contributor

Set canonical link if defined in sdformat file, otherwise set first link of model as canonical. Closes #100

@claireyywang claireyywang added 🏰 citadel Ignition Citadel TPE Trivial Physics Engine labels Oct 22, 2020
@claireyywang claireyywang self-assigned this Oct 22, 2020
@claireyywang
Copy link
Contributor Author

claireyywang commented Oct 22, 2020

[Resolved]
I have some questions related to nested model @iche033 @scpeters

  1. Do each model (nested or not) only have one canonical link or each nested model can have its own canonical link?
  2. If a model doesn’t have a top level link, does it take the nested model’s first link as the canonical link?

So far I only added a generic function in Model.cc and let SdfFeatures.cc set the canonical link since that's when we can determine whether CanonicalLink is defined or not for a model. I'm not sure if canonical link canbe set at Model::AddLink() due to limited information about a link (whether I should set first link or defined <canonical_link>).

…oup no canonical assumption

Signed-off-by: claireyywang <[email protected]>
@claireyywang claireyywang marked this pull request as ready for review October 23, 2020 05:03
@claireyywang claireyywang requested a review from mxgrey as a code owner October 23, 2020 05:03
@claireyywang claireyywang requested review from iche033 and removed request for mxgrey October 23, 2020 05:04
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.

thanks for the changes. I have a couple minor comments, and one about adding a test to verify canonical link in a nested model

tpe/lib/src/Model_TEST.cc Show resolved Hide resolved
tpe/lib/src/Model.cc Outdated Show resolved Hide resolved
tpe/lib/src/Model.cc Outdated Show resolved Hide resolved
@claireyywang claireyywang requested a review from iche033 November 10, 2020 18:13
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.

Just a couple of minor code check issues. I added some checks in SDFFeatures_TEST and tests pass. Feel free to incorporate these changes

diff --git a/tpe/plugin/src/SDFFeatures_TEST.cc b/tpe/plugin/src/SDFFeatures_TEST.cc
index bbef33f..78cd972 100644
--- a/tpe/plugin/src/SDFFeatures_TEST.cc
+++ b/tpe/plugin/src/SDFFeatures_TEST.cc
@@ -37,6 +37,7 @@
 #include <ignition/physics/sdf/ConstructWorld.hh>
 
 #include "lib/src/Entity.hh"
+#include "lib/src/Model.hh"
 #include "lib/src/World.hh"
 #include "World.hh"
 
@@ -413,6 +414,12 @@ TEST(SDFFeatures_TEST, NestedModel)
       nestedCollision.GetId());
   EXPECT_EQ("nested_collision", nestedCollision.GetName());
   EXPECT_EQ(ignition::math::Pose3d::Zero, nestedCollision.GetPose());
+
+  // canonical link
+  ignition::physics::tpelib::Model *m =
+      static_cast<ignition::physics::tpelib::Model *>(&model);
+  ignition::physics::tpelib::Entity canLink = m->GetCanonicalLink();
+  EXPECT_EQ(link.GetId(), canLink.GetId());
 }

tpe/lib/src/Model.cc Outdated Show resolved Hide resolved
tpe/plugin/src/SDFFeatures.cc Outdated Show resolved Hide resolved
tpe/lib/src/Model.hh Outdated Show resolved Hide resolved
Signed-off-by: claireyywang <[email protected]>
@codecov
Copy link

codecov bot commented Nov 11, 2020

Codecov Report

Merging #142 (13ef221) into ign-physics2 (c11a47d) will increase coverage by 0.04%.
The diff coverage is 96.15%.

Impacted file tree graph

@@               Coverage Diff                @@
##           ign-physics2     #142      +/-   ##
================================================
+ Coverage         83.06%   83.10%   +0.04%     
================================================
  Files               106      106              
  Lines              3973     3983      +10     
================================================
+ Hits               3300     3310      +10     
  Misses              673      673              
Impacted Files Coverage Δ
tpe/plugin/src/FreeGroupFeatures.cc 79.68% <66.66%> (-0.32%) ⬇️
tpe/lib/src/Model.cc 98.36% <100.00%> (+0.02%) ⬆️
tpe/plugin/src/SDFFeatures.cc 84.24% <100.00%> (+1.15%) ⬆️

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 c11a47d...13ef221. Read the comment docs.

@claireyywang claireyywang requested a review from iche033 November 11, 2020 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel TPE Trivial Physics Engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants