Ignition Physics

API Reference

5.1.0
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 IGNITION_PHYSICS_CONTACTPROPERTIES_HH_
19 #define IGNITION_PHYSICS_CONTACTPROPERTIES_HH_
20 
21 #include <string>
22 #include <vector>
23 
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 "ignition/physics/detail/ContactProperties.hh"
168 
169 #endif /* end of include guard: IGNITION_PHYSICS_CONTACTPROPERTIES_HH_ */
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: ContactProperties.hh:93
std::optional< typename PolicyT::Scalar > frictionCoeff
Coefficient of friction along the 1st friction direction.
Definition: ContactProperties.hh:49
If your feature is known to require any other features, then you should have your feature class inher...
Definition: FeatureList.hh:108
GetContactsFromLastStepFeature is a feature for retrieving the list of contacts generated in the prev...
Definition: GetContacts.hh:33
std::optional< typename PolicyT::Scalar > secondarySlipCompliance
Force-dependent slip coefficient along the 2nd friction direction.
Definition: ContactProperties.hh:69
std::optional< typename PolicyT::Scalar > secondaryFrictionCoeff
Coefficient of friction along the 2nd friction direction.
Definition: ContactProperties.hh:52
std::optional< typename PolicyT::Scalar > restitutionCoeff
Defines the bounciness of the contact. 0 is not bouncy. Values between 0 and 1 are allowed...
Definition: ContactProperties.hh:73
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: ContactProperties.hh:88
STL class.
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: ContactProperties.hh:79
std::optional< typename PolicyT::Scalar > secondaryRollingFrictionCoeff
Coefficient of rolling friction along the 2nd friction direction.
Definition: ContactProperties.hh:58
std::optional< typename PolicyT::Scalar > slipCompliance
Force-dependent slip coefficient along the 1st friction direction.
Definition: ContactProperties.hh:65
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: ContactProperties.hh:131
Placeholder class in case a Feature does not define its own World API.
Definition: Feature.hh:49
std::function< void(const ContactImpl &, size_t, ContactSurfaceParams< PolicyT > &) > SurfaceParamsCallback
Definition: ContactProperties.hh:150
typename GetContactsFromLastStepFeature ::World< PolicyT, FeaturesT >::ShapePtrType ShapePtrType
Definition: ContactProperties.hh:111
typename GetContactsFromLastStepFeature ::Implementation< PolicyT >::ContactInternal ContactImpl
Definition: ContactProperties.hh:146
std::optional< typename PolicyT::Scalar > maxErrorAllowance
Maximum joint error for which no error reduction is performed.
Definition: ContactProperties.hh:99
std::optional< typename PolicyT::Scalar > maxErrorReductionVelocity
Maximum velocity that can be used to reduce joint error.
Definition: ContactProperties.hh:96
This struct gets filled by the simulator and contains various properties of a contact joint (surface...
Definition: ContactProperties.hh:46
SetContactPropertiesCallbackFeature is a feature for setting the properties of a contact after it is ...
Definition: ContactProperties.hh:37
std::optional< typename PolicyT::Scalar > torsionalFrictionCoeff
Coefficient of torsional friction.
Definition: ContactProperties.hh:61
std::optional< typename PolicyT::Scalar > rollingFrictionCoeff
Coefficient of rolling friction along the 1st friction direction.
Definition: ContactProperties.hh:55
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: ContactProperties.hh:104