Link.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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_LINK_HH_
18 #define SDF_LINK_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <gz/math/Inertial.hh>
23 #include <gz/math/Pose3.hh>
24 #include <gz/utils/ImplPtr.hh>
25 #include "sdf/Element.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  //
36 
37  // Forward declarations.
38  class Collision;
39  class Light;
40  class ParserConfig;
41  class ParticleEmitter;
42  class Projector;
43  class Sensor;
44  class Visual;
45  struct PoseRelativeToGraph;
46  template <typename T> class ScopedGraph;
47 
49  {
51  public: Link();
52 
59  public: Errors Load(ElementPtr _sdf);
60 
68  public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
69 
73  public: std::string Name() const;
74 
78  public: void SetName(const std::string &_name);
79 
82  public: uint64_t VisualCount() const;
83 
89  public: const Visual *VisualByIndex(const uint64_t _index) const;
90 
96  public: Visual *VisualByIndex(uint64_t _index);
97 
101  public: bool VisualNameExists(const std::string &_name) const;
102 
106  public: const Visual *VisualByName(const std::string &_name) const;
107 
111  public: Visual *VisualByName(const std::string &_name);
112 
115  public: uint64_t CollisionCount() const;
116 
122  public: const Collision *CollisionByIndex(const uint64_t _index) const;
123 
129  public: Collision *CollisionByIndex(uint64_t _index);
130 
134  public: bool CollisionNameExists(const std::string &_name) const;
135 
139  public: const Collision *CollisionByName(const std::string &_name) const;
140 
144  public: Collision *CollisionByName(const std::string &_name);
145 
148  public: uint64_t LightCount() const;
149 
155  public: const Light *LightByIndex(const uint64_t _index) const;
156 
162  public: Light *LightByIndex(uint64_t _index);
163 
167  public: bool LightNameExists(const std::string &_name) const;
168 
172  public: const Light *LightByName(const std::string &_name) const;
173 
177  public: Light *LightByName(const std::string &_name);
178 
181  public: uint64_t SensorCount() const;
182 
188  public: const Sensor *SensorByIndex(const uint64_t _index) const;
189 
195  public: Sensor *SensorByIndex(uint64_t _index);
196 
200  public: bool SensorNameExists(const std::string &_name) const;
201 
207  public: const Sensor *SensorByName(const std::string &_name) const;
208 
214  public: Sensor *SensorByName(const std::string &_name);
215 
218  public: uint64_t ParticleEmitterCount() const;
219 
226  public: const ParticleEmitter *ParticleEmitterByIndex(
227  const uint64_t _index) const;
228 
235  public: ParticleEmitter *ParticleEmitterByIndex(uint64_t _index);
236 
240  public: bool ParticleEmitterNameExists(const std::string &_name) const;
241 
247  public: const ParticleEmitter *ParticleEmitterByName(
248  const std::string &_name) const;
249 
255  public: ParticleEmitter *ParticleEmitterByName(const std::string &_name);
256 
259  public: uint64_t ProjectorCount() const;
260 
267  public: const Projector *ProjectorByIndex(
268  const uint64_t _index) const;
269 
276  public: Projector *ProjectorByIndex(uint64_t _index);
277 
281  public: bool ProjectorNameExists(const std::string &_name) const;
282 
288  public: const Projector *ProjectorByName(
289  const std::string &_name) const;
290 
296  public: Projector *ProjectorByName(const std::string &_name);
297 
311  public: const gz::math::Inertiald &Inertial() const;
312 
317  public: bool SetInertial(const gz::math::Inertiald &_inertial);
318 
326  public: Errors ResolveInertial(gz::math::Inertiald &_inertial,
327  const std::string &_resolveTo = "") const;
328 
332  public: const gz::math::Pose3d &RawPose() const;
333 
337  public: void SetRawPose(const gz::math::Pose3d &_pose);
338 
343  public: const std::string &PoseRelativeTo() const;
344 
349  public: void SetPoseRelativeTo(const std::string &_frame);
350 
355  public: sdf::ElementPtr Element() const;
356 
360  public: sdf::SemanticPose SemanticPose() const;
361 
365  private: void SetPoseRelativeToGraph(
367 
369  friend class Model;
370 
375  public: bool EnableWind() const;
376 
380  public: bool EnableGravity() const;
381 
386  public: void SetEnableWind(bool _enableWind);
387 
391  public: void SetEnableGravity(bool _enableGravity);
392 
397  public: bool AddCollision(const Collision &_collision);
398 
403  public: bool AddVisual(const Visual &_visual);
404 
409  public: bool AddLight(const Light &_light);
410 
415  public: bool AddSensor(const Sensor &_sensor);
416 
421  public: bool AddParticleEmitter(const ParticleEmitter &_emitter);
422 
427  public: bool AddProjector(const Projector &_projector);
428 
430  public: void ClearCollisions();
431 
433  public: void ClearVisuals();
434 
436  public: void ClearLights();
437 
439  public: void ClearSensors();
440 
442  public: void ClearParticleEmitters();
443 
445  public: void ClearProjectors();
446 
452  public: sdf::ElementPtr ToElement() const;
453 
455  GZ_UTILS_IMPL_PTR(dataPtr)
456  };
457  }
458 }
459 #endif
sdf::SDF_VERSION_NAMESPACE::Model
Definition: Model.hh:54
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::ParticleEmitter
A description of a particle emitter, which can be attached to a link.
Definition: ParticleEmitter.hh:60
sdf::SDF_VERSION_NAMESPACE::Collision
A collision element descibes the collision properties associated with a link.
Definition: Collision.hh:46
Types.hh
SemanticPose.hh
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::SDF_VERSION_NAMESPACE::Light
Provides a description of a light source.
Definition: Light.hh:63
sdf::SDF_VERSION_NAMESPACE::Element
class GZ_SDFORMAT_VISIBLE Element
Definition: Element.hh:51
sdf::SDF_VERSION_NAMESPACE::SemanticPose
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:54
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
sdf::SDF_VERSION_NAMESPACE::ScopedGraph
Definition: Collision.hh:40
sdf::SDF_VERSION_NAMESPACE::Visual
Definition: Visual.hh:48
system_util.hh
sdf::SDF_VERSION_NAMESPACE::Projector
A description of a projector, which can be attached to a link.
Definition: Projector.hh:43
sdf::SDF_VERSION_NAMESPACE::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:140
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
Element.hh