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 #include "sdf/ParserConfig.hh"
31 #include "sdf/Error.hh"
32 
33 namespace sdf
34 {
35  // Inline bracket to help doxygen filtering.
36  inline namespace SDF_VERSION_NAMESPACE {
37  //
38 
39  // Forward declarations.
40  class Collision;
41  class Light;
42  class ParserConfig;
43  class ParticleEmitter;
44  class Projector;
45  class Sensor;
46  class Visual;
47  struct PoseRelativeToGraph;
48  template <typename T> class ScopedGraph;
49 
51  {
53  public: Link();
54 
61  public: Errors Load(ElementPtr _sdf);
62 
70  public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
71 
75  public: std::string Name() const;
76 
80  public: void SetName(const std::string &_name);
81 
84  public: uint64_t VisualCount() const;
85 
91  public: const Visual *VisualByIndex(const uint64_t _index) const;
92 
98  public: Visual *VisualByIndex(uint64_t _index);
99 
103  public: bool VisualNameExists(const std::string &_name) const;
104 
108  public: const Visual *VisualByName(const std::string &_name) const;
109 
113  public: Visual *VisualByName(const std::string &_name);
114 
117  public: uint64_t CollisionCount() const;
118 
124  public: const Collision *CollisionByIndex(const uint64_t _index) const;
125 
131  public: Collision *CollisionByIndex(uint64_t _index);
132 
136  public: bool CollisionNameExists(const std::string &_name) const;
137 
141  public: const Collision *CollisionByName(const std::string &_name) const;
142 
146  public: Collision *CollisionByName(const std::string &_name);
147 
150  public: uint64_t LightCount() const;
151 
157  public: const Light *LightByIndex(const uint64_t _index) const;
158 
164  public: Light *LightByIndex(uint64_t _index);
165 
169  public: bool LightNameExists(const std::string &_name) const;
170 
174  public: const Light *LightByName(const std::string &_name) const;
175 
179  public: Light *LightByName(const std::string &_name);
180 
183  public: uint64_t SensorCount() const;
184 
190  public: const Sensor *SensorByIndex(const uint64_t _index) const;
191 
197  public: Sensor *SensorByIndex(uint64_t _index);
198 
202  public: bool SensorNameExists(const std::string &_name) const;
203 
209  public: const Sensor *SensorByName(const std::string &_name) const;
210 
216  public: Sensor *SensorByName(const std::string &_name);
217 
220  public: uint64_t ParticleEmitterCount() const;
221 
229  const uint64_t _index) const;
230 
237  public: ParticleEmitter *ParticleEmitterByIndex(uint64_t _index);
238 
242  public: bool ParticleEmitterNameExists(const std::string &_name) const;
243 
250  const std::string &_name) const;
251 
257  public: ParticleEmitter *ParticleEmitterByName(const std::string &_name);
258 
261  public: uint64_t ProjectorCount() const;
262 
269  public: const Projector *ProjectorByIndex(
270  const uint64_t _index) const;
271 
278  public: Projector *ProjectorByIndex(uint64_t _index);
279 
283  public: bool ProjectorNameExists(const std::string &_name) const;
284 
290  public: const Projector *ProjectorByName(
291  const std::string &_name) const;
292 
298  public: Projector *ProjectorByName(const std::string &_name);
299 
313  public: const gz::math::Inertiald &Inertial() const;
314 
319  public: bool SetInertial(const gz::math::Inertiald &_inertial);
320 
328  public: Errors ResolveInertial(gz::math::Inertiald &_inertial,
329  const std::string &_resolveTo = "") const;
330 
338  public: void ResolveAutoInertials(sdf::Errors &_errors,
339  const ParserConfig &_config);
340 
344  public: const gz::math::Pose3d &RawPose() const;
345 
349  public: void SetRawPose(const gz::math::Pose3d &_pose);
350 
355  public: const std::string &PoseRelativeTo() const;
356 
361  public: void SetPoseRelativeTo(const std::string &_frame);
362 
367  public: sdf::ElementPtr Element() const;
368 
373 
377  private: void SetPoseRelativeToGraph(
379 
381  friend class Model;
382 
387  public: bool EnableWind() const;
388 
393  public: void SetEnableWind(bool _enableWind);
394 
401  public: bool AutoInertia() const;
402 
406  public: void SetAutoInertia(bool _autoInertia);
407 
415  public: bool AutoInertiaSaved() const;
416 
419  public: void SetAutoInertiaSaved(bool _autoInertiaSaved);
420 
425  public: bool AddCollision(const Collision &_collision);
426 
431  public: bool AddVisual(const Visual &_visual);
432 
437  public: bool AddLight(const Light &_light);
438 
443  public: bool AddSensor(const Sensor &_sensor);
444 
449  public: bool AddParticleEmitter(const ParticleEmitter &_emitter);
450 
455  public: bool AddProjector(const Projector &_projector);
456 
458  public: void ClearCollisions();
459 
461  public: void ClearVisuals();
462 
464  public: void ClearLights();
465 
467  public: void ClearSensors();
468 
470  public: void ClearParticleEmitters();
471 
473  public: void ClearProjectors();
474 
480  public: sdf::ElementPtr ToElement() const;
481 
483  GZ_UTILS_IMPL_PTR(dataPtr)
484  };
485  }
486 }
487 #endif
A collision element descibes the collision properties associated with a link.
Definition: Collision.hh:50
Provides a description of a light source.
Definition: Light.hh:64
Definition: Model.hh:55
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:100
A description of a particle emitter, which can be attached to a link.
Definition: ParticleEmitter.hh:61
A description of a projector, which can be attached to a link.
Definition: Projector.hh:44
Definition: Collision.hh:43
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:55
Information about an SDF sensor.
Definition: Sensor.hh:141
Definition: Visual.hh:49
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25