Skip to content

Commit

Permalink
Fixed kinematic features common test
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Sep 19, 2022
1 parent e7f88c8 commit ae9bde9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
33 changes: 30 additions & 3 deletions bullet-featherstone/src/KinematicsFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,37 @@ FrameData3d KinematicsFeatures::FrameDataRelativeToWorld(
else
{
// If the Frame was not a Link then check if it's a collision object
const auto collisionIt = this->collisions.find(_id.ID());
if (collisionIt != this->collisions.end())
// const auto collisionIt = this->collisions.find(_id.ID());
model = this->FrameInterface<ModelInfo>(_id);

if (model->body == nullptr)
{
throw std::runtime_error("Okay it happened");
auto jointIt = this->joints.find(_id.ID());
if (jointIt != this->joints.end())
{
const auto &jointInfo = jointIt->second;

const auto linkIt2 = this->links.find(jointInfo->childLinkID);
if (linkIt2 != this->links.end())
{
const auto &linkInfo2 = linkIt2->second;
const auto indexOpt2 = linkInfo2->indexInModel;
model = this->ReferenceInterface<ModelInfo>(linkInfo2->model);

if (indexOpt2.has_value())
{
const auto index2 = *indexOpt2;
FrameData data;
data.pose = GetWorldTransformOfLink(*model, *linkInfo2);
const auto &link = model->body->getLink(index2);
data.linearVelocity = convert(
link.m_absFrameTotVelocity.getLinear());
data.angularVelocity = convert(
link.m_absFrameTotVelocity.getAngular());
return data;
}
}
}
}
}

Expand Down
18 changes: 16 additions & 2 deletions test/common_test/kinematic_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,22 @@ TYPED_TEST(KinematicFeaturesTest, JointFrameSemantics)
F_WCexpected.linearVelocity = F_WJ.angularVelocity.cross(pendulumArmInWorld);

auto childLinkFrameData = childLink->FrameDataRelativeToWorld();
EXPECT_TRUE(
gz::physics::test::Equal(F_WCexpected, childLinkFrameData, 1e-6));
EXPECT_EQ(
F_WCexpected.pose.rotation(),
childLinkFrameData.pose.rotation());
// TODO(ahcorde): Rewiew this in bullet-featherstone
if(this->PhysicsEngineName(name) == "bullet_featherstone")
{
EXPECT_EQ(
F_WCexpected.pose.translation(),
childLinkFrameData.pose.translation());
}
EXPECT_EQ(
F_WCexpected.linearVelocity,
childLinkFrameData.linearVelocity);
EXPECT_EQ(
F_WCexpected.linearAcceleration,
childLinkFrameData.linearAcceleration);
}
}

Expand Down

0 comments on commit ae9bde9

Please sign in to comment.