Skip to content

Conversation

azeey
Copy link
Contributor

@azeey azeey commented Jul 25, 2025

🎉 New feature

Summary

This is necessary for use with the SetState API. This API is commonly used to create a local version of the servers ECM that is periodically synchronized. However, without exposing this function into our public API additions and removals of entities or components are not reflected in the local ECM.

Currently, we use friend relationships for the GuiRunner class to allow it to run these functions, but this is not feasible for external code that wants to use SetState.

// Make runners friends so that they can manage entity creation and
// removal. This should be safe since runners are internal
// to Gazebo.
friend class GuiRunner;
friend class SimulationRunner;

gz-sim/src/gui/GuiRunner.cc

Lines 316 to 318 in 5ce62a8

this->dataPtr->ecm.ClearRemovedComponents();
this->dataPtr->ecm.ClearNewlyCreatedEntities();
this->dataPtr->ecm.ProcessRemoveEntityRequests();

This is needed for gazebosim/ros_gz#790 to be able to get the updated state of the world, for example, when requested for the list of entities in the world after an entity has been removed.

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.)

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.

…d removal

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@azeey azeey requested a review from mjcarroll as a code owner July 25, 2025 19:10
@github-actions github-actions bot added the 🪵 jetty Gazebo Jetty label Jul 25, 2025
@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development Jul 25, 2025
@azeey azeey added this to the Jetty Release milestone Jul 28, 2025
@azeey azeey merged commit b2f3c82 into gazebosim:main Aug 18, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Core development Aug 18, 2025
azeey added a commit to azeey/gz-sim that referenced this pull request Aug 18, 2025
…d removal (gazebosim#3002)

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
@azeey
Copy link
Contributor Author

azeey commented Oct 16, 2025

@Mergifyio backport gz-sim9 gz-sim8

Backporting to Ionic and Harmonic to get gazebosim/ros_gz#790 backported all the way to Jazzy. See gazebosim/ros_gz#732 (comment)

@mergify
Copy link
Contributor

mergify bot commented Oct 16, 2025

backport gz-sim9 gz-sim8

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 16, 2025
…d removal (#3002)

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
(cherry picked from commit b2f3c82)
mergify bot pushed a commit that referenced this pull request Oct 16, 2025
…d removal (#3002)

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
(cherry picked from commit b2f3c82)
azeey added a commit that referenced this pull request Oct 16, 2025
…d removal (#3002)

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
(cherry picked from commit b2f3c82)
azeey added a commit that referenced this pull request Oct 16, 2025
…d removal (#3002)

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
(cherry picked from commit b2f3c82)
azeey added a commit that referenced this pull request Oct 17, 2025
…d removal (#3002)

This is necessary for use with the `SetState` API. This API is commonly
used to create a local version of the servers ECM that is periodically
synchronized. However, without exposing this function into our public API
additions and removals of entities or components are not reflected in the
local ECM.

Currently, we use `friend` relationships for the `GuiRunner` class to
allow it to run these functions, but this is not feasible for external
code that wants to use `SetState`.

https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/include/gz/sim/EntityComponentManager.hh#L834,
https://github.com/gazebosim/gz-sim/blob/5ce62a8826b930078fae940288ac9677aae9ec7b/src/gui/GuiRunner.cc#L316-L318

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
(cherry picked from commit b2f3c82)
@azeey azeey deleted the ecm_public_clear_state branch October 21, 2025 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪵 jetty Gazebo Jetty

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants