Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish all periodic change components in Scene Broadcaster #544

Merged
merged 6 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/ignition/gazebo/EntityComponentManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,12 @@ namespace ignition
/// \return True if there are any components with one-time changes.
public: bool HasOneTimeComponentChanges() const;

/// \brief Get the components types that are marked as periodic changes.
/// \return All the components that at least one entity marked as
/// periodic changes.
public: std::unordered_set<ComponentTypeId>
ComponentTypesWithPeriodicChanges() const;

/// \brief Set the absolute state of the ECM from a serialized message.
/// Entities / components that are in the new state but not in the old
/// one will be created.
Expand Down
12 changes: 12 additions & 0 deletions src/EntityComponentManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,18 @@ bool EntityComponentManager::HasOneTimeComponentChanges() const
return !this->dataPtr->oneTimeChangedComponents.empty();
}

/////////////////////////////////////////////////
std::unordered_set<ComponentTypeId>
EntityComponentManager::ComponentTypesWithPeriodicChanges() const
{
std::unordered_set<ComponentTypeId> periodicComponents;
for (const auto& compPair : this->dataPtr->periodicChangedComponents)
{
periodicComponents.insert(compPair.first);
}
return periodicComponents;
}

/////////////////////////////////////////////////
bool EntityComponentManager::HasEntity(const Entity _entity) const
{
Expand Down
5 changes: 3 additions & 2 deletions src/systems/scene_broadcaster/SceneBroadcaster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,13 @@ void SceneBroadcaster::PostUpdate(const UpdateInfo &_info,
{
_manager.State(*this->dataPtr->stepMsg.mutable_state(), {}, {}, true);
}
// Otherwise publish just selected components
// Otherwise publish just periodic change components
else
{
IGN_PROFILE("SceneBroadcast::PostUpdate UpdateState");
auto periodicComponents = _manager.ComponentTypesWithPeriodicChanges();
_manager.State(*this->dataPtr->stepMsg.mutable_state(),
{}, {components::Pose::typeId});
{}, periodicComponents);
}

// Full state on demand
Expand Down