Gazebo Physics

API Reference

5.3.2
gz/physics/CapsuleShape.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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_CAPSULESHAPE_HH_
19 #define GZ_PHYSICS_CAPSULESHAPE_HH_
20 
21 #include <string>
22 
24 #include <gz/physics/Geometry.hh>
25 
26 namespace ignition
27 {
28  namespace physics
29  {
30  IGN_PHYSICS_DECLARE_SHAPE_TYPE(CapsuleShape)
31 
32  class IGNITION_PHYSICS_VISIBLE GetCapsuleShapeProperties
33  : public virtual FeatureWithRequirements<CapsuleShapeCast>
34  {
35  public: template <typename PolicyT, typename FeaturesT>
36  class CapsuleShape : public virtual Entity<PolicyT, FeaturesT>
37  {
38  public: using Scalar = typename PolicyT::Scalar;
39 
42  public: Scalar GetRadius() const;
43 
47  public: Scalar GetLength() const;
48  };
49 
50  public: template <typename PolicyT>
51  class Implementation : public virtual Feature::Implementation<PolicyT>
52  {
53  public: using Scalar = typename PolicyT::Scalar;
54 
55  public: virtual Scalar GetCapsuleShapeRadius(
56  const Identity &_capsuleID) const = 0;
57 
58  public: virtual Scalar GetCapsuleShapeLength(
59  const Identity &_capsuleID) const = 0;
60  };
61  };
62 
66  class IGNITION_PHYSICS_VISIBLE SetCapsuleShapeProperties
67  : public virtual FeatureWithRequirements<CapsuleShapeCast>
68  {
69  public: template <typename PolicyT, typename FeaturesT>
70  class CapsuleShape : public virtual Entity<PolicyT, FeaturesT>
71  {
72  public: using Scalar = typename PolicyT::Scalar;
73 
77  public: void SetRadius(Scalar _radius);
78 
82  public: void SetLength(Scalar length);
83  };
84 
85  public: template <typename PolicyT>
86  class Implementation : public virtual Feature::Implementation<PolicyT>
87  {
88  public: using Scalar = typename PolicyT::Scalar;
89 
90  public: virtual void SetCapsuleShapeRadius(
91  const Identity &_capsuleID, Scalar _radius) = 0;
92 
93  public: virtual void SetCapsuleShapeLength(
94  const Identity &_capsuleID, Scalar _length) = 0;
95  };
96  };
97 
102  class IGNITION_PHYSICS_VISIBLE AttachCapsuleShapeFeature
103  : public virtual FeatureWithRequirements<CapsuleShapeCast>
104  {
105  public: template <typename PolicyT, typename FeaturesT>
106  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
107  {
108  public: using Scalar = typename PolicyT::Scalar;
109 
110  public: using PoseType =
111  typename FromPolicy<PolicyT>::template Use<Pose>;
112 
113  public: using ShapePtrType = CapsuleShapePtr<PolicyT, FeaturesT>;
114 
123  public: ShapePtrType AttachCapsuleShape(
124  const std::string &_name = "capsule",
125  Scalar _radius = 0.5,
126  Scalar _length = 1.0,
127  const PoseType &_pose = PoseType::Identity());
128  };
129 
130  public: template <typename PolicyT>
131  class Implementation : public virtual Feature::Implementation<PolicyT>
132  {
133  public: using Scalar = typename PolicyT::Scalar;
134 
135  public: using PoseType =
136  typename FromPolicy<PolicyT>::template Use<Pose>;
137 
138  public: virtual Identity AttachCapsuleShape(
139  const Identity &_linkID,
140  const std::string &_name,
141  Scalar _radius,
142  Scalar _length,
143  const PoseType &_pose) = 0;
144  };
145  };
146  }
147 }
148 
149 #include <gz/physics/detail/CapsuleShape.hh>
150 
151 #endif
Definition: gz/physics/CapsuleShape.hh:70
This is the base class of all "proxy objects". The "proxy objects" are essentially interfaces into th...
Definition: gz/physics/Entity.hh:216
void SetLength(Scalar length)
Set the length of this CapsuleShape.
If your feature is known to require any other features, then you should have your feature class inher...
Definition: gz/physics/FeatureList.hh:118
STL class.
void SetRadius(Scalar _radius)
Set the radius of this CapsuleShape.
typename PolicyT::Scalar Scalar
Definition: gz/physics/CapsuleShape.hh:133
This struct is used to conveniently convert from a policy to a geometric type. Example usage:
Definition: gz/physics/Geometry.hh:77
Definition: gz/physics/CapsuleShape.hh:131
typename FromPolicy< PolicyT >::template Use< Pose > PoseType
Definition: gz/physics/CapsuleShape.hh:136
This feature constructs a new capsule shape and attaches the desired pose in the link frame....
Definition: gz/physics/CapsuleShape.hh:102
virtual Identity AttachCapsuleShape(const Identity &_linkID, const std::string &_name, Scalar _radius, Scalar _length, const PoseType &_pose)=0
This feature sets the CapsuleShape properties such as the capsule radius and length.
Definition: gz/physics/CapsuleShape.hh:66
virtual void SetCapsuleShapeRadius(const Identity &_capsuleID, Scalar _radius)=0
#define IGN_PHYSICS_DECLARE_SHAPE_TYPE(CustomShapeType)
Given a shape type named CustomShapeType, this macro creates the following classes:
Definition: gz/physics/DeclareShapeType.hh:52
Definition: gz/physics/Feature.hh:92
virtual void SetCapsuleShapeLength(const Identity &_capsuleID, Scalar _length)=0
typename PolicyT::Scalar Scalar
Definition: gz/physics/CapsuleShape.hh:72
Definition: gz/physics/CapsuleShape.hh:86
typename PolicyT::Scalar Scalar
Definition: gz/physics/CapsuleShape.hh:88