-
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: support non-tree kinematics in AttachFixedJoint #352
Conversation
In gazebo classic, kinematic loops are closed by identifying a link with multiple parents and creating a mirror body node that is welded to the original. The inertia will be split evenly between the body nodes. This change adds data to store the welded mirror nodes, the weld constraints, and the original inertial data. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
To support closing kinematic loops. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
If the child link already has a parent, split the link and weld the new node to the original node. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Codecov Report
@@ Coverage Diff @@
## ign-physics5 #352 +/- ##
===============================================
Coverage ? 76.35%
===============================================
Files ? 129
Lines ? 5810
Branches ? 0
===============================================
Hits ? 4436
Misses ? 1374
Partials ? 0 Continue to review full report at Codecov.
|
Signed-off-by: Arjo Chakravarty <arjo@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.
I've added the unit tests in but they do not pass. Neither does the down stream pr in osrf/mbzirc#108 work. I'm not too sure whats wrong with it. Either ways I'm not on mbzirc right now. I believe @aaronchongth is taking over this aspect of it.
I might be wrong, but could the unit test that was ported over not be related to kinetic loops since both the parents of the added fixed joints are free floating and not attached to each other? |
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
I think the test is ok. It may not precisely be a "loop", but it doesn't follow the tree structure because the middle box will have two parents after attaching the fixed joints. I think I have a fix in 21a608d |
I've updated the description and marked this ready for review |
Thanks for explaining @scpeters ! Attaching works like a charm! I am having trouble detaching the models though, it looks like one of the models will refuse to detach. detach_and_stuck-2022-06-10_11.55.40.mp4It looks like the first parent that attaches, is unable to detach afterwards, but the second parent is free to attach and detach. After detaching, both the still-attached parent and the model will be stuck in space somehow, until the other previously detached parent bumps into it. I tried dropping shapes onto the stuck platform, but it doesn't budge. |
This exposes a current test failures Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
After testing it more downstream, I faced some interesting behaviors when detaching the models one after another. Consistently, detaching one of the joints does not seem to do anything, while detaching the other one causes both to be detached. detach_1.mp4detach_2.mp4I duplicated the test in this PR to detach one at a time, but could not seem to replicate this behvaior. I was wondering if you knew what might be the cause? |
I looked into this a bit and turns out that it's a downstream issue. We are generating the same detach topic name for both UAVs (one overriding another). So something to be fixed on our end. |
ok, I've also done some testing and if I only detach one joint, I would expect both boxes to fall, but only one is doing so. There may still be issues in the Detaching functionality here |
@aaronchongth was also able to reproduce the issue. Once the joint between a drone and an object is detached, we noticed that the drone is able to continue flying but the object remains static. Let us know if there's anything we can help here. |
I've tried debugging it, but I may need some advice from @mxgrey and @azeey about how to figure out what is going on |
Just a random thought: I don't see us removing the WeldConstraint in the detach function. Does this have something to do with it. |
I haven't looked at the code yet, but based on the conversation I might suspect that if the I'll take a look to check my hypothesis later today. |
Like @arjo129 suggested, I don't see What I would suggest is to maintain a hash map of All that being said, it's worth noting that this link splitting technique is not actually needed for this PR. The ordinary way of using the weld constraint would completely suffice for I might suggest reworking this PR so that the link splitting logic gets applied to all the joint types instead of just the fixed joint. Otherwise it would be much cleaner to just remove the link splitting entirely. |
I've merged #367 into this branch, so I think this is ready for re-review |
tested and confirmed that this PR works for us. I'll leave it to @azeey to give the final blessing. |
const auto poseParent2 = dartBody3->getTransform(); | ||
const auto poseChild2 = dartBody2->getTransform(); | ||
auto poseParentChild2 = poseParent2.inverse() * poseChild2; | ||
auto fixedJoint2 = model2Body->AttachFixedJoint(model3Body); |
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 would be great to add test expectations on the resulting masses after a WeldJointConstraint is created and destroyed, but feel free to punt for now.
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'll do this in a follow-up
🦟 Bug fix
Alternative to #345 and #347
Summary
With inspiration from #345 and #347, this implements a variation on the approach from gazebo-classic for handling non-tree kinematics (including kinematic loops) with the reduced coordinate Featherstone formulation by splitting links and welding them back together with a constraint. This adds data to the
LinkInfo
struct and aSplitAndWeldLink
helper function toBase.hh
. The test made by @arjo129 is included as well.This only implements support for kinematic loops in the
AttachFixedJoint
method, but it should be applicable in otherAttach*Joint
methods and theConstructSdfJoint
method to support non-tree kinematics in more cases.This implementation differs slightly from the approach in gazebo-classic. In gazebo11, all joints that are created dynamically using gazebo::physics::Model::CreateJoint use the approach of splitting and welding a link, even if the joint could simply be added as part of the existing Skeleton (see the call to
DARTModelPrivate::CreateLoopJointAndNodePair
inDARTModel::CreateJointHelper
in DARTModel.cc). Within DARTModlPrivate::CreateLoopJointAndNodePair, a new joint and node pair are created for the desired joint type by callingDARTModelPrivate::CreateJointAndNodePair
and then welded to the desired child link with blended inertia by callingDARTLink::AddSlaveBodyNode
.In this implementation, the split-and-weld approach is only taken if the target child link already has a parent joint that is not FreeJoint. To minimize changes to the existing code, when an existing parent joint is detected, the split-and-weld is done first, by creating a new FreeJoint and node pair and passing it to the
SplitAndWeldLink
helper function, which blends the inertia between the nodes and creates a WeldJointConstraint. The newly welded body node is then moved to a WeldJoint using themoveTo
API. This move requires the transform for the WeldJointConstraint to be updated to ensure consistency.UPDATE: with thanks to @azeey for the changes in #367, the welded links are now properly removed when joints are detached.
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.