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 "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 Frame;
38  class Joint;
39  class Link;
40  class ModelPrivate;
41  struct PoseRelativeToGraph;
42 
44  {
46  public: Model();
47 
50  public: Model(const Model &_model);
51 
54  public: Model(Model &&_model) noexcept;
55 
59  public: Model &operator=(Model &&_model);
60 
64  public: Model &operator=(const Model &_model);
65 
67  public: ~Model();
68 
75  public: Errors Load(ElementPtr _sdf);
76 
81  public: Errors ValidateGraphs() const;
82 
86  public: std::string Name() const;
87 
91  public: void SetName(const std::string &_name);
92 
97  public: bool Static() const;
98 
103  public: void SetStatic(bool _static);
104 
110  public: bool SelfCollide() const;
111 
116  public: void SetSelfCollide(bool _selfCollide);
117 
122  public: bool AllowAutoDisable() const;
123 
128  public: void SetAllowAutoDisable(bool _allowAutoDisable);
129 
134  public: bool EnableWind() const;
135 
139  public: void SetEnableWind(bool _enableWind);
140 
143  public: uint64_t LinkCount() const;
144 
150  public: const Link *LinkByIndex(const uint64_t _index) const;
151 
155  public: const Link *LinkByName(const std::string &_name) const;
156 
160  public: bool LinkNameExists(const std::string &_name) const;
161 
164  public: uint64_t JointCount() const;
165 
171  public: const Joint *JointByIndex(const uint64_t _index) const;
172 
176  public: bool JointNameExists(const std::string &_name) const;
177 
183  public: const Joint *JointByName(const std::string &_name) const;
184 
187  public: uint64_t FrameCount() const;
188 
195  public: const Frame *FrameByIndex(const uint64_t _index) const;
196 
201  public: const Frame *FrameByName(const std::string &_name) const;
202 
206  public: bool FrameNameExists(const std::string &_name) const;
207 
210  public: uint64_t ModelCount() const;
211 
217  public: const Model *ModelByIndex(const uint64_t _index) const;
218 
222  public: bool ModelNameExists(const std::string &_name) const;
223 
229  public: const Model *ModelByName(const std::string &_name) const;
230 
236  public: const ignition::math::Pose3d &RawPose() const;
237 
241  public: void SetRawPose(const ignition::math::Pose3d &_pose);
242 
245  public: const Link *CanonicalLink() const;
246 
251  public: const std::string &CanonicalLinkName() const;
252 
257  public: void SetCanonicalLinkName(const std::string &_canonicalLink);
258 
263  public: const std::string &PoseRelativeTo() const;
264 
269  public: void SetPoseRelativeTo(const std::string &_frame);
270 
275  public: sdf::ElementPtr Element() const;
276 
280  public: sdf::SemanticPose SemanticPose() const;
281 
287  private: sdf::Errors SetPoseRelativeToGraph(
288  std::weak_ptr<const PoseRelativeToGraph> _graph);
289 
294  private: std::pair<const Link *, std::string> CanonicalLinkAndRelativeName()
295  const;
296 
298  friend class World;
299 
302  friend std::pair<const Link *, std::string>
303  modelCanonicalLinkAndRelativeName(const Model *);
304 
306  private: ModelPrivate *dataPtr = nullptr;
307  };
308  }
309 }
310 #endif
Definition: Model.hh:43
Definition: World.hh:45
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:53
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:41
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
namespace for Simulation Description Format parser
Definition: Actor.hh:32
Definition: Joint.hh:83
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95