-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Kinematic Features Signed-off-by: Lobotuerk <jtlorente@ekumenlabs.com>
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <ignition/common/Console.hh> | ||
#include "KinematicsFeatures.hh" | ||
|
||
namespace ignition { | ||
namespace physics { | ||
namespace bullet { | ||
|
||
///////////////////////////////////////////////// | ||
FrameData3d KinematicsFeatures::FrameDataRelativeToWorld( | ||
const FrameID &_id) const | ||
{ | ||
FrameData3d data; | ||
|
||
// The feature system should never send us the world ID. | ||
if (_id.IsWorld()) | ||
{ | ||
ignerr << "Given a FrameID belonging to the world. This should not be " | ||
<< "possible! Please report this bug!\n"; | ||
assert(false); | ||
return data; | ||
} | ||
|
||
const auto linkID = _id.ID(); | ||
|
||
if (this->links.find(linkID) == this->links.end()) | ||
{ | ||
ignerr << "Given a FrameID not belonging to a link.\n"; | ||
return data; | ||
} | ||
const auto &linkInfo = this->links.at(linkID); | ||
const auto &model = linkInfo->link; | ||
|
||
const btVector3 pos = model->getCenterOfMassTransform().getOrigin(); | ||
const btMatrix3x3 mat = model->getCenterOfMassTransform().getBasis(); | ||
|
||
auto eigenMat = convert(mat); | ||
auto eigenVec = convert(pos); | ||
|
||
data.pose.linear() = eigenMat; | ||
data.pose.translation() = eigenVec; | ||
|
||
// Add base velocities | ||
btVector3 omega = model->getAngularVelocity(); | ||
btVector3 vel = model->getLinearVelocity(); | ||
// Transform to world frame | ||
// const auto matBaseToWorld = btMatrix3x3(model->getWorldToBaseRot()).inverse(); | ||
// omega = matBaseToWorld * omega; | ||
// vel = matBaseToWorld * vel; | ||
|
||
data.linearVelocity = convert(vel); | ||
data.angularVelocity = convert(omega); | ||
|
||
// \todo(anyone) compute frame accelerations | ||
|
||
return data; | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef IGNITION_PHYSICS_BULLET_SRC_KINEMATICSFEATURES_HH_ | ||
#define IGNITION_PHYSICS_BULLET_SRC_KINEMATICSFEATURES_HH_ | ||
|
||
#include <ignition/physics/FrameSemantics.hh> | ||
#include <ignition/physics/FreeGroup.hh> | ||
|
||
#include "Base.hh" | ||
|
||
namespace ignition { | ||
namespace physics { | ||
namespace bullet { | ||
|
||
using KinematicsFeatureList = FeatureList< | ||
LinkFrameSemantics | ||
>; | ||
|
||
class KinematicsFeatures : | ||
public virtual Base, | ||
public virtual Implements3d<KinematicsFeatureList> | ||
{ | ||
public: FrameData3d FrameDataRelativeToWorld(const FrameID &_id) const; | ||
}; | ||
|
||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters