Skip to content

Commit 2e5e81c

Browse files
ParticleEmitter can use topic from sdf (#3244) (#3257)
(cherry picked from commit 8b078b9) Signed-off-by: Maksim Derbasov <ntfs.hard@gmail.com> Co-authored-by: Maksim Derbasov <ntfs.hard@gmail.com>
1 parent 04580a2 commit 2e5e81c

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/systems/particle_emitter/ParticleEmitter.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ void ParticleEmitter::PreUpdate(const gz::sim::UpdateInfo &_info,
152152
const components::ParentEntity *_parent,
153153
const components::Pose *_pose)->bool
154154
{
155-
std::string topic;
155+
std::string topic = _emitter->Data().topic().data();
156156

157157
// Get the topic information from the header, which is currently a
158158
// hack to avoid breaking the particle_emitter.proto message.
159-
if (_emitter->Data().has_header())
159+
if (topic.empty() && _emitter->Data().has_header())
160160
{
161161
for (const auto & data : _emitter->Data().header().data())
162162
{
@@ -169,8 +169,10 @@ void ParticleEmitter::PreUpdate(const gz::sim::UpdateInfo &_info,
169169

170170
// If a topic has not been specified, then generate topic based
171171
// on the scoped name.
172-
topic = !topic.empty() ? topic :
173-
topicFromScopedName(_entity, _ecm) + "/cmd";
172+
if (topic.empty())
173+
{
174+
topic = topicFromScopedName(_entity, _ecm) + "/cmd";
175+
}
174176

175177
// Subscribe to the topic that receives particle emitter commands.
176178
if (!this->dataPtr->node.Subscribe(

0 commit comments

Comments
 (0)