Loading...
Searching...
No Matches
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
30namespace 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 ignition::math::Pose3d &Pose() const
238 SDF_DEPRECATED(9.0);
239
244 public: void SetPose(const ignition::math::Pose3d &_pose)
245 SDF_DEPRECATED(9.0);
246
252 public: const ignition::math::Pose3d &RawPose() const;
253
257 public: void SetRawPose(const ignition::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
#define SDF_DEPRECATED(version)
Definition Types.hh:38
SDF Element class.
Definition Element.hh:74
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition Frame.hh:42
Definition Joint.hh:84
Definition Model.hh:44
void SetStatic(bool _static)
Set this model to be static or not static.
void SetSelfCollide(bool _selfCollide)
Set this model to self-collide or not self-collide.
Model()
Default constructor.
const Joint * JointByIndex(const uint64_t _index) const
Get a joint based on an index.
const Link * LinkByIndex(const uint64_t _index) const
Get a link based on an index.
Model & operator=(Model &&_model)
Move assignment operator.
uint64_t FrameCount() const
Get the number of explicit frames.
bool Static() const
Check if this model should be static.
const Frame * FrameByIndex(const uint64_t _index) const
Get an explicit frame based on an index.
const Link * LinkByName(const std::string &_name) const
Get a link based on a name.
uint64_t ModelCount() const
Get the number of nested models.
Model(Model &&_model) noexcept
Move constructor.
void SetAllowAutoDisable(bool _allowAutoDisable)
Set this model to allow auto-disabling.
bool FrameNameExists(const std::string &_name) const
Get whether an explicit frame name exists.
void SetName(const std::string &_name)
Set the name of the model.
bool AllowAutoDisable() const
Check if this model should be allowed to auto-disable.
Errors Load(ElementPtr _sdf)
Load the model based on a element pointer.
bool LinkNameExists(const std::string &_name) const
Get whether a link name exists.
bool ModelNameExists(const std::string &_name) const
Get whether a nested model name exists.
Errors ValidateGraphs() const
Check that the FrameAttachedToGraph and PoseRelativeToGraph are valid.
bool SelfCollide() const
Check if this model should self-collide.
const Joint * JointByName(const std::string &_name) const
Get a joint based on a name.
bool JointNameExists(const std::string &_name) const
Get whether a joint name exists.
Model & operator=(const Model &_model)
Copy assignment operator.
const Model * ModelByIndex(const uint64_t _index) const
Get a nested model based on an index.
void SetEnableWind(bool _enableWind)
Set whether this model should be subject to wind.
~Model()
Destructor.
uint64_t JointCount() const
Get the number of joints.
Model(const Model &_model)
Copy constructor.
std::string Name() const
Get the name of the model.
const Model * ModelByName(const std::string &_name) const
Get a nested model based on a name.
const ignition::math::Pose3d & Pose() const SDF_DEPRECATED(9.0)
Get the pose of the model.
const Frame * FrameByName(const std::string &_name) const
Get an explicit frame based on a name.
uint64_t LinkCount() const
Get the number of links.
bool EnableWind() const
Check if this model should be subject to wind.
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition SemanticPose.hh:54
Definition World.hh:46
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:89
std::shared_ptr< Element > ElementPtr
Definition Element.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48