AGX Dynamics  2.38.0.2
FrictionControllerNlCallback.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/NlmcpCallback.h>
20 
21 namespace agx
22 {
23  class FrictionController;
24 
29  {
30  public:
31  struct ContextData
32  {
34  {
36  ecIndices[ 0 ] = ecIndices[ 1 ] = InvalidIndex;
37  }
38 
41  bool useSecondaryConstraint = false;
42  };
43 
44 
45  public:
46  static ContextData findContextData( const FrictionController* frictionController, const ConstraintImplementation* context );
47  static Real calculateNormalForce( const ConstraintImplementation* context, ContextData contextData );
48 
49  static RangeReal calculateBound( Real normalImpact,
50  Real frictionCoefficient,
51  // Minimum (close to zero) bound - default [0, 0], i.e.,
52  // the bound may be zero if the normal force is zero. This
53  // is the FrictionController::setMinimumStaticFrictionForceRange
54  // but scaled with the time step size.
55  RangeReal minBound = RangeReal{ 0.0 } );
56 
57  public:
61  FrictionControllerNlCallback( const FrictionController* frictionController );
62 
63  Real calculateNormalForce() const;
64  Real calculateNormalForce( const ConstraintImplementation* context ) const;
65 
66  virtual Bool initialize( const NlmcpCallback::Args& args ) override;
67 
68  virtual Real calculateResidual( const NlmcpCallback::Args& args ) const override;
69 
70  virtual void update( const NlmcpCallback::Args& args ) const override;
71 
72  virtual void postIterativeSolve( const NlmcpCallback::Args& /*args*/ ) const override;
73 
74  protected:
76 
77  virtual void onSetContext( const NlmcpCallbackSolverData& ) override;
78 
79  protected:
80  Real calculateNormalImpact( const RealValarray& z ) const;
81 
82  private:
83  const FrictionController* m_frictionController;
84  ContextData m_contextData;
85  };
86 }
agx::UInt
uint64_t UInt
Definition: Integer.h:27
agx::FrictionControllerNlCallback::update
virtual void update(const NlmcpCallback::Args &args) const override
Update call when bounds and/or q may be updated given the current solution z.
agx::FrictionControllerNlCallback::calculateNormalImpact
Real calculateNormalImpact(const RealValarray &z) const
agx::Real
double Real
Definition: Real.h:42
agx::FrictionController
Translational or rotational friction controller for Hinge, Prismatic and CylindricalJoint.
Definition: ElementaryConstraint.h:812
agx::FrictionControllerNlCallback::initialize
virtual Bool initialize(const NlmcpCallback::Args &args) override
This method is a test for the non-linear solver if this callback is active for non-linear solve.
agx::FrictionControllerNlCallback::ContextData
Definition: FrictionControllerNlCallback.h:31
agx::ConstraintImplementation
Definition: ConstraintImplementation.h:100
agx::FrictionControllerNlCallback::postIterativeSolve
virtual void postIterativeSolve(const NlmcpCallback::Args &) const override
Before direct solve, after iterative solve.
agx::FrictionControllerNlCallback::ContextData::rowOffset
UInt rowOffset
Definition: FrictionControllerNlCallback.h:39
agx::FrictionControllerNlCallback::~FrictionControllerNlCallback
virtual ~FrictionControllerNlCallback()
agx::FrictionControllerNlCallback::calculateNormalForce
Real calculateNormalForce() const
agx::FrictionControllerNlCallback::calculateBound
static RangeReal calculateBound(Real normalImpact, Real frictionCoefficient, RangeReal minBound=RangeReal{ 0.0 })
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agx::FrictionControllerNlCallback::ContextData::ecIndices
Vec2u ecIndices
Definition: FrictionControllerNlCallback.h:40
agx::ConstraintNlmcpCallback
Constraint solver callback interface with context and start rows for context.
Definition: NlmcpCallback.h:246
agx::FrictionControllerNlCallback::ContextData::useSecondaryConstraint
bool useSecondaryConstraint
Definition: FrictionControllerNlCallback.h:41
agx::Vec2T< UInt >
agx::FrictionControllerNlCallback::calculateResidual
virtual Real calculateResidual(const NlmcpCallback::Args &args) const override
Calculate residual given current solution.
agx::RealValarray
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Definition: agx_valarray_types.h:27
agx::FrictionControllerNlCallback::ContextData::ContextData
ContextData()
Definition: FrictionControllerNlCallback.h:33
agx::FrictionControllerNlCallback::onSetContext
virtual void onSetContext(const NlmcpCallbackSolverData &) override
Called when context constraint has been set and all data is valid.
NlmcpCallback.h
agx::Bool
bool Bool
Definition: Integer.h:40
agx::FrictionControllerNlCallback
Solver callback class for elementary FrictionController.
Definition: FrictionControllerNlCallback.h:28
agx::NlmcpCallback::Args
Definition: NlmcpCallback.h:45
agx::NlmcpCallbackSolverData
Data from the solver the ConstraintNlmcpCallback is part of.
Definition: NlmcpCallback.h:191
agx::FrictionControllerNlCallback::findContextData
static ContextData findContextData(const FrictionController *frictionController, const ConstraintImplementation *context)
agx::Range< Real >
agx::InvalidIndex
const AGXCORE_EXPORT InvalidIndexStruct InvalidIndex
agx::FrictionControllerNlCallback::FrictionControllerNlCallback
FrictionControllerNlCallback(const FrictionController *frictionController)
Default constructor.