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

Set a cloned joint's parent/child link names to the cloned parent/child link names #1075

Merged
merged 4 commits into from
Oct 5, 2021

Conversation

adlarkin
Copy link
Contributor

@adlarkin adlarkin commented Oct 1, 2021

Signed-off-by: Ashton Larkin [email protected]

🦟 Bug fix

Summary

When a joint is cloned, the cloned joint's parent and child links need to be set to the cloned parent and child links (currently, the cloned joint's parent/child links are the original joint's parent/child links). Otherwise, links will not be connected to joints when cloning things like models that have links and joints.

The approach taken here is similar to the approach taken for updating a cloned canonical link in #959, where internal maps are used to keep track of a joint's original links and cloned links. As discussed in #959 (comment), we shouldn't give special treatment to certain components. This is just a temporary workaround until we find a better solution.

To test this, do the following:

  1. Start gazebo with a double pendulum, since this model has links and joints:
ign gazebo -r pendulum_links.sdf
  1. In another terminal window, clone the double pendulum:
ign service -s /world/double_pendulum/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 300 --req 'clone_name: "double_pendulum_with_base", pose: {position: {y: 3}}, name: "pendulum_copy"'
  1. You should now see two pendulums operating as expected:

functioning_joints

If you repeat the steps above without this PR, you'll notice that the links on the cloned pendulum fall to the ground because the cloned pendulum does not have proper joints:

bad_joints_clone

Checklist

  • Signed all commits for DCO
  • Added tests
  • 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

Signed-off-by: Ashton Larkin <[email protected]>
@adlarkin adlarkin requested a review from chapulina as a code owner October 1, 2021 02:40
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Oct 1, 2021
@adlarkin adlarkin added the beta Targeting beta release of upcoming collection label Oct 1, 2021
Comment on lines +262 to +264
/// \TODO(anyone) We shouldn't be giving joints special treatment.
/// We should figure out a way to update a joint's parent/child links without
/// having to explicitly search/track for the cloned links.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a similar TODO note here: https://github.com/ignitionrobotics/ign-gazebo/blob/8f083d6d212c5867cc18cd45162ba3e4807643c4/src/EntityComponentManager.cc#L248-L250

I don't think we have an issue for tracking the idea of "generalizable component cloning" yet, do we? Should we create one?

@adlarkin adlarkin mentioned this pull request Oct 1, 2021
8 tasks
@azeey
Copy link
Contributor

azeey commented Oct 1, 2021

Detachable joints also contain information about parent and child links. Should we add those as well or state that they're not supported?

@codecov
Copy link

codecov bot commented Oct 1, 2021

Codecov Report

Merging #1075 (cb681b8) into ign-gazebo6 (30c6df0) will decrease coverage by 0.02%.
The diff coverage is 67.34%.

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

@@               Coverage Diff               @@
##           ign-gazebo6    #1075      +/-   ##
===============================================
- Coverage        64.09%   64.07%   -0.03%     
===============================================
  Files              255      255              
  Lines            20002    20051      +49     
===============================================
+ Hits             12821    12847      +26     
- Misses            7181     7204      +23     
Impacted Files Coverage Δ
include/ignition/gazebo/EntityComponentManager.hh 100.00% <ø> (ø)
src/EntityComponentManager.cc 84.22% <67.34%> (-1.13%) ⬇️
src/gui/plugins/plot_3d/Plot3D.cc 43.47% <0.00%> (-4.35%) ⬇️

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 30c6df0...3dbbf5a. Read the comment docs.

@adlarkin adlarkin changed the title Fix cloning joints Set a cloned joint's parent/child link names to the cloned parent/child link names Oct 1, 2021
@adlarkin adlarkin removed the beta Targeting beta release of upcoming collection label Oct 1, 2021
@adlarkin
Copy link
Contributor Author

adlarkin commented Oct 1, 2021

Detachable joints also contain information about parent and child links. Should we add those as well or state that they're not supported?

As we discussed offline, adding support for cloning detachable joints would require cloning the DetachableJoint system. So, for now, I have made a note in the documentation that cloning detachable joints is not supported: b557328

I've also created an issue for adding detachable joint cloning support so that we can re-visit this in the future: #1080

@adlarkin adlarkin changed the base branch from main to ign-gazebo6 October 4, 2021 20:46
Copy link
Contributor

@nkoenig nkoenig left a comment

Choose a reason for hiding this comment

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

Just one minor comment.

@adlarkin adlarkin merged commit 447e5c2 into ign-gazebo6 Oct 5, 2021
@adlarkin adlarkin deleted the adlarkin/clone_links_joints branch October 5, 2021 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants