ParticleEmitter.hh
Go to the documentation of this file.
1/*
2 * Copyright 2021 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef SDF_PARTICLE_EMITTER_HH_
18#define SDF_PARTICLE_EMITTER_HH_
19
20#include <memory>
21#include <string>
22
23#include <gz/math/Pose3.hh>
24#include <gz/math/Vector3.hh>
25#include "sdf/Material.hh"
26#include "sdf/SemanticPose.hh"
27#include "sdf/Types.hh"
28#include "sdf/sdf_config.h"
29#include "sdf/system_util.hh"
30
31namespace sdf
32{
33 // Inline bracket to help doxygen filtering.
34 inline namespace SDF_VERSION_NAMESPACE {
35 // Forward declarations.
36 struct PoseRelativeToGraph;
37
40 // Developer note: Make sure to update kEmitterTypeStrs in the source
41 // file when changing this enum.
43 {
45 POINT = 0,
46
48 BOX = 1,
49
51 CYLINDER = 2,
52
54 ELLIPSOID = 3,
55 };
56
61 {
63 public: ParticleEmitter();
64
71 public: Errors Load(ElementPtr _sdf);
72
77 public: std::string Name() const;
78
83 public: void SetName(const std::string &_name);
84
89 public: ParticleEmitterType Type() const;
90
93 public: void SetType(const ParticleEmitterType _type);
94
101 public: bool SetType(const std::string &_typeStr);
102
105 public: std::string TypeStr() const;
106
110 public: bool Emitting() const;
111
115 public: void SetEmitting(bool _emitting);
116
120 public: double Duration() const;
121
125 public: void SetDuration(double _duration);
126
130 public: double Lifetime() const;
131
136 public: void SetLifetime(double _duration);
137
140 public: double Rate() const;
141
145 public: void SetRate(double _rate);
146
150 public: double ScaleRate() const;
151
156 public: void SetScaleRate(double _scaleRate);
157
160 public: double MinVelocity() const;
161
165 public: void SetMinVelocity(double _vel);
166
169 public: double MaxVelocity() const;
170
174 public: void SetMaxVelocity(double _vel);
175
177 // Default value is (1, 1, 1).
178 // Note that the interpretation of the emitter area varies
179 // depending on the emmiter type:
180 // - point: The area is ignored.
181 // - box: The area is interpreted as width X height X depth.
182 // - cylinder: The area is interpreted as the bounding box of the
183 // cylinder. The cylinder is oriented along the Z-axis.
184 // - ellipsoid: The area is interpreted as the bounding box of an
185 // ellipsoid shaped area, i.e. a sphere or
186 // squashed-sphere area. The parameters are again
187 // identical to EM_BOX, except that the dimensions
188 // describe the widest points along each of the axes.
190 public: gz::math::Vector3d Size() const;
191
197 public: void SetSize(const gz::math::Vector3d &_size);
198
201 public: gz::math::Vector3d ParticleSize() const;
202
207 public: void SetParticleSize(const gz::math::Vector3d &_size);
208
215 public: gz::math::Color ColorStart() const;
216
220 public: void SetColorStart(const gz::math::Color &_colorStart);
221
228 public: gz::math::Color ColorEnd() const;
229
233 public: void SetColorEnd(const gz::math::Color &_colorEnd);
234
243 public: std::string ColorRangeImage() const;
244
248 public: void SetColorRangeImage(const std::string &_image);
249
252 public: std::string Topic() const;
253
256 public: void SetTopic(const std::string &_topic);
257
262 public: float ScatterRatio() const;
263
267 public: void SetScatterRatio(float _ratio);
268
273 public: const gz::math::Pose3d &RawPose() const;
274
278 public: void SetRawPose(const gz::math::Pose3d &_pose);
279
284 public: const std::string &PoseRelativeTo() const;
285
290 public: void SetPoseRelativeTo(const std::string &_frame);
291
295
299 public: sdf::ElementPtr Element() const;
300
305 public: const sdf::Material *Material() const;
306
309 public: void SetMaterial(const sdf::Material &_material);
310
313 public: const std::string &FilePath() const;
314
317 public: void SetFilePath(const std::string &_filePath);
318
324 public: sdf::ElementPtr ToElement() const;
325
332 public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
333
338 private: void SetXmlParentName(const std::string &_xmlParentName);
339
344 private: void SetPoseRelativeToGraph(
346
350 friend class Link;
351
353 GZ_UTILS_IMPL_PTR(dataPtr)
354 };
355 }
356}
357#endif
This class contains visual material properties.
Definition: Material.hh:47
A description of a particle emitter, which can be attached to a link.
Definition: ParticleEmitter.hh:61
double Rate() const
Get the number of particles per second that should be emitted.
void SetScatterRatio(float _ratio)
Set the particle scatter ratio.
void SetColorRangeImage(const std::string &_image)
Set the path to the color image used as an affector.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this particle emitter.
void SetMaxVelocity(double _vel)
Set the maximum velocity for each particle.
Errors Load(ElementPtr _sdf)
Load the particle emitter based on an element pointer.
gz::math::Vector3d Size() const
Get the size of the emitter where the particles are sampled.
sdf::ElementPtr ToElement(sdf::Errors &_errors) const
Create and return an SDF element filled with data from this particle emitter.
double Duration() const
Get the number of seconds the emitter is active.
void SetMinVelocity(double _vel)
Set the minimum velocity for each particle.
const gz::math::Pose3d & RawPose() const
Get the pose of the particle emitter.
double MaxVelocity() const
Get the maximum velocity for each particle.
void SetType(const ParticleEmitterType _type)
Set the type of the particle emitter.
gz::math::Vector3d ParticleSize() const
Get the size of a particle in meters.
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
void SetMaterial(const sdf::Material &_material)
Set the emitter's material.
bool SetType(const std::string &_typeStr)
Set the type of the particle emitter.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
void SetColorEnd(const gz::math::Color &_colorEnd)
Set the end color for all particles emitted.
void SetRate(double _rate)
Set the number of particles per second that should be emitted.
const std::string & FilePath() const
The path to the file where this element was loaded from.
gz::math::Color ColorStart() const
Gets the starting color for all particles emitted.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this emitter's pose is expressed.
void SetName(const std::string &_name)
Set the name of the particle emitter.
std::string Name() const
Get the name of the particle emitter.
void SetScaleRate(double _scaleRate)
Set the amount by which to scale the particles in both x and y direction per second.
void SetDuration(double _duration)
Set the number of seconds the emitter is active.
void SetColorStart(const gz::math::Color &_colorStart)
Set the starting color for all particles emitted.
gz::math::Color ColorEnd() const
Get the end color for all particles emitted.
const sdf::Material * Material() const
Get a pointer to the emitter's material properties.
std::string ColorRangeImage() const
Get the path to the color image used as an affector.
void SetRawPose(const gz::math::Pose3d &_pose)
Set the pose of the particle emitter object.
double Lifetime() const
Get the number of seconds each particle will 'live' for before being destroyed.
double ScaleRate() const
Get the amount by which to scale the particles in both x and y direction per second.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this emitter's pose is expressed.
void SetEmitting(bool _emitting)
Set whether the particle emitter is running, emitting particles.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
bool Emitting() const
Get whether the particle emitter should run (emit particles).
double MinVelocity() const
Get the minimum velocity for each particle.
std::string Topic() const
Get the topic used to update the particle emitter properties.
void SetLifetime(double _duration)
Set the number of seconds each particle will 'live' for.
float ScatterRatio() const
Get the particle scatter ratio.
ParticleEmitterType Type() const
Get the type of the particle emitter.
void SetSize(const gz::math::Vector3d &_size)
Set the size of the emitter where the particles are sampled.
void SetTopic(const std::string &_topic)
Set the topic used to update the particle emitter properties.
std::string TypeStr() const
Get the particle emitter type as a string.
void SetParticleSize(const gz::math::Vector3d &_size)
Set the size of a particle in meters.
Definition: Collision.hh:43
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:55
ParticleEmitterType
The set of particle emitter types.
Definition: ParticleEmitter.hh:43
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25