Skip to content

Commit

Permalink
[BULLET] Making GetContactsFromLastStepFeature optional in Collision …
Browse files Browse the repository at this point in the history
…Features (#690)

* GetContactsFromLastStepFeature made optional

Signed-off-by: Tomas Lorente <jtlorente@ekumenlabs.com>

Co-authored-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
Lobotuerk and azeey authored Mar 19, 2021
1 parent 778ff85 commit a84ec51
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/systems/physics/Physics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,20 @@ class ignition::gazebo::systems::PhysicsPrivate
/// \brief Feature list to handle collisions.
public: struct CollisionFeatureList : ignition::physics::FeatureList<
MinimumFeatureList,
ignition::physics::GetContactsFromLastStepFeature,
ignition::physics::sdf::ConstructSdfCollision>{};

/// \brief Feature list to handle contacts information.
public: struct ContactFeatureList : ignition::physics::FeatureList<
CollisionFeatureList,
ignition::physics::GetContactsFromLastStepFeature>{};

/// \brief Collision type with collision features.
public: using ShapePtrType = ignition::physics::ShapePtr<
ignition::physics::FeaturePolicy3d, CollisionFeatureList>;

/// \brief World type with just the minimum features. Non-pointer.
public: using WorldShapeType = ignition::physics::World<
ignition::physics::FeaturePolicy3d, CollisionFeatureList>;
ignition::physics::FeaturePolicy3d, ContactFeatureList>;

//////////////////////////////////////////////////
// Collision filtering with bitmasks
Expand Down Expand Up @@ -373,6 +377,7 @@ class ignition::gazebo::systems::PhysicsPrivate
physics::World,
MinimumFeatureList,
CollisionFeatureList,
ContactFeatureList,
NestedModelFeatureList>;

/// \brief A map between world entity ids in the ECM to World Entities in
Expand Down Expand Up @@ -420,6 +425,7 @@ class ignition::gazebo::systems::PhysicsPrivate
public: using EntityCollisionMap = EntityFeatureMap3d<
physics::Shape,
CollisionFeatureList,
ContactFeatureList,
CollisionMaskFeatureList,
FrictionPyramidSlipComplianceFeatureList
>;
Expand Down Expand Up @@ -2157,14 +2163,14 @@ void PhysicsPrivate::UpdateCollisions(EntityComponentManager &_ecm)
}

auto worldCollisionFeature =
this->entityWorldMap.EntityCast<CollisionFeatureList>(worldEntity);
this->entityWorldMap.EntityCast<ContactFeatureList>(worldEntity);
if (!worldCollisionFeature)
{
static bool informed{false};
if (!informed)
{
igndbg << "Attempting process contacts, but the physics "
<< "engine doesn't support collision features. "
<< "engine doesn't support contact features. "
<< "Contacts won't be computed."
<< std::endl;
informed = true;
Expand All @@ -2191,8 +2197,10 @@ void PhysicsPrivate::UpdateCollisions(EntityComponentManager &_ecm)
for (const auto &contactComposite : allContacts)
{
const auto &contact = contactComposite.Get<WorldShapeType::ContactPoint>();
auto coll1Entity = this->entityCollisionMap.Get(contact.collision1);
auto coll2Entity = this->entityCollisionMap.Get(contact.collision2);
auto coll1Entity =
this->entityCollisionMap.Get(ShapePtrType(contact.collision1));
auto coll2Entity =
this->entityCollisionMap.Get(ShapePtrType(contact.collision2));


if (coll1Entity != kNullEntity && coll2Entity != kNullEntity)
Expand Down

0 comments on commit a84ec51

Please sign in to comment.