Skip to content

Commit

Permalink
Send state message when components are removed
Browse files Browse the repository at this point in the history
Signed-off-by: Nate Koenig <[email protected]>
  • Loading branch information
Nate Koenig committed Dec 6, 2021
1 parent f292777 commit 025bb3f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/ignition/gazebo/EntityComponentManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ namespace ignition
/// \param[in] _offset Offset value.
public: void SetEntityCreateOffset(uint64_t _offset);

/// \brief Return true if there are components marked for removal.
/// \return True if there are components marked for removal.
public: bool HasRemovedComponents() const;

/// \brief Clear the list of newly added entities so that a call to
/// EachAdded after this will have no entities to iterate. This function
/// is protected to facilitate testing.
Expand Down
7 changes: 7 additions & 0 deletions src/EntityComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,13 @@ void EntityComponentManager::ClearNewlyCreatedEntities()
}
}

/////////////////////////////////////////////////
bool EntityComponentManager::HasRemovedComponents() const
{
std::lock_guard<std::mutex> lock(this->dataPtr->removedComponentsMutex);
return !this->dataPtr->removedComponents.empty();
}

/////////////////////////////////////////////////
void EntityComponentManager::ClearRemovedComponents()
{
Expand Down
2 changes: 1 addition & 1 deletion src/systems/scene_broadcaster/SceneBroadcaster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void SceneBroadcaster::PostUpdate(const UpdateInfo &_info,
bool jumpBackInTime = _info.dt < std::chrono::steady_clock::duration::zero();
bool changeEvent = _manager.HasEntitiesMarkedForRemoval() ||
_manager.HasNewEntities() || _manager.HasOneTimeComponentChanges() ||
jumpBackInTime;
jumpBackInTime || _manager.HasRemovedComponents();
auto now = std::chrono::system_clock::now();
bool itsPubTime = !_info.paused && (now - this->dataPtr->lastStatePubTime >
this->dataPtr->statePublishPeriod);
Expand Down

0 comments on commit 025bb3f

Please sign in to comment.