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 ParticleEmitter;
41  class Sensor;
42  class Visual;
43  struct PoseRelativeToGraph;
44  template <typename T> class ScopedGraph;
45 
47  {
49  public: Link();
50 
57  public: Errors Load(ElementPtr _sdf);
58 
62  public: std::string Name() const;
63 
67  public: void SetName(const std::string &_name);
68 
71  public: uint64_t VisualCount() const;
72 
78  public: const Visual *VisualByIndex(const uint64_t _index) const;
79 
85  public: Visual *VisualByIndex(uint64_t _index);
86 
90  public: bool VisualNameExists(const std::string &_name) const;
91 
95  public: const Visual *VisualByName(const std::string &_name) const;
96 
100  public: Visual *VisualByName(const std::string &_name);
101 
104  public: uint64_t CollisionCount() const;
105 
111  public: const Collision *CollisionByIndex(const uint64_t _index) const;
112 
118  public: Collision *CollisionByIndex(uint64_t _index);
119 
123  public: bool CollisionNameExists(const std::string &_name) const;
124 
128  public: const Collision *CollisionByName(const std::string &_name) const;
129 
133  public: Collision *CollisionByName(const std::string &_name);
134 
137  public: uint64_t LightCount() const;
138 
144  public: const Light *LightByIndex(const uint64_t _index) const;
145 
151  public: Light *LightByIndex(uint64_t _index);
152 
156  public: bool LightNameExists(const std::string &_name) const;
157 
161  public: const Light *LightByName(const std::string &_name) const;
162 
166  public: Light *LightByName(const std::string &_name);
167 
170  public: uint64_t SensorCount() const;
171 
177  public: const Sensor *SensorByIndex(const uint64_t _index) const;
178 
184  public: Sensor *SensorByIndex(uint64_t _index);
185 
189  public: bool SensorNameExists(const std::string &_name) const;
190 
196  public: const Sensor *SensorByName(const std::string &_name) const;
197 
203  public: Sensor *SensorByName(const std::string &_name);
204 
207  public: uint64_t ParticleEmitterCount() const;
208 
215  public: const ParticleEmitter *ParticleEmitterByIndex(
216  const uint64_t _index) const;
217 
224  public: ParticleEmitter *ParticleEmitterByIndex(uint64_t _index);
225 
229  public: bool ParticleEmitterNameExists(const std::string &_name) const;
230 
236  public: const ParticleEmitter *ParticleEmitterByName(
237  const std::string &_name) const;
238 
244  public: ParticleEmitter *ParticleEmitterByName(const std::string &_name);
245 
259  public: const gz::math::Inertiald &Inertial() const;
260 
265  public: bool SetInertial(const gz::math::Inertiald &_inertial);
266 
274  public: Errors ResolveInertial(gz::math::Inertiald &_inertial,
275  const std::string &_resolveTo = "") const;
276 
280  public: const gz::math::Pose3d &RawPose() const;
281 
285  public: void SetRawPose(const gz::math::Pose3d &_pose);
286 
291  public: const std::string &PoseRelativeTo() const;
292 
297  public: void SetPoseRelativeTo(const std::string &_frame);
298 
303  public: sdf::ElementPtr Element() const;
304 
308  public: sdf::SemanticPose SemanticPose() const;
309 
313  private: void SetPoseRelativeToGraph(
315 
317  friend class Model;
318 
323  public: bool EnableWind() const;
324 
329  public: void SetEnableWind(bool _enableWind);
330 
335  public: bool AddCollision(const Collision &_collision);
336 
341  public: bool AddVisual(const Visual &_visual);
342 
347  public: bool AddLight(const Light &_light);
348 
353  public: bool AddSensor(const Sensor &_sensor);
354 
359  public: bool AddParticleEmitter(const ParticleEmitter &_sensor);
360 
362  public: void ClearCollisions();
363 
365  public: void ClearVisuals();
366 
368  public: void ClearLights();
369 
371  public: void ClearSensors();
372 
374  public: void ClearParticleEmitters();
375 
381  public: sdf::ElementPtr ToElement() const;
382 
384  GZ_UTILS_IMPL_PTR(dataPtr)
385  };
386  }
387 }
388 #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:45
Types.hh
SemanticPose.hh
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
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:50
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:39
sdf::SDF_VERSION_NAMESPACE::Visual
Definition: Visual.hh:47
system_util.hh
sdf::SDF_VERSION_NAMESPACE::Sensor
Information about an SDF sensor.
Definition: Sensor.hh:136
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
Element.hh