Skip to content

Commit

Permalink
Merge from ign-gazebo6
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jun 26, 2024
2 parents d9bc3bd + ca1b626 commit dc83c33
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
5 changes: 5 additions & 0 deletions include/gz/sim/components/Gravity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ namespace components
/// \brief Store the gravity acceleration.
using Gravity = Component<math::Vector3d, class GravityTag>;
GZ_SIM_REGISTER_COMPONENT("gz_sim_components.Gravity", Gravity)

/// \brief Store the gravity acceleration.
using GravityEnabled = Component<bool, class GravityEnabledTag>;
GZ_SIM_REGISTER_COMPONENT(
"gz_sim_components.GravityEnabled", GravityEnabled)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,9 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Link *_link)

if (!_link->EnableGravity())
{
// If disable gravity, create a gravity component to the entity
// This gravity will have value 0,0,0
// If disable gravity, create a GravityEnabled component to the entity
this->dataPtr->ecm->CreateComponent(
linkEntity, components::Gravity());
linkEntity, components::GravityEnabled(false));
}

// Visuals
Expand Down
19 changes: 5 additions & 14 deletions src/systems/physics/Physics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1307,21 +1307,12 @@ void PhysicsPrivate::CreateLinkEntities(const EntityComponentManager &_ecm,
}

// get link gravity
const components::Gravity *gravity =
_ecm.Component<components::Gravity>(_entity);
if (nullptr != gravity)
const components::GravityEnabled *gravityEnabled =
_ecm.Component<components::GravityEnabled>(_entity);
if (nullptr != gravityEnabled)
{
// Entity has a gravity component that is all zeros when
// <gravity> is set to false
// See SdfEntityCreator::CreateEntities()
if (gravity->Data() == math::Vector3d::Zero)
{
link.SetEnableGravity(false);
}
else
{
link.SetEnableGravity(true);
}
// gravityEnabled set in SdfEntityCreator::CreateEntities()
link.SetEnableGravity(gravityEnabled->Data());
}

auto constructLinkFeature =
Expand Down

0 comments on commit dc83c33

Please sign in to comment.