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

testing world pose function #80

Merged
merged 1 commit into from
Jul 10, 2020
Merged
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
9 changes: 9 additions & 0 deletions tpe/lib/src/Entity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ math::Pose3d Entity::GetPose() const
return this->dataPtr->pose;
}

//////////////////////////////////////////////////
math::Pose3d Entity::GetWorldPose() const
{
if (this->dataPtr->parent)
return this->dataPtr->pose + this->dataPtr->parent->GetWorldPose();

return this->dataPtr->pose;
}

//////////////////////////////////////////////////
void Entity::SetId(std::size_t _id)
{
Expand Down
6 changes: 5 additions & 1 deletion tpe/lib/src/Entity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ class IGNITION_PHYSICS_TPELIB_VISIBLE Entity
public: virtual void SetPose(const math::Pose3d &_pose);

/// \brief Get the pose of the entity
/// \return Pose of entity to set to
/// \return Pose of entity
public: virtual math::Pose3d GetPose() const;

/// \brief Get the world pose of the entity
/// \return World pose of entity
public: virtual math::Pose3d GetWorldPose() const;

/// \brief Get a child entity by id
/// \param[in] _id Id of child entity
/// \return Child entity
Expand Down
10 changes: 10 additions & 0 deletions tpe/lib/src/Link_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "Collision.hh"
#include "Link.hh"
#include "Model.hh"

using namespace ignition;
using namespace physics;
Expand Down Expand Up @@ -47,6 +48,15 @@ TEST(Link, BasicAPI)
EXPECT_EQ(math::Pose3d(10, -0.312675, 2.43845, 1.23686, 0.471978, 0.918989),
link.GetPose());

Model model;
model.SetPose(modelPose);
Entity &linkEnt = model.AddLink();
linkEnt.SetPose(math::Pose3d(0, 0.2, 0.5, 0, 1, 0));
EXPECT_EQ(math::Pose3d(10, -0.312675, 2.43845, 1.23686, 0.471978, 0.918989),
link.GetWorldPose());

// std::cerr << "link entity world pose " << linkEnt.GetWorldPose() << std::endl;

Link link2;
EXPECT_NE(link.GetId(), link2.GetId());
}
Expand Down