Loading...
Searching...
No Matches
Collision.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_COLLISION_HH_
18#define SDF_COLLISION_HH_
19
20#include <memory>
21#include <optional>
22#include <string>
23#include <gz/math/Pose3.hh>
24#include <gz/math/Vector3.hh>
25#include <gz/math/Inertial.hh>
26#include <gz/utils/ImplPtr.hh>
27#include "sdf/Element.hh"
28#include "sdf/SemanticPose.hh"
29#include "sdf/Types.hh"
30#include "sdf/config.hh"
31#include "sdf/system_util.hh"
32#include "sdf/ParserConfig.hh"
33
34namespace sdf
35{
36 // Inline bracket to help doxygen filtering.
37 inline namespace SDF_VERSION_NAMESPACE {
38 //
39 // Forward declaration.
40 class Geometry;
41 class ParserConfig;
42 class Surface;
43 struct PoseRelativeToGraph;
44 template <typename T> class ScopedGraph;
45
51 {
53 public: Collision();
54
61 public: Errors Load(ElementPtr _sdf);
62
70 public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
71
75 public: std::string Name() const;
76
80 public: void SetName(const std::string &_name);
81
85 public: static double DensityDefault();
86
89 public: double Density() const;
90
93 public: void SetDensity(double _density);
94
100
105 public: void SetAutoInertiaParams(const sdf::ElementPtr _autoInertiaParams);
106
109 public: const Geometry *Geom() const;
110
113 public: void SetGeom(const Geometry &_geom);
114
117 public: const sdf::Surface *Surface() const;
118
121 public: void SetSurface(const sdf::Surface &_surface);
122
127 public: const gz::math::Pose3d &RawPose() const;
128
132 public: void SetRawPose(const gz::math::Pose3d &_pose);
133
138 public: const std::string &PoseRelativeTo() const;
139
144 public: void SetPoseRelativeTo(const std::string &_frame);
145
150
157 public: void CalculateInertial(sdf::Errors &_errors,
158 gz::math::Inertiald &_inertial,
159 const ParserConfig &_config);
160
169 // if this collision's density has not been explicitly set.
173 public: void CalculateInertial(
174 sdf::Errors &_errors,
175 gz::math::Inertiald &_inertial,
176 const ParserConfig &_config,
177 const std::optional<double> &_density,
178 sdf::ElementPtr _autoInertiaParams);
179
184 public: sdf::ElementPtr Element() const;
185
191 public: sdf::ElementPtr ToElement() const;
192
199 public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
200
205 private: void SetXmlParentName(const std::string &_xmlParentName);
206
211 private: void SetPoseRelativeToGraph(
213
217 friend class Link;
218
220 GZ_UTILS_IMPL_PTR(dataPtr)
221 };
222 }
223}
224#endif
A collision element descibes the collision properties associated with a link.
Definition Collision.hh:51
void SetRawPose(const gz::math::Pose3d &_pose)
Set the pose of the collision object.
sdf::ElementPtr AutoInertiaParams() const
Get the ElementPtr to the <auto_inertia_params> element This element can be used as a parent element ...
static double DensityDefault()
Get the default density of a collision if its density is not specified.
void CalculateInertial(sdf::Errors &_errors, gz::math::Inertiald &_inertial, const ParserConfig &_config)
Calculate and return the MassMatrix for the collision.
void SetSurface(const sdf::Surface &_surface)
Set the collision's surface parameters.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
const gz::math::Pose3d & RawPose() const
Get the pose of the collision object.
const sdf::Surface * Surface() const
Get a pointer to the collisions's surface parameters.
double Density() const
Get the density of the collision.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
void SetAutoInertiaParams(const sdf::ElementPtr _autoInertiaParams)
Function to set the auto inertia params using a sdf ElementPtr object.
Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
Load the collision based on a element pointer.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this collision.
Errors Load(ElementPtr _sdf)
Load the collision based on a element pointer.
std::string Name() const
Get the name of the collision.
void CalculateInertial(sdf::Errors &_errors, gz::math::Inertiald &_inertial, const ParserConfig &_config, const std::optional< double > &_density, sdf::ElementPtr _autoInertiaParams)
Calculate and return the MassMatrix for the collision.
void SetDensity(double _density)
Set the density of the collision.
void SetGeom(const Geometry &_geom)
Set the collision's geometry.
sdf::ElementPtr ToElement(sdf::Errors &_errors) const
Create and return an SDF element filled with data from this collision.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
const Geometry * Geom() const
Get a pointer to the collisions's geometry.
void SetName(const std::string &_name)
Set the name of the collision.
Geometry provides access to a shape, such as a Box.
Definition Geometry.hh:93
This class contains configuration options for the libsdformat parser.
Definition ParserConfig.hh:106
Definition Collision.hh:44
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition SemanticPose.hh:55
Surface information for a collision.
Definition Surface.hh:305
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:81
std::shared_ptr< Element > ElementPtr
Definition Element.hh:55
namespace for Simulation Description Format parser
Definition Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:25