Gazebo Physics

API Reference

7.4.0
FrameSemantics.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_FRAMESEMANTICS_HH_
19 #define GZ_PHYSICS_FRAMESEMANTICS_HH_
20 
21 #include <memory>
22 
23 #include <gz/physics/Feature.hh>
24 #include <gz/physics/Entity.hh>
25 #include <gz/physics/FrameID.hh>
26 #include <gz/physics/FrameData.hh>
28 
29 namespace gz
30 {
31  namespace physics
32  {
38  class GZ_PHYSICS_VISIBLE FrameSemantics : public virtual Feature
39  {
40  // Forward declaration
41  public: template <typename, typename> class Frame;
42 
45  public: template <typename PolicyT, typename FeaturesT>
46  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
47  {
48  public: using FrameData =
50  typename PolicyT::Scalar, PolicyT::Dim>;
51 
59  public: template <typename RQ>
60  typename RQ::Quantity Resolve(
61  const RQ &_quantity,
62  const FrameID &_relativeTo,
63  const FrameID &_inCoordinatesOf) const;
64 
81  public: template <typename RQ>
82  typename RQ::Quantity Resolve(
83  const RQ &_quantity,
84  const FrameID &_relativeTo = FrameID::World()) const;
85 
90  public: template <typename RQ>
91  RQ Reframe(const RQ &_quantity,
92  const FrameID &_withRespectTo = FrameID::World()) const;
93 
94  template <typename, typename> friend class FrameSemantics::Frame;
95  };
96 
99  public: template <typename PolicyT, typename FeaturesT>
100  class Frame : public virtual Entity<PolicyT, FeaturesT>
101  {
102  public: using FrameData =
104 
106  public: FrameID GetFrameID() const;
107 
110 
115  const FrameID &_relativeTo) const;
116 
120  const FrameID &_relativeTo,
121  const FrameID &_inCoordinatesOf) const;
122 
125  public: operator FrameID() const;
126 
128  public: virtual ~Frame() = default;
129  };
130 
133  template <typename PolicyT>
134  class Implementation : public virtual Feature::Implementation<PolicyT>
135  {
136  public: using FrameData =
138 
145  const FrameID &_id) const = 0;
146 
157  protected: virtual FrameID GenerateFrameID(
158  const Identity &_identity) const;
159 
166  protected: template<typename T>
167  T *FrameInterface(const FrameID &_frameID) const;
168  };
169  };
170 
173  class GZ_PHYSICS_VISIBLE LinkFrameSemantics
174  : public virtual FrameSemantics
175  {
176  public: template <typename Policy, typename Features>
178  };
179 
182  class GZ_PHYSICS_VISIBLE JointFrameSemantics
183  : public virtual FrameSemantics
184  {
185  public: template <typename Policy, typename Features>
187  };
188 
190  class GZ_PHYSICS_VISIBLE ShapeFrameSemantics
191  : public virtual FrameSemantics
192  {
193  public: template <typename Policy, typename Features>
195  };
196 
199  class GZ_PHYSICS_VISIBLE ModelFrameSemantics
200  : public virtual FrameSemantics
201  {
202  public: template <typename Policy, typename Features>
204  };
205 
208  class GZ_PHYSICS_VISIBLE CompleteFrameSemantics
209  : public virtual LinkFrameSemantics,
210  public virtual JointFrameSemantics,
211  public virtual ModelFrameSemantics
212  {
213  // This alias is needed in order to disambiguate which Engine class to use
214  // from the base classes.
215  public: template <typename Policy, typename Features>
217  };
218  }
219 }
220 
221 #include <gz/physics/detail/FrameSemantics.hh>
222 
223 #endif