Model.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_MODEL_HH_
18 #define SDF_MODEL_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <ignition/math/Pose3.hh>
24 #include <ignition/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 Frame;
39  class InterfaceModel;
40  class Joint;
41  class Link;
42  class ParserConfig;
43  struct NestedInclude;
44  struct PoseRelativeToGraph;
45  struct FrameAttachedToGraph;
46  template <typename T> class ScopedGraph;
47 
49  {
51  public: Model();
52 
59  public: Errors Load(ElementPtr _sdf);
60 
68  public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
69 
73  public: std::string Name() const;
74 
78  public: void SetName(const std::string &_name);
79 
84  public: bool Static() const;
85 
90  public: void SetStatic(bool _static);
91 
97  public: bool SelfCollide() const;
98 
103  public: void SetSelfCollide(bool _selfCollide);
104 
109  public: bool AllowAutoDisable() const;
110 
115  public: void SetAllowAutoDisable(bool _allowAutoDisable);
116 
121  public: bool EnableWind() const;
122 
126  public: void SetEnableWind(bool _enableWind);
127 
133  public: uint64_t LinkCount() const;
134 
140  public: const Link *LinkByIndex(const uint64_t _index) const;
141 
147  public: const Link *LinkByName(const std::string &_name) const;
148 
154  public: bool LinkNameExists(const std::string &_name) const;
155 
161  public: uint64_t JointCount() const;
162 
168  public: const Joint *JointByIndex(const uint64_t _index) const;
169 
175  public: bool JointNameExists(const std::string &_name) const;
176 
184  public: const Joint *JointByName(const std::string &_name) const;
185 
191  public: uint64_t FrameCount() const;
192 
200  public: const Frame *FrameByIndex(const uint64_t _index) const;
201 
208  public: const Frame *FrameByName(const std::string &_name) const;
209 
215  public: bool FrameNameExists(const std::string &_name) const;
216 
222  public: uint64_t ModelCount() const;
223 
230  public: const Model *ModelByIndex(const uint64_t _index) const;
231 
237  public: bool ModelNameExists(const std::string &_name) const;
238 
246  public: const Model *ModelByName(const std::string &_name) const;
247 
253  public: const ignition::math::Pose3d &RawPose() const;
254 
258  public: void SetRawPose(const ignition::math::Pose3d &_pose);
259 
262  public: const Link *CanonicalLink() const;
263 
268  public: const std::string &CanonicalLinkName() const;
269 
274  public: void SetCanonicalLinkName(const std::string &_canonicalLink);
275 
280  public: const std::string &PoseRelativeTo() const;
281 
286  public: void SetPoseRelativeTo(const std::string &_frame);
287 
292  public: sdf::ElementPtr Element() const;
293 
297  public: sdf::SemanticPose SemanticPose() const;
298 
301  public: const std::string &PlacementFrameName() const;
302 
306  public: void SetPlacementFrameName(const std::string &_name);
307 
312  // TODO (addisu): If the canonical link is inside an interface model, this
313  // function returns {nullptr, name}. This can be problematic for downstream
314  // applications.
315  public: std::pair<const Link *, std::string> CanonicalLinkAndRelativeName()
316  const;
317 
322  public: uint64_t InterfaceModelCount() const;
323 
330  public: std::shared_ptr<const InterfaceModel> InterfaceModelByIndex(
331  const uint64_t _index) const;
332 
340  public: const NestedInclude *InterfaceModelNestedIncludeByIndex(
341  const uint64_t _index) const;
342 
348  private: void SetPoseRelativeToGraph(
350 
356  private: void SetFrameAttachedToGraph(
358 
362  friend class Root;
363  friend class World;
364 
366  IGN_UTILS_IMPL_PTR(dataPtr)
367  };
368  }
369 }
370 #endif
sdf::v11::Joint
Definition: Joint.hh:85
sdf::v11::ScopedGraph
Definition: Collision.hh:39
sdf::v11::World
Definition: World.hh:51
sdf::v11::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v11::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
namespace for Simulation Description Format parser
Definition: Actor.hh:33
sdf::v11::Model
Definition: Model.hh:48
sdf::v11::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
Types.hh
SemanticPose.hh
sdf::v11::NestedInclude
Contains the necessary information about an included model file for custom model parsers to be able t...
Definition: InterfaceElements.hh:43
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:41
sdf::v11::Frame
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:42
sdf::v11::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
system_util.hh
sdf::v11::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
sdf::v11::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
Element.hh