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 <ignition/math/Pose3.hh>
24 #include <ignition/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 
31 namespace sdf
32 {
33  // Inline bracket to help doxygen filtering.
34  inline namespace SDF_VERSION_NAMESPACE {
35  // Forward declarations.
36  class ParticleEmitterPrivate;
37  struct PoseRelativeToGraph;
38 
41  // Developer note: Make sure to update emitterTypeStrs in the source
42  // file when changing this enum.
44  {
46  POINT = 0,
47 
49  BOX = 1,
50 
52  CYLINDER = 2,
53 
55  ELLIPSOID = 3,
56  };
57 
62  {
64  public: ParticleEmitter();
65 
68  public: ParticleEmitter(const ParticleEmitter &_emitter);
69 
72  public: ParticleEmitter(ParticleEmitter &&_emitter) noexcept;
73 
77  public: ParticleEmitter &operator=(ParticleEmitter &&_emitter);
78 
82  public: ParticleEmitter &operator=(const ParticleEmitter &_emitter);
83 
85  public: ~ParticleEmitter();
86 
93  public: Errors Load(ElementPtr _sdf);
94 
99  public: std::string Name() const;
100 
105  public: void SetName(const std::string &_name);
106 
111  public: ParticleEmitterType Type() const;
112 
115  public: void SetType(const ParticleEmitterType _type);
116 
123  public: bool SetType(const std::string &_typeStr);
124 
127  public: std::string TypeStr() const;
128 
132  public: bool Emitting() const;
133 
137  public: void SetEmitting(bool _emitting);
138 
142  public: double Duration() const;
143 
147  public: void SetDuration(double _duration);
148 
152  public: double Lifetime() const;
153 
158  public: void SetLifetime(double _duration);
159 
162  public: double Rate() const;
163 
167  public: void SetRate(double _rate);
168 
172  public: double ScaleRate() const;
173 
178  public: void SetScaleRate(double _scaleRate);
179 
182  public: double MinVelocity() const;
183 
187  public: void SetMinVelocity(double _vel);
188 
191  public: double MaxVelocity() const;
192 
196  public: void SetMaxVelocity(double _vel);
197 
199  // Default value is (1, 1, 1).
200  // Note that the interpretation of the emitter area varies
201  // depending on the emmiter type:
202  // - point: The area is ignored.
203  // - box: The area is interpreted as width X height X depth.
204  // - cylinder: The area is interpreted as the bounding box of the
205  // cylinder. The cylinder is oriented along the Z-axis.
206  // - ellipsoid: The area is interpreted as the bounding box of an
207  // ellipsoid shaped area, i.e. a sphere or
208  // squashed-sphere area. The parameters are again
209  // identical to EM_BOX, except that the dimensions
210  // describe the widest points along each of the axes.
212  public: ignition::math::Vector3d Size() const;
213 
219  public: void SetSize(const ignition::math::Vector3d &_size);
220 
223  public: ignition::math::Vector3d ParticleSize() const;
224 
229  public: void SetParticleSize(const ignition::math::Vector3d &_size);
230 
237  public: ignition::math::Color ColorStart() const;
238 
242  public: void SetColorStart(const ignition::math::Color &_colorStart);
243 
250  public: ignition::math::Color ColorEnd() const;
251 
255  public: void SetColorEnd(const ignition::math::Color &_colorEnd);
256 
265  public: std::string ColorRangeImage() const;
266 
270  public: void SetColorRangeImage(const std::string &_image);
271 
274  public: std::string Topic() const;
275 
278  public: void SetTopic(const std::string &_topic);
279 
284  public: float ScatterRatio() const;
285 
289  public: void SetScatterRatio(float _ratio);
290 
295  public: const ignition::math::Pose3d &RawPose() const;
296 
300  public: void SetRawPose(const ignition::math::Pose3d &_pose);
301 
306  public: const std::string &PoseRelativeTo() const;
307 
312  public: void SetPoseRelativeTo(const std::string &_frame);
313 
316  public: sdf::SemanticPose SemanticPose() const;
317 
321  public: sdf::ElementPtr Element() const;
322 
327  public: sdf::Material *Material() const;
328 
331  public: void SetMaterial(const sdf::Material &_material);
332 
335  public: const std::string &FilePath() const;
336 
339  public: void SetFilePath(const std::string &_filePath);
340 
345  private: void SetXmlParentName(const std::string &_xmlParentName);
346 
351  private: void SetPoseRelativeToGraph(
352  std::weak_ptr<const PoseRelativeToGraph> _graph);
353 
357  friend class Link;
358 
360  private: ParticleEmitterPrivate *dataPtr = nullptr;
361  };
362  }
363 }
364 #endif
ParticleEmitterType
The set of particle emitter types.
Definition: ParticleEmitter.hh:43
A description of a particle emitter, which can be attached to a link.
Definition: ParticleEmitter.hh:61
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:53
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
This class contains visual material properties.
Definition: Material.hh:45
namespace for Simulation Description Format parser
Definition: Actor.hh:32
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95