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 <gz/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 
237  public: const gz::math::Pose3d &Pose() const
238  SDF_DEPRECATED(9.0);
239 
244  public: void SetPose(const gz::math::Pose3d &_pose)
245  SDF_DEPRECATED(9.0);
246 
252  public: const gz::math::Pose3d &RawPose() const;
253 
257  public: void SetRawPose(const gz::math::Pose3d &_pose);
258 
261  public: const Link *CanonicalLink() const;
262 
267  public: const std::string &CanonicalLinkName() const;
268 
273  public: void SetCanonicalLinkName(const std::string &_canonicalLink);
274 
279  public: const std::string &PoseRelativeTo() const;
280 
285  public: void SetPoseRelativeTo(const std::string &_frame);
286 
292  public: const std::string &PoseFrame() const
293  SDF_DEPRECATED(9.0);
294 
300  public: void SetPoseFrame(const std::string &_frame)
301  SDF_DEPRECATED(9.0);
302 
307  public: sdf::ElementPtr Element() const;
308 
312  public: sdf::SemanticPose SemanticPose() const;
313 
319  private: sdf::Errors SetPoseRelativeToGraph(
320  std::weak_ptr<const PoseRelativeToGraph> _graph);
321 
326  private: std::pair<const Link *, std::string> CanonicalLinkAndRelativeName()
327  const;
328 
330  friend class World;
331 
334  friend std::pair<const Link *, std::string>
335  modelCanonicalLinkAndRelativeName(const Model *);
336 
338  private: ModelPrivate *dataPtr = nullptr;
339  };
340  }
341 }
342 #endif
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
Types.hh
SemanticPose.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v9::World
Definition: World.hh:45
sdf::v9::Joint
Definition: Joint.hh:83
sdf::v9::SDF_DEPRECATED
class SDFORMAT_VISIBLE SDF_DEPRECATED(9.2) URDF2SDF
URDF to SDF converter.
Definition: parser_urdf.hh:40
sdf::v9::Frame
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:41
sdf::v9::SemanticPose
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:53
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::Model
Definition: Model.hh:43
system_util.hh
sdf::v9::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
Element.hh