Gazebo Physics

API Reference

5.3.2
gz/physics/Shape.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 
18 #ifndef GZ_PHYSICS_SHAPE_HH_
19 #define GZ_PHYSICS_SHAPE_HH_
20 
24 #include <gz/physics/Geometry.hh>
25 
26 namespace ignition
27 {
28  namespace physics
29  {
33  class IGNITION_PHYSICS_VISIBLE GetShapeKinematicProperties
34  : public virtual Feature
35  {
36  public: template <typename PolicyT, typename FeaturesT>
37  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
38  {
39  public: using PoseType =
40  typename FromPolicy<PolicyT>::template Use<Pose>;
41 
47  public: PoseType GetRelativeTransform() const;
48  };
49 
50  public: template <typename PolicyT>
51  class Implementation : public virtual Feature::Implementation<PolicyT>
52  {
53  public: using PoseType =
54  typename FromPolicy<PolicyT>::template Use<Pose>;
55 
56  public: virtual PoseType GetShapeRelativeTransform(
57  const Identity &_shapeID) const = 0;
58  };
59  };
60 
62  class IGNITION_PHYSICS_VISIBLE SetShapeKinematicProperties
63  : public virtual Feature
64  {
65  public: template <typename PolicyT, typename FeaturesT>
66  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
67  {
68  public: using PoseType =
69  typename FromPolicy<PolicyT>::template Use<Pose>;
70 
77  public: void SetRelativeTransform(const PoseType &_pose);
78  };
79 
80  public: template <typename PolicyT>
81  class Implementation : public virtual Feature::Implementation<PolicyT>
82  {
83  public: using PoseType =
84  typename FromPolicy<PolicyT>::template Use<Pose>;
85 
86  public: virtual void SetShapeRelativeTransform(
87  const Identity &_shapeID, const PoseType &_pose) = 0;
88  };
89  };
90 
94  class IGNITION_PHYSICS_VISIBLE GetShapeCollisionProperties
95  : public virtual Feature
96  {
97  public: template <typename PolicyT, typename FeaturesT>
98  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
99  {
100  public: using Scalar = typename PolicyT::Scalar;
101 
108  public: Scalar GetFrictionCoefficient(
109  const BaseShapePtr<PolicyT> &_other) const;
110 
118  public: Scalar GetRestitutionCoefficient(
119  const BaseShapePtr<PolicyT> &_other) const;
120  };
121 
122  public: template <typename PolicyT>
123  class Implementation : public virtual Feature::Implementation<PolicyT>
124  {
125  public: using Scalar = typename PolicyT::Scalar;
126 
127  public: virtual Scalar GetFrictionCoefficient(
128  const Identity &_shape0, const Identity &_shape1) const = 0;
129 
130  public: virtual Scalar GetRestitutionCoefficient(
131  const Identity &_shape0, const Identity &_shape1) const = 0;
132  };
133  };
134 
138  class IGNITION_PHYSICS_VISIBLE GetShapeBoundingBox
139  : public virtual FeatureWithRequirements<ShapeFrameSemantics>
140  {
141  public: template <typename PolicyT, typename FeaturesT>
142  class Shape
143  : public virtual ShapeFrameSemantics::Shape<PolicyT, FeaturesT>
144  {
145  public: using AlignedBoxType =
146  typename FromPolicy<PolicyT>::template Use<AlignedBox>;
147 
157  public: AlignedBoxType GetAxisAlignedBoundingBox(
158  const FrameID &_referenceFrame = FrameID::World()) const;
159  };
160 
161  public: template <typename PolicyT>
162  class Implementation : public virtual Feature::Implementation<PolicyT>
163  {
164  public: using AlignedBoxType =
165  typename FromPolicy<PolicyT>::template Use<AlignedBox>;
166 
170  public: virtual AlignedBoxType GetShapeAxisAlignedBoundingBox(
171  const Identity &_shape) const = 0;
172  };
173  };
174 
178  class IGNITION_PHYSICS_VISIBLE SetShapeCollisionProperties
179  : public virtual Feature
180  {
181  public: template <typename PolicyT, typename FeaturesT>
182  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
183  {
184  public: using Scalar = typename PolicyT::Scalar;
185 
193  public: void SetFrictionCoefficient(
194  const BaseShapePtr<PolicyT> &_other, Scalar _value);
195 
203  public: void SetRestitutionCoefficient(
204  const BaseShapePtr<PolicyT> &_other, Scalar _value);
205  };
206 
207  public: template <typename PolicyT>
208  class Implementation : public virtual Feature::Implementation<PolicyT>
209  {
210  public: using Scalar = typename PolicyT::Scalar;
211 
212  public: virtual void SetShapeFrictionCoefficient(
213  const Identity &_shape0,
214  const Identity &_shape1,
215  Scalar _value) = 0;
216 
217  public: virtual void SetShapeRestitutionCoefficient(
218  const Identity &_shape0,
219  const Identity &_shape1,
220  Scalar _value) = 0;
221  };
222  };
223 
225  class IGNITION_PHYSICS_VISIBLE CollisionFilterMaskFeature
226  : public virtual Feature
227  {
228  public: template <typename PolicyT, typename FeaturesT>
229  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
230  {
235  public: void SetCollisionFilterMask(const uint16_t _mask);
236 
239  public: uint16_t GetCollisionFilterMask() const;
240 
242  public: void RemoveCollisionFilterMask();
243  };
244 
245  public: template <typename PolicyT>
246  class Implementation : public virtual Feature::Implementation<PolicyT>
247  {
248  public: virtual void SetCollisionFilterMask(
249  const Identity &_shapeID, const uint16_t _mask) = 0;
250 
251  public: virtual uint16_t GetCollisionFilterMask(
252  const Identity &_shapeID) const = 0;
253 
254  public: virtual void RemoveCollisionFilterMask(
255  const Identity &_shapeID) = 0;
256  };
257  };
258 
262  class IGNITION_PHYSICS_VISIBLE GetShapeFrictionPyramidSlipCompliance
263  : public virtual Feature
264  {
265  public: template <typename PolicyT, typename FeaturesT>
266  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
267  {
268  public: using Scalar = typename PolicyT::Scalar;
269 
274  public: Scalar GetPrimarySlipCompliance() const;
275 
280  public: Scalar GetSecondarySlipCompliance() const;
281  };
282 
283  public: template <typename PolicyT>
284  class Implementation : public virtual Feature::Implementation<PolicyT>
285  {
286  public: using Scalar = typename PolicyT::Scalar;
287 
288  public: virtual Scalar GetShapeFrictionPyramidPrimarySlipCompliance(
289  const Identity &_shapeID) const = 0;
290 
291  public: virtual Scalar GetShapeFrictionPyramidSecondarySlipCompliance(
292  const Identity &_shapeID) const = 0;
293  };
294  };
295 
299  class IGNITION_PHYSICS_VISIBLE SetShapeFrictionPyramidSlipCompliance
300  : public virtual Feature
301  {
302  public: template <typename PolicyT, typename FeaturesT>
303  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
304  {
305  public: using Scalar = typename PolicyT::Scalar;
306 
313  public: bool SetPrimarySlipCompliance(Scalar _value);
314 
321  public: bool SetSecondarySlipCompliance(Scalar _value);
322  };
323 
324  public: template <typename PolicyT>
325  class Implementation : public virtual Feature::Implementation<PolicyT>
326  {
327  public: using Scalar = typename PolicyT::Scalar;
328 
329  public: virtual bool SetShapeFrictionPyramidPrimarySlipCompliance(
330  const Identity &_shapeID, Scalar _value) = 0;
331 
332  public: virtual bool SetShapeFrictionPyramidSecondarySlipCompliance(
333  const Identity &_shapeID, Scalar _value) = 0;
334  };
335  };
336  }
337 }
338 
339 #include <gz/physics/detail/Shape.hh>
340 
341 #endif
If your feature is known to require any other features, then you should have your feature class inher...
Definition: gz/physics/FeatureList.hh:118
Placeholder class in case a Feature does not define its own Shape API.
Definition: gz/physics/Feature.hh:85
virtual uint16_t GetCollisionFilterMask(const Identity &_shapeID) const =0
void SetCollisionFilterMask(const uint16_t _mask)
Set the collision filter bitmask of this shape.
bool SetPrimarySlipCompliance(Scalar _value)
Set the slip compliance for the first friction direction of a friction pyramid model.
This feature retrieves the shape's axis aligned bounding box in the requested frame....
Definition: gz/physics/Shape.hh:138
typename FromPolicy< PolicyT >::template Use< AlignedBox > AlignedBoxType
Definition: gz/physics/Shape.hh:165
bool SetSecondarySlipCompliance(Scalar _value)
Set the slip compliance for the second friction direction of a friction pyramid model.
uint16_t GetCollisionFilterMask() const
Get the collision filter bitmask of this shape.
This struct is used to conveniently convert from a policy to a geometric type. Example usage:
Definition: gz/physics/Geometry.hh:77
Scalar GetRestitutionCoefficient(const BaseShapePtr< PolicyT > &_other) const
Get the coefficient of restitution between this shape and another shape.
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:125
virtual Scalar GetShapeFrictionPyramidPrimarySlipCompliance(const Identity &_shapeID) const =0
virtual bool SetShapeFrictionPyramidSecondarySlipCompliance(const Identity &_shapeID, Scalar _value)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:327
virtual Scalar GetShapeFrictionPyramidSecondarySlipCompliance(const Identity &_shapeID) const =0
virtual void SetShapeFrictionCoefficient(const Identity &_shape0, const Identity &_shape1, Scalar _value)=0
Container for specifying Frame IDs. We do not want to use a generic integer type for this,...
Definition: gz/physics/FrameID.hh:46
void RemoveCollisionFilterMask()
Removes the collision filter bitmask from this shape.
virtual void SetShapeRestitutionCoefficient(const Identity &_shape0, const Identity &_shape1, Scalar _value)=0
virtual bool SetShapeFrictionPyramidPrimarySlipCompliance(const Identity &_shapeID, Scalar _value)=0
This feature retrieves the shape collision properties such as the shape surface friction coefficient ...
Definition: gz/physics/Shape.hh:94
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:184
This feature sets the Shape collision properties such as the Shape surface friction coefficient and r...
Definition: gz/physics/Shape.hh:178
virtual AlignedBoxType GetShapeAxisAlignedBoundingBox(const Identity &_shape) const =0
Implementation function for querying the axis-aligned bounding box of a shape.
typename FromPolicy< PolicyT >::template Use< Pose > PoseType
Definition: gz/physics/Shape.hh:40
virtual PoseType GetShapeRelativeTransform(const Identity &_shapeID) const =0
virtual void SetShapeRelativeTransform(const Identity &_shapeID, const PoseType &_pose)=0
virtual void SetCollisionFilterMask(const Identity &_shapeID, const uint16_t _mask)=0
typename FromPolicy< PolicyT >::template Use< Pose > PoseType
Definition: gz/physics/Shape.hh:69
typename FromPolicy< PolicyT >::template Use< Pose > PoseType
Definition: gz/physics/Shape.hh:84
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:210
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:268
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:286
void SetFrictionCoefficient(const BaseShapePtr< PolicyT > &_other, Scalar _value)
Set the coefficient of friction between this shape and another shape.
Definition: gz/physics/Feature.hh:92
This class defines the concept of a Feature. It should be inherited by classes that define some plugi...
Definition: gz/physics/Feature.hh:35
This feature retrieves the shape kinematic properties such as the the relative transform from the the...
Definition: gz/physics/Shape.hh:33
This feature retrieves the shape's slip compliance of the first and second friction direction in the ...
Definition: gz/physics/Shape.hh:262
This feature sets the Shape's slip compliance of the first and second friction direction in the frict...
Definition: gz/physics/Shape.hh:299
PoseType GetRelativeTransform() const
Get the transform from the Link frame to the frame of this Shape.
Definition: gz/physics/Shape.hh:62
Scalar GetFrictionCoefficient(const BaseShapePtr< PolicyT > &_other) const
Get the coefficient of friction between this shape and another shape.
void SetRestitutionCoefficient(const BaseShapePtr< PolicyT > &_other, Scalar _value)
Set the coefficient of restitution between this shape and another shape.
Definition: gz/physics/Shape.hh:225
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:305
void SetRelativeTransform(const PoseType &_pose)
Set the transform from the Link frame to the frame of this Shape.
AlignedBoxType GetAxisAlignedBoundingBox(const FrameID &_referenceFrame=FrameID::World()) const
Get the axis aligned bounding box for the shape in the requested frame.
virtual void RemoveCollisionFilterMask(const Identity &_shapeID)=0
Definition: gz/physics/Shape.hh:142
typename FromPolicy< PolicyT >::template Use< AlignedBox > AlignedBoxType
Definition: gz/physics/Shape.hh:146
virtual Scalar GetRestitutionCoefficient(const Identity &_shape0, const Identity &_shape1) const =0
static const FrameID & World()
Get a reference to the world Frame.
Scalar GetSecondarySlipCompliance() const
Get the slip compliance for the second friction direction of a friction pyramid model.
Scalar GetPrimarySlipCompliance() const
Get the slip compliance for the first friction direction of a friction pyramid model.
virtual Scalar GetFrictionCoefficient(const Identity &_shape0, const Identity &_shape1) const =0
typename FromPolicy< PolicyT >::template Use< Pose > PoseType
Definition: gz/physics/Shape.hh:54
Base class for the API of a Frame. This will be inherited by any objects that are able to express Fra...
Definition: gz/physics/FrameSemantics.hh:41
typename PolicyT::Scalar Scalar
Definition: gz/physics/Shape.hh:100
Definition: gz/physics/Shape.hh:229