Gazebo Physics

API Reference

5.3.2
include/gz/physics/World.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_WORLD_HH_
19 #define GZ_PHYSICS_WORLD_HH_
20 
21 #include <string>
22 
25 
26 namespace ignition
27 {
28  namespace physics
29  {
31  class IGNITION_PHYSICS_VISIBLE CollisionDetector : public virtual Feature
32  {
34  public: template <typename PolicyT, typename FeaturesT>
35  class World : public virtual Feature::World<PolicyT, FeaturesT>
36  {
39  public: void SetCollisionDetector(
40  const std::string &_collisionDetector);
41 
44  public: const std::string &GetCollisionDetector() const;
45  };
46 
48  public: template <typename PolicyT>
49  class Implementation : public virtual Feature::Implementation<PolicyT>
50  {
54  public: virtual void SetWorldCollisionDetector(
55  const Identity &_id, const std::string &_collisionDetector) = 0;
56 
60  public: virtual const std::string &GetWorldCollisionDetector(
61  const Identity &_id) const = 0;
62  };
63  };
64 
67 
70  class IGNITION_PHYSICS_VISIBLE Gravity
71  : public virtual
72  FeatureWithRequirements<GravityRequiredFeatures>
73  {
75  public: template <typename PolicyT, typename FeaturesT>
76  class World : public virtual Feature::World<PolicyT, FeaturesT>
77  {
78  public: using LinearVectorType =
79  typename FromPolicy<PolicyT>::template Use<LinearVector>;
80 
81  public: using RelativeForceType =
82  typename FromPolicy<PolicyT>::template Use<RelativeForce>;
83 
88  public: void SetGravity(const RelativeForceType &_gravity);
89 
96  public: void SetGravity(
97  const LinearVectorType &_gravity,
98  const FrameID &_forceInCoordinatesOf = FrameID::World());
99 
106  public: LinearVectorType GetGravity(
107  const FrameID &_forceInCoordinatesOf = FrameID::World()) const;
108  };
109 
111  public: template <typename PolicyT>
112  class Implementation : public virtual Feature::Implementation<PolicyT>
113  {
114  public: using LinearVectorType =
115  typename FromPolicy<PolicyT>::template Use<LinearVector>;
116 
121  public: virtual void SetWorldGravity(
122  const Identity &_id, const LinearVectorType &_gravity) = 0;
123 
128  public: virtual LinearVectorType GetWorldGravity(
129  const Identity &_id) const = 0;
130  };
131  };
132 
134  class IGNITION_PHYSICS_VISIBLE Solver : public virtual Feature
135  {
137  public: template <typename PolicyT, typename FeaturesT>
138  class World : public virtual Feature::World<PolicyT, FeaturesT>
139  {
142  public: void SetSolver(const std::string &_solver);
143 
146  public: const std::string &GetSolver() const;
147  };
148 
150  public: template <typename PolicyT>
151  class Implementation : public virtual Feature::Implementation<PolicyT>
152  {
156  public: virtual void SetWorldSolver(
157  const Identity &_id, const std::string &_solver) = 0;
158 
162  public: virtual const std::string &GetWorldSolver(
163  const Identity &_id) const = 0;
164  };
165  };
166  }
167 }
168 
169 #include <gz/physics/detail/World.hh>
170 
171 #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
STL class.
This struct is used to conveniently convert from a policy to a geometric type. Example usage:
Definition: gz/physics/Geometry.hh:77
virtual LinearVectorType GetWorldGravity(const Identity &_id) const =0
Implementation API for getting the gravity expressed in the world frame.
LinearVectorType GetGravity(const FrameID &_forceInCoordinatesOf=FrameID::World()) const
Get the World gravity vector. Optionally, you may specify the frame whose coordinates are used to exp...
The implementation API for the solver.
Definition: include/gz/physics/World.hh:151
virtual void SetWorldSolver(const Identity &_id, const std::string &_solver)=0
Implementation API for setting the solver.
Container for specifying Frame IDs. We do not want to use a generic integer type for this,...
Definition: gz/physics/FrameID.hh:46
virtual void SetWorldGravity(const Identity &_id, const LinearVectorType &_gravity)=0
Implementation API for setting the gravity vector, which is expressed in the World frame....
const std::string & GetSolver() const
Get the name of the solver in use.
Use a FeatureList to aggregate a list of Features.
Definition: gz/physics/FeatureList.hh:61
void SetGravity(const RelativeForceType &_gravity)
Set the World gravity vector.
virtual const std::string & GetWorldSolver(const Identity &_id) const =0
Implementation API for getting the solver.
typename FromPolicy< PolicyT >::template Use< LinearVector > LinearVectorType
Definition: include/gz/physics/World.hh:79
The World API for getting and setting the gravity vector.
Definition: include/gz/physics/World.hh:76
typename FromPolicy< PolicyT >::template Use< LinearVector > LinearVectorType
Definition: include/gz/physics/World.hh:115
typename FromPolicy< PolicyT >::template Use< RelativeForce > RelativeForceType
Definition: include/gz/physics/World.hh:82
const std::string & GetCollisionDetector() const
Get the name of the collision detector in use.
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
virtual const std::string & GetWorldCollisionDetector(const Identity &_id) const =0
Implementation API for getting the collision detector.
The World API for setting the collision detector.
Definition: include/gz/physics/World.hh:35
The implementation API for the gravity.
Definition: include/gz/physics/World.hh:112
The implementation API for the collision detector.
Definition: include/gz/physics/World.hh:49
Placeholder class in case a Feature does not define its own World API.
Definition: gz/physics/Feature.hh:49
void SetCollisionDetector(const std::string &_collisionDetector)
Set the name of the collision detector to use.
Definition: include/gz/physics/World.hh:31
virtual void SetWorldCollisionDetector(const Identity &_id, const std::string &_collisionDetector)=0
Implementation API for setting the collision detector.
Definition: include/gz/physics/World.hh:134
The World API for setting the solver.
Definition: include/gz/physics/World.hh:138
void SetSolver(const std::string &_solver)
Set the name of the solver to use.
static const FrameID & World()
Get a reference to the world Frame.
Get and set the World's gravity vector in a specified frame.
Definition: include/gz/physics/World.hh:70