algorithm/contact-solver-base.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2022-2024 INRIA
3 //
4 
5 #ifndef __pinocchio_algorithm_contact_solver_base_hpp__
6 #define __pinocchio_algorithm_contact_solver_base_hpp__
7 
8 #include "pinocchio/math/fwd.hpp"
10 
11 #ifdef PINOCCHIO_WITH_HPP_FCL
12  #include <hpp/fcl/timings.h>
13 #endif // PINOCCHIO_WITH_HPP_FCL
14 
15 namespace pinocchio
16 {
17 
18  template<typename _Scalar>
20  {
21  typedef _Scalar Scalar;
22 
23 #ifdef PINOCCHIO_WITH_HPP_FCL
24  typedef hpp::fcl::CPUTimes CPUTimes;
25  typedef hpp::fcl::Timer Timer;
26 #endif // PINOCCHIO_WITH_HPP_FCL
27 
28  explicit ContactSolverBaseTpl(const int problem_size)
30  , max_it(1000)
31  , it(0)
32  , absolute_precision(Scalar(1e-6))
33  , relative_precision(Scalar(1e-6))
36 #ifdef PINOCCHIO_WITH_HPP_FCL
37  , timer(false)
38 #endif // PINOCCHIO_WITH_HPP_FCL
39  {
40  }
41 
43  int getProblemSize() const
44  {
45  return problem_size;
46  }
47 
49  int getIterationCount() const
50  {
51  return it;
52  }
53 
55  void setMaxIterations(const int max_it)
56  {
57  PINOCCHIO_CHECK_INPUT_ARGUMENT(max_it > 0, "max_it should be greater than 0.");
58  this->max_it = max_it;
59  }
61  int getMaxIterations() const
62  {
63  return max_it;
64  }
65 
68  {
70  absolute_precision >= Scalar(0), "absolute_precision should be positive.");
71  this->absolute_precision = absolute_precision;
72  }
75  {
76  return absolute_precision;
77  }
78 
81  {
83  relative_precision >= Scalar(0), "relative_precision should be positive.");
84  this->relative_precision = relative_precision;
85  }
88  {
89  return relative_precision;
90  }
91 
95  {
96  return absolute_residual;
97  }
101  {
102  return relative_residual;
103  }
104 
105 #ifdef PINOCCHIO_WITH_HPP_FCL
106  CPUTimes getCPUTimes() const
107  {
108  return timer.elapsed();
109  }
110 #endif // PINOCCHIO_WITH_HPP_FCL
111 
112  protected:
116  int max_it;
118  int it;
127 
128 #ifdef PINOCCHIO_WITH_HPP_FCL
129  Timer timer;
130 #endif // PINOCCHIO_WITH_HPP_FCL
131 
132  }; // struct ContactSolverBaseTpl
133 
134 } // namespace pinocchio
135 
136 #endif // ifndef __pinocchio_algorithm_contact_solver_base_hpp__
pinocchio::ContactSolverBaseTpl::getRelativePrecision
Scalar getRelativePrecision() const
Get the relative precision requested.
Definition: algorithm/contact-solver-base.hpp:87
pinocchio::ContactSolverBaseTpl::absolute_precision
Scalar absolute_precision
Desired absolute precision.
Definition: algorithm/contact-solver-base.hpp:120
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
Macro to check an assert-like condition and throw a std::invalid_argument exception (with a message) ...
Definition: include/pinocchio/macros.hpp:192
pinocchio::ContactSolverBaseTpl::getProblemSize
int getProblemSize() const
Returns the size of the problem.
Definition: algorithm/contact-solver-base.hpp:43
pinocchio::ContactSolverBaseTpl::setRelativePrecision
void setRelativePrecision(const Scalar relative_precision)
Set the relative precision for the problem.
Definition: algorithm/contact-solver-base.hpp:80
pinocchio::Timer
Definition: timer2.hpp:13
pinocchio::ContactSolverBaseTpl::setAbsolutePrecision
void setAbsolutePrecision(const Scalar absolute_precision)
Set the absolute precision for the problem.
Definition: algorithm/contact-solver-base.hpp:67
pinocchio::ContactSolverBaseTpl::setMaxIterations
void setMaxIterations(const int max_it)
Set the maximum number of iterations.
Definition: algorithm/contact-solver-base.hpp:55
hpp::fcl::Timer
pinocchio::ContactSolverBaseTpl::max_it
int max_it
&#160;
Definition: algorithm/contact-solver-base.hpp:116
pinocchio::ContactSolverBaseTpl
Definition: algorithm/contact-solver-base.hpp:19
hpp::fcl::CPUTimes
pinocchio::ContactSolverBaseTpl::getAbsolutePrecision
Scalar getAbsolutePrecision() const
Get the absolute precision requested.
Definition: algorithm/contact-solver-base.hpp:74
pinocchio::ContactSolverBaseTpl::it
int it
Number of iterations needed to achieve convergence.
Definition: algorithm/contact-solver-base.hpp:118
fwd.hpp
pinocchio::ContactSolverBaseTpl::relative_residual
Scalar relative_residual
Relative convergence residual value.
Definition: algorithm/contact-solver-base.hpp:126
comparison-operators.hpp
pinocchio::ContactSolverBaseTpl::ContactSolverBaseTpl
ContactSolverBaseTpl(const int problem_size)
Definition: algorithm/contact-solver-base.hpp:28
pinocchio::ContactSolverBaseTpl::Scalar
_Scalar Scalar
Definition: algorithm/contact-solver-base.hpp:21
pinocchio::ContactSolverBaseTpl::absolute_residual
Scalar absolute_residual
Absolule convergence residual value.
Definition: algorithm/contact-solver-base.hpp:124
pinocchio::ContactSolverBaseTpl::getMaxIterations
int getMaxIterations() const
Get the maximum number of iterations allowed.
Definition: algorithm/contact-solver-base.hpp:61
pinocchio::ContactSolverBaseTpl::getRelativeConvergenceResidual
Scalar getRelativeConvergenceResidual() const
Returns the value of the relative residual value corresponding to the difference between two successi...
Definition: algorithm/contact-solver-base.hpp:100
pinocchio::ContactSolverBaseTpl::getIterationCount
int getIterationCount() const
Get the number of iterations achieved by the solver.
Definition: algorithm/contact-solver-base.hpp:49
pinocchio::ContactSolverBaseTpl::problem_size
int problem_size
Size of the problem.
Definition: algorithm/contact-solver-base.hpp:114
pinocchio::ContactSolverBaseTpl::getAbsoluteConvergenceResidual
Scalar getAbsoluteConvergenceResidual() const
Returns the value of the absolute residual value corresponding to the contact complementary condition...
Definition: algorithm/contact-solver-base.hpp:94
pinocchio::ContactSolverBaseTpl::relative_precision
Scalar relative_precision
Desired relative precision.
Definition: algorithm/contact-solver-base.hpp:122
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
timings.h


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:08