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

Add support for nested models in TPE #86

Merged
merged 45 commits into from
Sep 14, 2020
Merged

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Jul 21, 2020

Depends on gazebosim/sdformat#316

This PR adds support for nested models in TPE plugin (dartsim plugin does not support nested models yet).

Example sdf description of a nested model:

  <model>
      <link>...  </link>
      <model>
      ...
      </model>
  <model>

The main changes are:

  • Added functions to allow Models to construct child models.
  • Added support for getting canonical links from a nested model tree
  • Updated SetWorldPose in FreeGroup to work with nested models

iche033 and others added 30 commits July 6, 2020 15:52
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: Ian Chen <[email protected]>

Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
@scpeters
Copy link
Member

scpeters commented Aug 8, 2020

@azeey so now we want to declare that ignition::physics::sdf::ConstructSdfModel does not support nested models? If we require SDFormat 9.3, then we can use the new DOM API's to check if an sdf::Model passed to this API has any nested models. Should we add this as a check in our shim function (the one usually in a detail folder)?

At a minimum, we should document the new restriction on the ignition::physics::sdf::ConstructSdfModel feature. We can do this in a separate PR, as long as this doesn't get released before the follow-up is merged

@iche033
Copy link
Contributor Author

iche033 commented Aug 11, 2020

At a minimum, we should document the new restriction on the ignition::physics::sdf::ConstructSdfModel feature. We can do this in a separate PR, as long as this doesn't get released before the follow-up is merged

done. added comment in ef6503e

Signed-off-by: Steve Peters <[email protected]>
@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #86 into ign-physics2 will increase coverage by 0.15%.
The diff coverage is 86.23%.

Impacted file tree graph

@@               Coverage Diff                @@
##           ign-physics2      #86      +/-   ##
================================================
+ Coverage         83.28%   83.43%   +0.15%     
================================================
  Files               106      106              
  Lines              3804     3900      +96     
================================================
+ Hits               3168     3254      +86     
- Misses              636      646      +10     
Impacted Files Coverage Δ
sdf/include/ignition/physics/sdf/ConstructModel.hh 100.00% <ø> (ø)
dartsim/src/SDFFeatures.cc 66.57% <25.00%> (-0.49%) ⬇️
tpe/plugin/src/FreeGroupFeatures.cc 80.00% <76.00%> (+2.22%) ⬆️
tpe/plugin/src/SDFFeatures.cc 83.08% <86.48%> (+3.08%) ⬆️
tpe/lib/src/Model.cc 98.33% <96.96%> (-1.67%) ⬇️
...clude/ignition/physics/sdf/ConstructNestedModel.hh 100.00% <100.00%> (ø)
tpe/plugin/src/Base.hh 98.00% <100.00%> (ø)

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 c5ad325...359ca9a. Read the comment docs.

@scpeters
Copy link
Member

@iche033 I've made a prerelease of sdformat 9.3.0; to use prereleases in CI for this PR, we need the following: gazebo-tooling/gzdev#16

@scpeters
Copy link
Member

@osrf-jenkins run tests please

@scpeters
Copy link
Member

@osrf-jenkins run tests please

@scpeters
Copy link
Member

CI looks good with the prerelease, except for the slight decrease in code coverage

tpe/lib/src/Model.cc Show resolved Hide resolved
tpe/lib/src/Model.cc Outdated Show resolved Hide resolved
//////////////////////////////////////////////////
Entity &Model::GetCanonicalLink()
{
std::set<Model *> models;
Copy link
Member

Choose a reason for hiding this comment

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

will a std::set maintain the same order of nested models?

Copy link
Contributor Author

@iche033 iche033 Sep 2, 2020

Choose a reason for hiding this comment

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

I don't think so. Similarly, all the children (links and nested mdoels) in a TPE Model are stored in an std::map which also does not guarantee order. Will that be an issue?

Copy link
Member

Choose a reason for hiding this comment

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

the spec calls for the first link to be the canonical link if the attribute //model/@canonical_link is unspecified, so if this ignores the xml order then the choice of canonical link may not be consistent

it's a bit pedantic I guess. we can make an issue for it ("TPE canonical link choice may be inconsistent") instead of spending more time on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok I added some logic to mark the first link added to the model as the canonical link, and also added a todo note about handling (or preventing) removal of this link. The order in which the links are added should be consistent with the xml order so the canonical link should also be consistent now. d2a9481

Copy link
Member

Choose a reason for hiding this comment

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

the handling of links looks good now. for a model with no links and multiple nested models, I'm not sure that it will always pick the same model since it is storing them in a std::set, but I'm fine with adding a todo comment and opening an issue instead of iterating further

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good. Added note in 359ca9a and ticketed issue #100

@scpeters
Copy link
Member

scpeters commented Sep 3, 2020

I think we can ignore the abichecker failure, since it was not configured to use prereleases. It should be fixed by gazebo-tooling/release-tools#273, but we don't need to wait for that.

@chapulina chapulina mentioned this pull request Sep 3, 2020
Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

looks ok to me, though I haven't tested it

Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Sep 10, 2020

@osrf-jenkins run tests please

@iche033 iche033 merged commit 7ea8682 into ign-physics2 Sep 14, 2020
@iche033 iche033 deleted the tpe_nested_model branch September 14, 2020 19:44
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.

4 participants