| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2022-2024 INRIA |
| 3 |
|
|
// |
| 4 |
|
|
|
| 5 |
|
|
#ifndef __pinocchio_algorithm_pgs_solver_hpp__ |
| 6 |
|
|
#define __pinocchio_algorithm_pgs_solver_hpp__ |
| 7 |
|
|
|
| 8 |
|
|
#include "pinocchio/algorithm/constraints/fwd.hpp" |
| 9 |
|
|
#include "pinocchio/algorithm/contact-solver-base.hpp" |
| 10 |
|
|
|
| 11 |
|
|
namespace pinocchio |
| 12 |
|
|
{ |
| 13 |
|
|
|
| 14 |
|
|
/// \brief Projected Gauss Siedel solver |
| 15 |
|
|
template<typename _Scalar> |
| 16 |
|
|
struct PGSContactSolverTpl : ContactSolverBaseTpl<_Scalar> |
| 17 |
|
|
{ |
| 18 |
|
|
typedef _Scalar Scalar; |
| 19 |
|
|
typedef ContactSolverBaseTpl<Scalar> Base; |
| 20 |
|
|
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> VectorXs; |
| 21 |
|
|
|
| 22 |
|
✗ |
explicit PGSContactSolverTpl(const int problem_size) |
| 23 |
|
|
: Base(problem_size) |
| 24 |
|
✗ |
, x(problem_size) |
| 25 |
|
✗ |
, x_previous(problem_size) |
| 26 |
|
|
{ |
| 27 |
|
|
} |
| 28 |
|
|
|
| 29 |
|
|
/// |
| 30 |
|
|
/// \brief Solve the constrained conic problem composed of problem data (G,g,cones) and starting |
| 31 |
|
|
/// from the initial guess. |
| 32 |
|
|
/// |
| 33 |
|
|
/// \param[in] G Symmetric PSD matrix representing the Delassus of the contact problem. |
| 34 |
|
|
/// \param[in] g Free contact acceleration or velicity associted with the contact problem. |
| 35 |
|
|
/// \param[in] cones Vector of conic constraints. |
| 36 |
|
|
/// \param[in,out] x Initial guess and output solution of the problem |
| 37 |
|
|
/// \param[in] over_relax Over relaxation value |
| 38 |
|
|
/// |
| 39 |
|
|
/// \returns True if the problem has converged. |
| 40 |
|
|
template< |
| 41 |
|
|
typename MatrixLike, |
| 42 |
|
|
typename VectorLike, |
| 43 |
|
|
typename ConstraintAllocator, |
| 44 |
|
|
typename VectorLikeOut> |
| 45 |
|
|
bool solve( |
| 46 |
|
|
const MatrixLike & G, |
| 47 |
|
|
const Eigen::MatrixBase<VectorLike> & g, |
| 48 |
|
|
const std::vector<CoulombFrictionConeTpl<Scalar>, ConstraintAllocator> & cones, |
| 49 |
|
|
const Eigen::DenseBase<VectorLikeOut> & x, |
| 50 |
|
|
const Scalar over_relax = Scalar(1)); |
| 51 |
|
|
|
| 52 |
|
|
protected: |
| 53 |
|
|
/// \brief Previous temporary value of the optimum. |
| 54 |
|
|
VectorXs x, x_previous; |
| 55 |
|
|
#ifdef PINOCCHIO_WITH_HPP_FCL |
| 56 |
|
|
using Base::timer; |
| 57 |
|
|
#endif // PINOCCHIO_WITH_HPP_FCL |
| 58 |
|
|
|
| 59 |
|
|
}; // struct PGSContactSolverTpl |
| 60 |
|
|
} // namespace pinocchio |
| 61 |
|
|
|
| 62 |
|
|
#include "pinocchio/algorithm/pgs-solver.hxx" |
| 63 |
|
|
|
| 64 |
|
|
#endif // ifndef __pinocchio_algorithm_pgs_solver_hpp__ |
| 65 |
|
|
|