-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lobotuerk <jtlorente@ekumenlabs.com>
- Loading branch information
Showing
5 changed files
with
114 additions
and
5 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
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,67 @@ | ||
#include "FreeGroupFeatures.hh" | ||
|
||
namespace ignition { | ||
namespace physics { | ||
namespace bullet { | ||
|
||
///////////////////////////////////////////////// | ||
Identity FreeGroupFeatures::FindFreeGroupForModel( | ||
const Identity &_modelID) const | ||
{ | ||
const auto &model = this->models.at(_modelID); | ||
|
||
// If there are no links at all in this model, then the FreeGroup functions | ||
// will not work properly, so we'll just reject these cases. | ||
if (model->links.size() == 0) | ||
return this->GenerateInvalidId(); | ||
|
||
// Reject also if the model has fixed base | ||
if (model->fixed) | ||
return this->GenerateInvalidId(); | ||
|
||
return _modelID; | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
Identity FreeGroupFeatures::FindFreeGroupForLink( | ||
const Identity &_linkID) const | ||
{ | ||
const auto &link_it = this->links.find(_linkID); | ||
|
||
if (link_it != this->links.end() && link_it->second != nullptr) | ||
return this->GenerateIdentity(_linkID.id, link_it->second); | ||
return this->GenerateInvalidId(); | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
Identity FreeGroupFeatures::GetFreeGroupCanonicalLink( | ||
const Identity &_groupID) const | ||
{ | ||
(void) _groupID; | ||
// Todo(Lobotuerk) implement canonical links | ||
return this->GenerateInvalidId(); | ||
} | ||
|
||
///////////////////////////////////////////////// | ||
void FreeGroupFeatures::SetFreeGroupWorldPose( | ||
const Identity &_groupID, | ||
const PoseType &_pose) | ||
{ | ||
// Convert pose | ||
const auto poseTranslation = _pose.translation(); | ||
const auto poseLinear = _pose.linear(); | ||
btTransform baseTransform; | ||
baseTransform.setOrigin(convertVec(poseTranslation)); | ||
baseTransform.setBasis(convertMat(poseLinear)); | ||
|
||
// Set base transform | ||
const auto &model = this->models.at(_groupID); | ||
for (auto link : model->links) | ||
{ | ||
this->links.at(link)->link->setCenterOfMassTransform(baseTransform); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
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,38 @@ | ||
#ifndef IGNITION_PHYSICS_BULLET_SRC_FREEGROUPFEATURES_HH_ | ||
#define IGNITION_PHYSICS_BULLET_SRC_FREEGROUPFEATURES_HH_ | ||
|
||
#include <ignition/physics/FreeGroup.hh> | ||
|
||
#include "Base.hh" | ||
|
||
namespace ignition { | ||
namespace physics { | ||
namespace bullet { | ||
|
||
using FreeGroupFeatureList = FeatureList< | ||
FindFreeGroupFeature, | ||
SetFreeGroupWorldPose | ||
>; | ||
|
||
class FreeGroupFeatures | ||
: public virtual Base, | ||
public virtual Implements3d<FreeGroupFeatureList> | ||
{ | ||
// ----- FindFreeGroupFeature ----- | ||
Identity FindFreeGroupForModel(const Identity &_modelID) const override; | ||
|
||
Identity FindFreeGroupForLink(const Identity &_linkID) const override; | ||
|
||
Identity GetFreeGroupCanonicalLink(const Identity &_groupID) const override; | ||
|
||
// ----- SetFreeGroupWorldPose ----- | ||
void SetFreeGroupWorldPose( | ||
const Identity &_groupID, | ||
const PoseType &_pose) override; | ||
}; | ||
|
||
} | ||
} | ||
} | ||
|
||
#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
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