Skip to content

Commit

Permalink
[bullet-featherstone] Fix attaching fixed joint (#610)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Mar 23, 2024
1 parent 7d30e47 commit a86da62
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion bullet-featherstone/src/JointFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,11 @@ void JointFeatures::SetJointTransformFromParent(

if (jointInfo->fixedConstraint)
{
auto tf = convertTf(_pose);
jointInfo->fixedConstraint->setPivotInA(
convertVec(_pose.translation()));
tf.getOrigin());
jointInfo->fixedConstraint->setFrameInA(
tf.getBasis());
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/common_test/joint_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,8 @@ TYPED_TEST(JointFeaturesAttachDetachTest, JointAttachDetach)
auto frameDataModel1Body = model1Body->FrameDataRelativeToWorld();
auto frameDataModel2Body = model2Body->FrameDataRelativeToWorld();

const gz::math::Pose3d initialModel1Pose(0, 0, 0.25, 0, 0, 0);
const gz::math::Pose3d initialModel2Pose(0, 0, 3.0, 0, 0, 0);
const gz::math::Pose3d initialModel1Pose(0, 0, 0.25, 0, 0, 0.1);
const gz::math::Pose3d initialModel2Pose(0, 0, 3.0, 0, 0, 0.2);

EXPECT_EQ(initialModel1Pose,
gz::math::eigen3::convert(frameDataModel1Body.pose));
Expand Down Expand Up @@ -1133,14 +1133,14 @@ TYPED_TEST(JointFeaturesAttachDetachTest, JointAttachDetach)

// After a while, body2 should reach the ground and come to a stop
std::size_t stepCount = 0u;
const std::size_t maxNumSteps = 1000u;
const std::size_t maxNumSteps = 2000u;
while (stepCount++ < maxNumSteps)
{
world->Step(output, state, input);
frameDataModel2Body = model2Body->FrameDataRelativeToWorld();
// Expected Z height of model2 is 0.75 when both boxes are stacked on top
// of each other since each is 0.5 high.
if (fabs(frameDataModel2Body.pose.translation().z() - 0.75) < 2e-2 &&
if (fabs(frameDataModel2Body.pose.translation().z() - 0.75) < 1e-2 &&
fabs(frameDataModel2Body.linearVelocity.z()) < 1e-3)
{
break;
Expand Down
4 changes: 2 additions & 2 deletions test/common_test/worlds/joint_across_models.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</model>

<model name="M1">
<pose>0 0 0.25 0 0.0 0</pose>
<pose>0 0 0.25 0 0.0 0.1</pose>
<link name="body">
<inertial>
<inertia>
Expand Down Expand Up @@ -65,7 +65,7 @@
</link>
</model>
<model name="M2">
<pose>0 0 3.0 0 0.0 0</pose>
<pose>0 0 3.0 0 0.0 0.2</pose>
<link name="body">
<inertial>
<inertia>
Expand Down

0 comments on commit a86da62

Please sign in to comment.