Gazebo Physics

API Reference

2.6.2
gz/physics/ContactProperties.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_CONTACTPROPERTIES_HH_
19 #define GZ_PHYSICS_CONTACTPROPERTIES_HH_
20 
21 #include <string>
22 #include <vector>
23 
26 #include <gz/physics/Geometry.hh>
29 
30 namespace ignition
31 {
32 namespace physics
33 {
37 class IGNITION_PHYSICS_VISIBLE SetContactPropertiesCallbackFeature
38  : public virtual FeatureWithRequirements<ForwardStep>
39 {
46  public: template <typename PolicyT> struct ContactSurfaceParams
47  {
49  std::optional<typename PolicyT::Scalar> frictionCoeff;
50 
52  std::optional<typename PolicyT::Scalar> secondaryFrictionCoeff;
53 
55  std::optional<typename PolicyT::Scalar> rollingFrictionCoeff;
56 
58  std::optional<typename PolicyT::Scalar> secondaryRollingFrictionCoeff;
59 
61  std::optional<typename PolicyT::Scalar> torsionalFrictionCoeff;
62 
65  std::optional<typename PolicyT::Scalar> slipCompliance;
66 
69  std::optional<typename PolicyT::Scalar> secondarySlipCompliance;
70 
73  std::optional<typename PolicyT::Scalar> restitutionCoeff;
74 
78  std::optional<typename FromPolicy<PolicyT>::template Use<Vector>>
80 
87  std::optional<typename FromPolicy<PolicyT>::template Use<Vector>>
89 
93  std::optional<typename PolicyT::Scalar> errorReductionParameter;
94 
96  std::optional<typename PolicyT::Scalar> maxErrorReductionVelocity;
97 
99  std::optional<typename PolicyT::Scalar> maxErrorAllowance;
100 
104  std::optional<typename PolicyT::Scalar> constraintForceMixing;
105  };
106 
107  public: template <typename PolicyT, typename FeaturesT>
108  class World : public virtual Feature::World<PolicyT, FeaturesT>
109  {
110  public: using ShapePtrType = typename GetContactsFromLastStepFeature
111  ::World<PolicyT, FeaturesT>::ShapePtrType;
112 
125  public: typedef std::function<
126  void(
127  const typename GetContactsFromLastStepFeature::
129  size_t /*_numContactsOnCollision*/,
130  ContactSurfaceParams<PolicyT>& /*_surfaceParams*/)
132 
134  public: void AddContactPropertiesCallback(
135  const std::string &_callbackID, SurfaceParamsCallback _callback);
136 
138  public: bool RemoveContactPropertiesCallback(
139  const std::string &_callbackID);
140  };
141 
142  public: template <typename PolicyT>
143  class Implementation : public virtual Feature::Implementation<PolicyT>
144  {
145  public: using ContactImpl = typename GetContactsFromLastStepFeature
146  ::Implementation<PolicyT>::ContactInternal;
147 
148  public: typedef std::function<
149  void(const ContactImpl&, size_t, ContactSurfaceParams<PolicyT>&)
151 
153  public: virtual void AddContactPropertiesCallback(
154  const Identity &_worldID,
155  const std::string &_callbackID,
156  SurfaceParamsCallback _callback) = 0;
157 
159  public: virtual bool RemoveContactPropertiesCallback(
160  const Identity &_worldID, const std::string &_callbackID) = 0;
161  };
162 };
163 
164 }
165 }
166 
167 #include "gz/physics/detail/ContactProperties.hh"
168 
169 #endif /* end of include guard: GZ_PHYSICS_CONTACTPROPERTIES_HH_ */
std::optional< typename PolicyT::Scalar > secondarySlipCompliance
Force-dependent slip coefficient along the 2nd friction direction.
Definition: gz/physics/ContactProperties.hh:69
virtual bool RemoveContactPropertiesCallback(const Identity &_worldID, const std::string &_callbackID)=0
Remove the callback.
If your feature is known to require any other features, then you should have your feature class inher...
Definition: gz/physics/FeatureList.hh:108
This struct gets filled by the simulator and contains various properties of a contact joint (surface,...
Definition: gz/physics/ContactProperties.hh:46
STL class.
std::optional< typename PolicyT::Scalar > rollingFrictionCoeff
Coefficient of rolling friction along the 1st friction direction.
Definition: gz/physics/ContactProperties.hh:55
std::optional< typename PolicyT::Scalar > errorReductionParameter
Joint error reduction parameter. This is the fraction of the joint error that will be attempted to be...
Definition: gz/physics/ContactProperties.hh:93
Definition: gz/physics/ContactProperties.hh:108
Definition: gz/physics/ContactProperties.hh:143
std::optional< typename PolicyT::Scalar > frictionCoeff
Coefficient of friction along the 1st friction direction.
Definition: gz/physics/ContactProperties.hh:49
std::optional< typename PolicyT::Scalar > restitutionCoeff
Defines the bounciness of the contact. 0 is not bouncy. Values between 0 and 1 are allowed.
Definition: gz/physics/ContactProperties.hh:73
typename GetContactsFromLastStepFeature ::World< PolicyT, FeaturesT >::ShapePtrType ShapePtrType
Definition: gz/physics/ContactProperties.hh:111
std::optional< typename FromPolicy< PolicyT >::template Use< Vector > > contactSurfaceMotionVelocity
Desired velocity of the colliding bodies in the contact point. Setting this to non-zero asks the phys...
Definition: gz/physics/ContactProperties.hh:88
std::optional< typename PolicyT::Scalar > secondaryFrictionCoeff
Coefficient of friction along the 2nd friction direction.
Definition: gz/physics/ContactProperties.hh:52
std::optional< typename PolicyT::Scalar > secondaryRollingFrictionCoeff
Coefficient of rolling friction along the 2nd friction direction.
Definition: gz/physics/ContactProperties.hh:58
GetContactsFromLastStepFeature is a feature for retrieving the list of contacts generated in the prev...
Definition: gz/physics/GetContacts.hh:33
std::optional< typename PolicyT::Scalar > slipCompliance
Force-dependent slip coefficient along the 1st friction direction.
Definition: gz/physics/ContactProperties.hh:65
bool RemoveContactPropertiesCallback(const std::string &_callbackID)
Remove the callback.
typename GetContactsFromLastStepFeature ::Implementation< PolicyT >::ContactInternal ContactImpl
Definition: gz/physics/ContactProperties.hh:146
Definition: gz/physics/Feature.hh:92
std::optional< typename FromPolicy< PolicyT >::template Use< Vector > > firstFrictionalDirection
The first frictional direction. It should be perpendicular to the contact normal. The second friction...
Definition: gz/physics/ContactProperties.hh:79
std::optional< typename PolicyT::Scalar > maxErrorAllowance
Maximum joint error for which no error reduction is performed.
Definition: gz/physics/ContactProperties.hh:99
Placeholder class in case a Feature does not define its own World API.
Definition: gz/physics/Feature.hh:49
void AddContactPropertiesCallback(const std::string &_callbackID, SurfaceParamsCallback _callback)
Add the callback.
std::optional< typename PolicyT::Scalar > maxErrorReductionVelocity
Maximum velocity that can be used to reduce joint error.
Definition: gz/physics/ContactProperties.hh:96
std::optional< typename PolicyT::Scalar > torsionalFrictionCoeff
Coefficient of torsional friction.
Definition: gz/physics/ContactProperties.hh:61
SetContactPropertiesCallbackFeature is a feature for setting the properties of a contact after it is ...
Definition: gz/physics/ContactProperties.hh:37
std::optional< typename PolicyT::Scalar > constraintForceMixing
Constraint force mixing. This should be a non-negative number. If greater than 0, this number is adde...
Definition: gz/physics/ContactProperties.hh:104
std::function< void(const typename GetContactsFromLastStepFeature::World< PolicyT, FeaturesT >::Contact &, size_t, ContactSurfaceParams< PolicyT > &) > SurfaceParamsCallback
This callback is called for every detected contact point and allows customizing properties of the con...
Definition: gz/physics/ContactProperties.hh:131
virtual void AddContactPropertiesCallback(const Identity &_worldID, const std::string &_callbackID, SurfaceParamsCallback _callback)=0
Add the callback.
std::function< void(const ContactImpl &, size_t, ContactSurfaceParams< PolicyT > &) > SurfaceParamsCallback
Definition: gz/physics/ContactProperties.hh:150