-
Notifications
You must be signed in to change notification settings - Fork 41
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
[dartsim] Add empty nested model construction and nested model entity management #228
Conversation
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
We do this by keeping track of links separately from DART so that APIs such as `Model::GetLink()` and `Link::GetIndex` are not affected by BodyNode's moving from one skeleton to another when a joint is created between different (nested) models. Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
…ties Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! I have a few comments, and also asked a few questions to help me get a better grasp of ign-physics
(I'm still trying to familiarize myself with the repository).
@@ -213,6 +213,56 @@ namespace ignition | |||
}; | |||
}; | |||
|
|||
///////////////////////////////////////////////// | |||
/// \brief This feature retrieves the nested model pointer from the parent | |||
/// model by specifying the model index and model index/name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// model by specifying the model index and model index/name. | |
/// model by specifying the parent model index and nested model index/name. |
I found it a little confusing to read "model index" twice - should one be referring to the parent model, and the other to the nested model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably supposed to say
/// \brief This feature retrieves the nested model pointer from the parent
/// model by specifying the index or name of the nested model.
From the user's point of view, the parent model does not need to be specified, so I would recommend not mentioning that in the public API documentation, as it may be misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to say "...name or index of the nested model". b836a0a
dartsim/src/SDFFeatures.cc
Outdated
return this->AddModel( // NOLINT | ||
{model, _sdfModel.Name(), modelFrame, _sdfModel.CanonicalLinkName()}, | ||
_parentID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this->AddModel( // NOLINT | |
{model, _sdfModel.Name(), modelFrame, _sdfModel.CanonicalLinkName()}, | |
_parentID); | |
return this->AddModel( // NOLINT | |
{model, _sdfModel.Name(), modelFrame, _sdfModel.CanonicalLinkName()}, | |
_parentID, worldID); |
I believe the world ID parameter is missing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not that worldID
is missing, but rather _parentID
should be replaced with worldID
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at the code further, it does appear to be correct, although I would urge some caution because the type of entity that _parentID
refers to is conditional. It may refer to a world or a model depending on whether the model that's being constructed is nested. This may be a strong recipe for some maintenance confusion and a future bug creeping in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is _parentID
and worldID
are the same if the model is not nested. But I agree it is confusing. I changed it to worldID
in 212c941.
This may be a strong recipe for some maintenance confusion and a future bug creeping in.
I agree. FWIW, this was done to avoid code duplication between ConstructSdfModel
and ConstructSdfNestedModel
where unlike ConstructEmptyNestedModel
, ConstructSdfNestedModel
is a feature that can construct a model and it's nested models from sdf::Model
. i.e, ConstructSdfNestedModel
is the same as ConstructSdfModel
but can also handle nested models if they exist in the input sdf::Model
.
/// Index of the model within this model. | ||
/// \return A model reference. If _index is GetModelCount() or higher, | ||
/// this will be a nullptr. | ||
public: ModelPtrType GetModel(std::size_t _index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest making this function more explicit by calling it GetNestedModel
. Same for the overloads of GetModel
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d137bba. Also made the same change to ConstructEmptyNestedModel
.
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
I believe I have addressed all the feedback. Please take a look. |
🎉 New feature
Summary
This adds two new features:
ConstructEmptyNestedModelFeature
, which allows users to create a nested model without having to useConstructSdfNestedModel
GetNestedModelFromModel
, which allow retrieving a nested model from it's parentModel
entity.Requires:
[dartsim] Fix joint construction errors due to link name duplication or BodyNodes moving to other skeletons #220[dartsim] Ensure Link and Model APIs continue to work after joint creation in DART #227Test it
Run tests
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge