Skip to content

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Jul 29, 2025

🎉 New feature

Summary

Requires gazebosim/gz-physics#764

Allow to enable/disable gravity and static state

Test it

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-by: Remove this if GenAI was not used.

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
@ahcorde ahcorde self-assigned this Jul 29, 2025
@ahcorde ahcorde requested review from azeey and mjcarroll as code owners July 29, 2025 12:46
@github-actions github-actions bot added the 🎵 harmonic Gazebo Harmonic label Jul 29, 2025
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@ahcorde ahcorde requested a review from arjo129 as a code owner August 18, 2025 15:36
@@ -41,6 +41,10 @@ namespace components
using GravityEnabled = Component<bool, class GravityEnabledTag>;
GZ_SIM_REGISTER_COMPONENT(
"gz_sim_components.GravityEnabled", GravityEnabled)

/// \brief Store the gravity acceleration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Update indentation. Also, is the comment correct? I'd expect something about store whether we want to enable gravity or not.


/// \brief Set a new state to change the model's gravity.
/// \param[in] _ecm Entity-component manager.
/// \param[in] _gravity New model state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace _gravity with _enabled?

/// deleted the following iteration.
public: std::unordered_set<Entity> staticStateCmdsToRemove;

public: std::unordered_set<Entity> gravityEnabledCmdsToRemove;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doxygen.


//////////////////////////////////////////////////
// enabled gravity
/// \brief Feature list for model static state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment.

@@ -2101,6 +2122,30 @@ void PhysicsPrivate::RemovePhysicsEntities(const EntityComponentManager &_ecm)
void PhysicsPrivate::UpdatePhysics(EntityComponentManager &_ecm)
{
GZ_PROFILE("PhysicsPrivate::UpdatePhysics");

// _ecm.Each<components::Model, components::Name, components::Static>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this block?

@@ -2743,6 +2923,7 @@ void PhysicsPrivate::ResetPhysics(EntityComponentManager &_ecm)
this->canonicalLinkModelTracker = CanonicalLinkModelTracker();
this->modelWorldPoses.clear();
this->worldPoseCmdsToRemove.clear();
this->staticStateCmdsToRemove.clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also clear gravityEnabledCmdStoreremove?

void Model::SetStaticStateCmd(EntityComponentManager &_ecm,
bool _state)
{
std::cout << "SetStaticState " << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

@@ -219,6 +220,44 @@ void Model::SetWorldPoseCmd(EntityComponentManager &_ecm,
}
}

void Model::SetStaticStateCmd(EntityComponentManager &_ecm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add //////////////////////////////////////////////////

}
}

void Model::SetGravityEnabledCmd(EntityComponentManager &_ecm,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add //////////////////////////////////////////////////

void Model::SetGravityEnabledCmd(EntityComponentManager &_ecm,
bool _enabled)
{
std::cout << "SetGravityEnabledCmd " << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Status: Inbox
Development

Successfully merging this pull request may close these issues.

2 participants