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  class 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 
74  public: Errors ValidateGraphs() const;
75 
79  public: std::string Name() const;
80 
84  public: void SetName(const std::string &_name);
85 
90  public: bool Static() const;
91 
96  public: void SetStatic(bool _static);
97 
103  public: bool SelfCollide() const;
104 
109  public: void SetSelfCollide(bool _selfCollide);
110 
115  public: bool AllowAutoDisable() const;
116 
121  public: void SetAllowAutoDisable(bool _allowAutoDisable);
122 
127  public: bool EnableWind() const;
128 
132  public: void SetEnableWind(bool _enableWind);
133 
139  public: uint64_t LinkCount() const;
140 
146  public: const Link *LinkByIndex(const uint64_t _index) const;
147 
153  public: const Link *LinkByName(const std::string &_name) const;
154 
160  public: bool LinkNameExists(const std::string &_name) const;
161 
167  public: uint64_t JointCount() const;
168 
174  public: const Joint *JointByIndex(const uint64_t _index) const;
175 
181  public: bool JointNameExists(const std::string &_name) const;
182 
190  public: const Joint *JointByName(const std::string &_name) const;
191 
197  public: uint64_t FrameCount() const;
198 
206  public: const Frame *FrameByIndex(const uint64_t _index) const;
207 
214  public: const Frame *FrameByName(const std::string &_name) const;
215 
221  public: bool FrameNameExists(const std::string &_name) const;
222 
228  public: uint64_t ModelCount() const;
229 
236  public: const Model *ModelByIndex(const uint64_t _index) const;
237 
243  public: bool ModelNameExists(const std::string &_name) const;
244 
252  public: const Model *ModelByName(const std::string &_name) const;
253 
259  public: const ignition::math::Pose3d &RawPose() const;
260 
264  public: void SetRawPose(const ignition::math::Pose3d &_pose);
265 
268  public: const Link *CanonicalLink() const;
269 
274  public: const std::string &CanonicalLinkName() const;
275 
280  public: void SetCanonicalLinkName(const std::string &_canonicalLink);
281 
286  public: const std::string &PoseRelativeTo() const;
287 
292  public: void SetPoseRelativeTo(const std::string &_frame);
293 
298  public: sdf::ElementPtr Element() const;
299 
303  public: sdf::SemanticPose SemanticPose() const;
304 
307  public: const std::string &PlacementFrameName() const;
308 
312  public: void SetPlacementFrameName(const std::string &_name);
313 
318  // TODO(addisu): If the canonical link is inside an interface model, this
319  // function returns {nullptr, name}. This can be problematic for downstream
320  // applications.
321  public: std::pair<const Link *, std::string> CanonicalLinkAndRelativeName()
322  const;
323 
328  public: uint64_t InterfaceModelCount() const;
329 
336  public: std::shared_ptr<const InterfaceModel> InterfaceModelByIndex(
337  const uint64_t _index) const;
338 
346  public: const NestedInclude *InterfaceModelNestedIncludeByIndex(
347  const uint64_t _index) const;
348 
354  private: void SetPoseRelativeToGraph(
356 
362  private: void SetFrameAttachedToGraph(
364 
368  friend class Root;
369  friend class World;
370 
372  IGN_UTILS_IMPL_PTR(dataPtr)
373  };
374  }
375 }
376 #endif
sdf::v12::Joint
Definition: Joint.hh:85
sdf::v12::World
Definition: World.hh:54
sdf::v12::ScopedGraph
Definition: Collision.hh:39
sdf::v12::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::v12::NestedInclude
Contains the necessary information about an included model file for custom model parsers to be able t...
Definition: InterfaceElements.hh:44
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:33
sdf::v12::Model
Definition: Model.hh:48
sdf::v12::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
Types.hh
SemanticPose.hh
sdf::v12::Frame
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:42
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:41
sdf::v12::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::v12::Element
SDF Element class.
Definition: Element.hh:73
sdf::v12::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
system_util.hh
sdf::v12::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
Element.hh