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
31namespace 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
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
347 const uint64_t _index) const;
348
353 public: bool AddLink(const Link &_link);
354
359 public: bool AddJoint(const Joint &_joint);
360
365 public: bool AddModel(const Model &_model);
366
368 public: void ClearLinks();
369
371 public: void ClearJoints();
372
374 public: void ClearModels();
375
381 private: void SetPoseRelativeToGraph(
383
389 private: void SetFrameAttachedToGraph(
391
395 friend class Root;
396 friend class World;
397
399 IGN_UTILS_IMPL_PTR(dataPtr)
400 };
401 }
402}
403#endif
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:43
Definition: Joint.hh:86
Definition: Model.hh:49
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
const Model * ModelByName(const std::string &_name) const
Get a nested model based on a name.
void SetSelfCollide(bool _selfCollide)
Set this model to self-collide or not self-collide.
void SetRawPose(const ignition::math::Pose3d &_pose)
Set the pose of the model.
bool EnableWind() const
Check if this model should be subject to wind.
bool AddLink(const Link &_link)
Add a link to the model.
const Model * ModelByIndex(const uint64_t _index) const
Get an immediate (not recursively nested) child model based on an index.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
const Frame * FrameByName(const std::string &_name) const
Get an explicit frame based on a name.
bool Static() const
Check if this model should be static.
bool ModelNameExists(const std::string &_name) const
Get whether a nested model name exists.
void SetStatic(bool _static)
Set this model to be static or not static.
bool AddModel(const Model &_model)
Add a model to the model.
const std::string & PlacementFrameName() const
Get the name of the placement frame of the model.
bool LinkNameExists(const std::string &_name) const
Get whether a link name exists.
void ClearJoints()
Remove all joints.
uint64_t InterfaceModelCount() const
Get the number of nested interface models that are immediate (not recursively nested) children of thi...
bool JointNameExists(const std::string &_name) const
Get whether a joint name exists.
const ignition::math::Pose3d & RawPose() const
Get the pose of the model.
const NestedInclude * InterfaceModelNestedIncludeByIndex(const uint64_t _index) const
Get the nested include information of an immediate (not recursively nested) child interface model bas...
bool AddJoint(const Joint &_joint)
Add a joint to the model.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
std::pair< const Link *, std::string > CanonicalLinkAndRelativeName() const
Get the model's canonical link and the nested name of the link relative to the current model,...
std::shared_ptr< const InterfaceModel > InterfaceModelByIndex(const uint64_t _index) const
Get an immediate (not recursively nested) child interface model based on an index.
bool AllowAutoDisable() const
Check if this model should be allowed to auto-disable.
Model()
Default constructor.
void ClearLinks()
Remove all links.
Errors ValidateGraphs() const
Check that the FrameAttachedToGraph and PoseRelativeToGraph are valid.
const Joint * JointByIndex(const uint64_t _index) const
Get an immediate (not nested) child joint based on an index.
bool SelfCollide() const
Check if this model should self-collide.
uint64_t FrameCount() const
Get the number of explicit frames that are immediate (not nested) children of this Model object.
void ClearModels()
Remove all models.
bool FrameNameExists(const std::string &_name) const
Get whether an explicit frame name exists.
const Frame * FrameByIndex(const uint64_t _index) const
Get an immediate (not nested) child explicit frame based on an index.
std::string Name() const
Get the name of the model.
const std::string & CanonicalLinkName() const
Get the name of the model's canonical link.
uint64_t LinkCount() const
Get the number of links that are immediate (not nested) children of this Model object.
const Link * LinkByName(const std::string &_name) const
Get a link based on a name.
Errors Load(ElementPtr _sdf)
Load the model based on a element pointer.
void SetName(const std::string &_name)
Set the name of the model.
const Joint * JointByName(const std::string &_name) const
Get a joint based on a name.
Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
Load the model based on a element pointer.
void SetAllowAutoDisable(bool _allowAutoDisable)
Set this model to allow auto-disabling.
uint64_t ModelCount() const
Get the number of nested models that are immediate (not recursively nested) children of this Model ob...
void SetCanonicalLinkName(const std::string &_canonicalLink)
Set the name of the model's canonical link.
void SetPlacementFrameName(const std::string &_name)
Set the name of the placement frame of the model.
const Link * LinkByIndex(const uint64_t _index) const
Get an immediate (not nested) child link based on an index.
const Link * CanonicalLink() const
Get the model's canonical link.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
uint64_t JointCount() const
Get the number of joints that are immediate (not nested) children of this Model object.
void SetEnableWind(bool _enableWind)
Set whether this model should be subject to wind.
Contains the necessary information about an included model file for custom model parsers to be able t...
Definition: InterfaceElements.hh:45
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:85
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:55
Definition: Collision.hh:39
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:55
Definition: World.hh:55
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
namespace for Simulation Description Format parser
Definition: Actor.hh:34
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41