-
Notifications
You must be signed in to change notification settings - Fork 43
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
Resolve joints in nested models #464
Resolve joints in nested models #464
Conversation
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.
Thanks for the PR @srmainwaring. It looks like we were handling links in nested models properly for GetLink
, but not joints in nested models for GetJoint
. What do you think about storing a list of joints inside ModelInfo
the same way we store links
and nestedModels
?
Sure - that'd work and be consistent with the link handling. However with the links we still get a DART warning about renaming links when the nested model links are joined to the container model skeleton if there are any duplicated links (which is likely as most models will have a IIRC the link code uses a world scoped full name for the links. If the same approach is used for nested joints, what is the convention for referring to these joints from plugins? It might be useful to have a document describing the various use cases for referring to joint and link names in plugins for flat and nested models and the Gazebo teams recommendation of best practice. I expect that needs to be something that works for other physics engines as well and is not just driven by DART's particular treatment. |
As you can see in gz-physics/dartsim/src/Base.hh Lines 62 to 64 in 2a93515
We could do the same for joints. Also, I think you're right in that we should use fully qualified names when adding entities to DART to avoid this name collision. However, we don't want this to leak into the user API of gz-physics. Ideally, we'd store the original local (unscoped) names of links and joints and allow
It only uses the full names for other book keeping tasks. For
We currently don't support accessing links of a nested model from the grand parent model. The issue addressed by keeping links in |
Codecov Report
@@ Coverage Diff @@
## gz-physics6 #464 +/- ##
===============================================
+ Coverage 75.52% 75.56% +0.03%
===============================================
Files 142 142
Lines 7138 7190 +52
===============================================
+ Hits 5391 5433 +42
- Misses 1747 1757 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@azeey all makes sense. The PR for the I'll start drafting your suggested changes in this PR following the approach for links. |
- Use similar approach to links. - Add vector of JointInfo to ModelInfo. - Update Base::AddJoint - Update Base::RemoveModelImpl - Update calls to Base::AddJoint - Resolve modelID from modelInfo. - Resolve modelID from child link. - Move GetModelOfLinkImpl to Base to consolidate duplicated code. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
4411dc9
to
b4860f9
Compare
@azeey I've reworked the PR to use a similar approach to that used for links. The example provided above works. I've promoted a method GetModelOfLinkImpl to dartsim::Base as it's required in JointFeatures which does not subclass from EntityManagementFeatures. There is some further consolidation that can be done in JointFeatures to reduce duplicated code, but would appreciate your feedback that this is on the right track before further refinements. Update
I've pushed a change to I've added some debug tools and notes as well - to be removed once the behaviour is agreed. |
- Change SDFFeatures_TEST.cc to not find grandchild joint. - Add debug utils to base to verify mode structure (NB: to be removed before merge). Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
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've made some small comments, but the overall approach looks great!
- Review feedback - JointInfo.name is not required. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - replace loop in GetJoint with a lookup of the fully scoped name in jointsByName. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - keep note describing nested model structure. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - add extra test for joints in nested models. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Satisfy cpplint. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - fix comment. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - replace \todo comments with doc strings for debug utility functions. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - consolidate duplicated code to create a fully scoped joint name. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
Hi @azeey - I think this PR now includes all the changes you requested and has been tidied up. Is there anything else you'd like completed to get this merged? |
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.
Just a couple of small comments. Otherwise, LGTM!
- Review feedback - remove unused variable from FullyScopedJointName. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Review feedback - replace duplicated code with call to FullyScopedJointName. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Fix build warning - remove unused variable. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
🦟 Bug fix
Fixes gz-sim: #1844
Summary
The details of the bug and how to reproduce it are documented in gz-sim: #1844.
In brief: joints in nested models were not being found correctly by the function
EntityManagementFeatures::GetJoint
which resulted in thePhysics
system plugin ingz-sim
not reporting the joint position and not begin able to actuate the joint.The change handles the three cases:
There is also an issue where DART renames joints in nested models that have duplicate unscoped names. DART expects all names for a given skeleton (= gazebo model) to be unique. It is not practical to expect all Gazebo models to use different names, so we elected to register the joints for nested models using their top-level model scoped names. It may be worth doing this for links and collisions to avoid warnings such as:
but this would be for a separate PR.
An updated version of the test world is attached: test_nested_model.sdf.zip. Note: the tests were carried out using a modified version of the JointPositionController that handles nested models by searching for joints with scoped names. This modification will be submitted in
gz-sim
as a separate PR.The joints are moved from the command line using:
Figure:
test_nested_model.sdf
showing all joints repositioned using the joint position controller plugin.Testing (Updated)
There was one test failure in
SDFFeatures_TEST
(L601-L607). The test expected querying a parent model for a joint contained in a nested model to return a non-null pointer. However querying a parent for a grandchild joint should return null in the Gazebo interface even if DART moves the grand child joint to the parent.Checklist
codecheck
passed (See contributing)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.