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 Sensor;
43  class Visual;
44  struct PoseRelativeToGraph;
45  template <typename T> class ScopedGraph;
46 
48  {
50  public: Link();
51 
58  public: Errors Load(ElementPtr _sdf);
59 
67  public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
68 
72  public: std::string Name() const;
73 
77  public: void SetName(const std::string &_name);
78 
81  public: uint64_t VisualCount() const;
82 
88  public: const Visual *VisualByIndex(const uint64_t _index) const;
89 
95  public: Visual *VisualByIndex(uint64_t _index);
96 
100  public: bool VisualNameExists(const std::string &_name) const;
101 
105  public: const Visual *VisualByName(const std::string &_name) const;
106 
110  public: Visual *VisualByName(const std::string &_name);
111 
114  public: uint64_t CollisionCount() const;
115 
121  public: const Collision *CollisionByIndex(const uint64_t _index) const;
122 
128  public: Collision *CollisionByIndex(uint64_t _index);
129 
133  public: bool CollisionNameExists(const std::string &_name) const;
134 
138  public: const Collision *CollisionByName(const std::string &_name) const;
139 
143  public: Collision *CollisionByName(const std::string &_name);
144 
147  public: uint64_t LightCount() const;
148 
154  public: const Light *LightByIndex(const uint64_t _index) const;
155 
161  public: Light *LightByIndex(uint64_t _index);
162 
166  public: bool LightNameExists(const std::string &_name) const;
167 
171  public: const Light *LightByName(const std::string &_name) const;
172 
176  public: Light *LightByName(const std::string &_name);
177 
180  public: uint64_t SensorCount() const;
181 
187  public: const Sensor *SensorByIndex(const uint64_t _index) const;
188 
194  public: Sensor *SensorByIndex(uint64_t _index);
195 
199  public: bool SensorNameExists(const std::string &_name) const;
200 
206  public: const Sensor *SensorByName(const std::string &_name) const;
207 
213  public: Sensor *SensorByName(const std::string &_name);
214 
217  public: uint64_t ParticleEmitterCount() const;
218 
225  public: const ParticleEmitter *ParticleEmitterByIndex(
226  const uint64_t _index) const;
227 
234  public: ParticleEmitter *ParticleEmitterByIndex(uint64_t _index);
235 
239  public: bool ParticleEmitterNameExists(const std::string &_name) const;
240 
246  public: const ParticleEmitter *ParticleEmitterByName(
247  const std::string &_name) const;
248 
254  public: ParticleEmitter *ParticleEmitterByName(const std::string &_name);
255 
269  public: const gz::math::Inertiald &Inertial() const;
270 
275  public: bool SetInertial(const gz::math::Inertiald &_inertial);
276 
284  public: Errors ResolveInertial(gz::math::Inertiald &_inertial,
285  const std::string &_resolveTo = "") const;
286 
290  public: const gz::math::Pose3d &RawPose() const;
291 
295  public: void SetRawPose(const gz::math::Pose3d &_pose);
296 
301  public: const std::string &PoseRelativeTo() const;
302 
307  public: void SetPoseRelativeTo(const std::string &_frame);
308 
313  public: sdf::ElementPtr Element() const;
314 
318  public: sdf::SemanticPose SemanticPose() const;
319 
323  private: void SetPoseRelativeToGraph(
325 
327  friend class Model;
328 
333  public: bool EnableWind() const;
334 
339  public: void SetEnableWind(bool _enableWind);
340 
345  public: bool AddCollision(const Collision &_collision);
346 
351  public: bool AddVisual(const Visual &_visual);
352 
357  public: bool AddLight(const Light &_light);
358 
363  public: bool AddSensor(const Sensor &_sensor);
364 
369  public: bool AddParticleEmitter(const ParticleEmitter &_sensor);
370 
372  public: void ClearCollisions();
373 
375  public: void ClearVisuals();
376 
378  public: void ClearLights();
379 
381  public: void ClearSensors();
382 
384  public: void ClearParticleEmitters();
385 
391  public: sdf::ElementPtr ToElement() const;
392 
394  GZ_UTILS_IMPL_PTR(dataPtr)
395  };
396  }
397 }
398 #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: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:40
sdf::SDF_VERSION_NAMESPACE::Visual
Definition: Visual.hh:48
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