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 
80  public: std::string Name() const;
81 
85  public: void SetName(const std::string &_name);
86 
91  public: bool Static() const;
92 
97  public: void SetStatic(bool _static);
98 
104  public: bool SelfCollide() const;
105 
110  public: void SetSelfCollide(bool _selfCollide);
111 
116  public: bool AllowAutoDisable() const;
117 
122  public: void SetAllowAutoDisable(bool _allowAutoDisable);
123 
128  public: bool EnableWind() const;
129 
133  public: void SetEnableWind(bool _enableWind);
134 
137  public: uint64_t LinkCount() const;
138 
144  public: const Link *LinkByIndex(const uint64_t _index) const;
145 
149  public: const Link *LinkByName(const std::string &_name) const;
150 
154  public: bool LinkNameExists(const std::string &_name) const;
155 
158  public: uint64_t JointCount() const;
159 
165  public: const Joint *JointByIndex(const uint64_t _index) const;
166 
170  public: bool JointNameExists(const std::string &_name) const;
171 
177  public: const Joint *JointByName(const std::string &_name) const;
178 
181  public: uint64_t FrameCount() const;
182 
189  public: const Frame *FrameByIndex(const uint64_t _index) const;
190 
195  public: const Frame *FrameByName(const std::string &_name) const;
196 
200  public: bool FrameNameExists(const std::string &_name) const;
201 
204  public: uint64_t ModelCount() const;
205 
211  public: const Model *ModelByIndex(const uint64_t _index) const;
212 
216  public: bool ModelNameExists(const std::string &_name) const;
217 
223  public: const Model *ModelByName(const std::string &_name) const;
224 
231  public: const ignition::math::Pose3d &Pose() const
232  SDF_DEPRECATED(9.0);
233 
238  public: void SetPose(const ignition::math::Pose3d &_pose)
239  SDF_DEPRECATED(9.0);
240 
246  public: const ignition::math::Pose3d &RawPose() const;
247 
251  public: void SetRawPose(const ignition::math::Pose3d &_pose);
252 
255  public: const Link *CanonicalLink() const;
256 
261  public: const std::string &CanonicalLinkName() const;
262 
267  public: void SetCanonicalLinkName(const std::string &_canonicalLink);
268 
273  public: const std::string &PoseRelativeTo() const;
274 
279  public: void SetPoseRelativeTo(const std::string &_frame);
280 
286  public: const std::string &PoseFrame() const
287  SDF_DEPRECATED(9.0);
288 
294  public: void SetPoseFrame(const std::string &_frame)
295  SDF_DEPRECATED(9.0);
296 
301  public: sdf::ElementPtr Element() const;
302 
306  public: sdf::SemanticPose SemanticPose() const;
307 
313  private: sdf::Errors SetPoseRelativeToGraph(
314  std::weak_ptr<const PoseRelativeToGraph> _graph);
315 
320  private: std::pair<const Link *, std::string> CanonicalLinkAndRelativeName()
321  const;
322 
324  friend class World;
325 
328  friend std::pair<const Link *, std::string>
329  modelCanonicalLinkAndRelativeName(const Model *);
330 
332  private: ModelPrivate *dataPtr = nullptr;
333  };
334  }
335 }
336 #endif
sdf::v9::Model::FrameByIndex
const Frame * FrameByIndex(const uint64_t _index) const
Get an explicit frame based on an index.
sdf::v9::Model::ModelByName
const Model * ModelByName(const std::string &_name) const
Get a nested model based on a name.
sdf::v9::Model::ModelByIndex
const Model * ModelByIndex(const uint64_t _index) const
Get a nested model based on an index.
sdf::v9::Model::SelfCollide
bool SelfCollide() const
Check if this model should self-collide.
sdf::v9::Model::JointCount
uint64_t JointCount() const
Get the number of joints.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:33
sdf::v9::Model::JointByName
const Joint * JointByName(const std::string &_name) const
Get a joint based on a name.
sdf::v9::Model::SetName
void SetName(const std::string &_name)
Set the name of the model.
sdf::v9::Model::FrameByName
const Frame * FrameByName(const std::string &_name) const
Get an explicit frame based on a name.
sdf::v9::Model::Load
Errors Load(ElementPtr _sdf)
Load the model based on a element pointer.
sdf::v9::Model::~Model
~Model()
Destructor.
sdf::v9::Model::Name
std::string Name() const
Get the name of the model.
sdf::v9::Model::operator=
Model & operator=(Model &&_model)
Move assignment operator.
sdf::v9::Model::operator=
Model & operator=(const Model &_model)
Copy assignment operator.
Types.hh
SemanticPose.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
sdf::v9::Model::JointByIndex
const Joint * JointByIndex(const uint64_t _index) const
Get a joint based on an index.
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
sdf::v9::World
Definition: World.hh:46
sdf::v9::Model::SetSelfCollide
void SetSelfCollide(bool _selfCollide)
Set this model to self-collide or not self-collide.
sdf::v9::Model::FrameCount
uint64_t FrameCount() const
Get the number of explicit frames.
sdf::v9::Joint
Definition: Joint.hh:83
sdf::v9::Model::AllowAutoDisable
bool AllowAutoDisable() const
Check if this model should be allowed to auto-disable.
sdf::v9::SDF_DEPRECATED
class SDFORMAT_VISIBLE SDF_DEPRECATED(9.2) URDF2SDF
URDF to SDF converter.
Definition: parser_urdf.hh:40
sdf::v9::Model::Static
bool Static() const
Check if this model should be static.
sdf::v9::Model::JointNameExists
bool JointNameExists(const std::string &_name) const
Get whether a joint name exists.
sdf::v9::Frame
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:42
sdf::v9::Model::ModelNameExists
bool ModelNameExists(const std::string &_name) const
Get whether a nested model name exists.
sdf::v9::Model::LinkCount
uint64_t LinkCount() const
Get the number of links.
sdf::v9::Element
SDF Element class.
Definition: Element.hh:70
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:54
sdf::v9::Model::SetAllowAutoDisable
void SetAllowAutoDisable(bool _allowAutoDisable)
Set this model to allow auto-disabling.
sdf::v9::Model::Model
Model(Model &&_model) noexcept
Move constructor.
sdf::v9::Model::ModelCount
uint64_t ModelCount() const
Get the number of nested models.
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::Model::LinkNameExists
bool LinkNameExists(const std::string &_name) const
Get whether a link name exists.
sdf::v9::Model::Pose
const ignition::math::Pose3d & Pose() const SDF_DEPRECATED(9.0)
Get the pose of the model.
sdf::v9::Model::SetEnableWind
void SetEnableWind(bool _enableWind)
Set whether this model should be subject to wind.
sdf::v9::Model
Definition: Model.hh:44
sdf::v9::Model::LinkByName
const Link * LinkByName(const std::string &_name) const
Get a link based on a name.
system_util.hh
sdf::v9::Model::FrameNameExists
bool FrameNameExists(const std::string &_name) const
Get whether an explicit frame name exists.
sdf::v9::Model::Model
Model(const Model &_model)
Copy constructor.
sdf::v9::Model::Model
Model()
Default constructor.
sdf::v9::Model::LinkByIndex
const Link * LinkByIndex(const uint64_t _index) const
Get a link based on an index.
sdf::v9::Model::SetStatic
void SetStatic(bool _static)
Set this model to be static or not static.
sdf::v9::Model::EnableWind
bool EnableWind() const
Check if this model should be subject to wind.
Element.hh