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/Pose3.hh>
23 #include <gz/utils/ImplPtr.hh>
24 #include "sdf/Element.hh"
25 #include "sdf/SemanticPose.hh"
26 #include "sdf/Types.hh"
27 #include "sdf/sdf_config.h"
28 #include "sdf/system_util.hh"
29 
30 namespace sdf
31 {
32  // Inline bracket to help doxygen filtering.
33  inline namespace SDF_VERSION_NAMESPACE {
34  //
35 
36  // Forward declarations.
37  class Collision;
38  class Light;
39  class ParticleEmitter;
40  class Sensor;
41  class Visual;
42  struct PoseRelativeToGraph;
43  template <typename T> class ScopedGraph;
44 
46  {
48  public: Link();
49 
56  public: Errors Load(ElementPtr _sdf);
57 
61  public: std::string Name() const;
62 
66  public: void SetName(const std::string &_name);
67 
70  public: uint64_t VisualCount() const;
71 
77  public: const Visual *VisualByIndex(const uint64_t _index) const;
78 
84  public: Visual *VisualByIndex(uint64_t _index);
85 
89  public: bool VisualNameExists(const std::string &_name) const;
90 
94  public: const Visual *VisualByName(const std::string &_name) const;
95 
99  public: Visual *VisualByName(const std::string &_name);
100 
103  public: uint64_t CollisionCount() const;
104 
110  public: const Collision *CollisionByIndex(const uint64_t _index) const;
111 
117  public: Collision *CollisionByIndex(uint64_t _index);
118 
122  public: bool CollisionNameExists(const std::string &_name) const;
123 
127  public: const Collision *CollisionByName(const std::string &_name) const;
128 
132  public: Collision *CollisionByName(const std::string &_name);
133 
136  public: uint64_t LightCount() const;
137 
143  public: const Light *LightByIndex(const uint64_t _index) const;
144 
150  public: Light *LightByIndex(uint64_t _index);
151 
155  public: bool LightNameExists(const std::string &_name) const;
156 
160  public: const Light *LightByName(const std::string &_name) const;
161 
165  public: Light *LightByName(const std::string &_name);
166 
169  public: uint64_t SensorCount() const;
170 
176  public: const Sensor *SensorByIndex(const uint64_t _index) const;
177 
183  public: Sensor *SensorByIndex(uint64_t _index);
184 
188  public: bool SensorNameExists(const std::string &_name) const;
189 
195  public: const Sensor *SensorByName(const std::string &_name) const;
196 
202  public: Sensor *SensorByName(const std::string &_name);
203 
206  public: uint64_t ParticleEmitterCount() const;
207 
214  public: const ParticleEmitter *ParticleEmitterByIndex(
215  const uint64_t _index) const;
216 
223  public: ParticleEmitter *ParticleEmitterByIndex(uint64_t _index);
224 
228  public: bool ParticleEmitterNameExists(const std::string &_name) const;
229 
235  public: const ParticleEmitter *ParticleEmitterByName(
236  const std::string &_name) const;
237 
243  public: ParticleEmitter *ParticleEmitterByName(const std::string &_name);
244 
258  public: const gz::math::Inertiald &Inertial() const;
259 
264  public: bool SetInertial(const gz::math::Inertiald &_inertial);
265 
273  public: Errors ResolveInertial(gz::math::Inertiald &_inertial,
274  const std::string &_resolveTo = "") const;
275 
279  public: const gz::math::Pose3d &RawPose() const;
280 
284  public: void SetRawPose(const gz::math::Pose3d &_pose);
285 
290  public: const std::string &PoseRelativeTo() const;
291 
296  public: void SetPoseRelativeTo(const std::string &_frame);
297 
302  public: sdf::ElementPtr Element() const;
303 
307  public: sdf::SemanticPose SemanticPose() const;
308 
312  private: void SetPoseRelativeToGraph(
314 
316  friend class Model;
317 
322  public: bool EnableWind() const;
323 
327  public: bool EnableGravity() const;
328 
333  public: void SetEnableWind(bool _enableWind);
334 
338  public: void SetEnableGravity(bool _enableGravity);
339 
344  public: bool AddCollision(const Collision &_collision);
345 
350  public: bool AddVisual(const Visual &_visual);
351 
356  public: bool AddLight(const Light &_light);
357 
362  public: bool AddSensor(const Sensor &_sensor);
363 
368  public: bool AddParticleEmitter(const ParticleEmitter &_sensor);
369 
371  public: void ClearCollisions();
372 
374  public: void ClearVisuals();
375 
377  public: void ClearLights();
378 
380  public: void ClearSensors();
381 
383  public: void ClearParticleEmitters();
384 
390  public: sdf::ElementPtr ToElement() const;
391 
393  IGN_UTILS_IMPL_PTR(dataPtr)
394  };
395  }
396 }
397 #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::Element
class IGNITION_SDFORMAT_VISIBLE Element
Definition: Element.hh:50
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::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:106
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