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

bullet-featherstone: Fix joint frame data pose #650

Open
wants to merge 1 commit into
base: bullet_kinematic_feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bullet-featherstone/src/KinematicsFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
const auto index = _linkInfo->indexInModel.value();
FrameData3d data;
data.pose = GetWorldTransformOfLink(*_modelInfo, *_linkInfo);

const auto &link = _modelInfo->body->getLink(index);
data.linearVelocity = convert(link.m_absFrameTotVelocity.getLinear());
data.angularVelocity = convert(link.m_absFrameTotVelocity.getAngular());
Expand All @@ -41,8 +42,10 @@
{
bool isModel = false;
bool isCollision = false;
bool isJoint = false;
const ModelInfo *model = nullptr;
Eigen::Isometry3d collisionPoseOffset = Eigen::Isometry3d();
Eigen::Isometry3d jointPoseOffset = Eigen::Isometry3d();

const auto linkIt = this->links.find(_id.ID());
if (linkIt != this->links.end())
Expand All @@ -63,16 +66,20 @@
auto jointIt = this->joints.find(_id.ID());
if (jointIt != this->joints.end())
{
isJoint = true;
const auto &jointInfo = jointIt->second;

const auto linkIt2 = this->links.find(jointInfo->childLinkID);
if (linkIt2 != this->links.end())
{
const auto &linkInfo2 = linkIt2->second;
model = this->ReferenceInterface<ModelInfo>(linkInfo2->model);
jointPoseOffset = jointInfo->tf_to_child.inverse();
if (linkInfo2->indexInModel.has_value())
{
return getNonBaseLinkFrameData(model, linkInfo2.get());
auto data = getNonBaseLinkFrameData(model, linkInfo2.get());
data.pose = data.pose * jointPoseOffset;
return data;
}
}
}
Expand Down Expand Up @@ -125,6 +132,8 @@
}
else if (isCollision)
data.pose = data.pose * collisionPoseOffset;
else if (isJoint)
data.pose = data.pose * jointPoseOffset;

Check warning on line 136 in bullet-featherstone/src/KinematicsFeatures.cc

View check run for this annotation

Codecov / codecov/patch

bullet-featherstone/src/KinematicsFeatures.cc#L136

Added line #L136 was not covered by tests
data.linearVelocity = convert(model->body->getBaseVel());
data.angularVelocity = convert(model->body->getBaseOmega());
}
Expand Down
18 changes: 3 additions & 15 deletions test/common_test/kinematic_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,9 @@ TYPED_TEST(KinematicFeaturesTest, JointFrameSemantics)

auto childLinkFrameData = childLink->FrameDataRelativeToWorld();
EXPECT_EQ(
F_WCexpected.pose.rotation(),
childLinkFrameData.pose.rotation());
// TODO(ahcorde): Review this in bullet-featherstone
if (this->PhysicsEngineName(name) != "bullet-featherstone")
{
EXPECT_NEAR(
F_WCexpected.pose.translation().x(),
childLinkFrameData.pose.translation().x(), 1e-6);
EXPECT_NEAR(
F_WCexpected.pose.translation().y(),
childLinkFrameData.pose.translation().y(), 1e-6);
EXPECT_NEAR(
F_WCexpected.pose.translation().z(),
childLinkFrameData.pose.translation().z(), 1e-6);
}
gz::math::eigen3::convert(F_WCexpected.pose),
gz::math::eigen3::convert(childLinkFrameData.pose));

EXPECT_TRUE(
gz::physics::test::Equal(
F_WCexpected.linearVelocity,
Expand Down
Loading