hpp-constraints
4.9.1
Definition of basic geometric constraints for motion planning
|
#include <hpp/constraints/solver/hierarchical-iterative.hh>
Classes | |
struct | Data |
Public Types | |
enum | Status { ERROR_INCREASED, MAX_ITERATION_REACHED, INFEASIBLE, SUCCESS } |
typedef Eigen::RowBlockIndices | Indices_t |
typedef lineSearch::FixedSequence | DefaultLineSearch |
typedef boost::function< bool(vectorIn_t q, vectorOut_t qSat, Eigen::VectorXi &saturation)> | Saturation_t |
Public Member Functions | |
HierarchicalIterative (const LiegroupSpacePtr_t &configSpace) | |
HierarchicalIterative (const HierarchicalIterative &other) | |
virtual | ~HierarchicalIterative () |
value_type | residualError () const |
Returns the squared norm of the error vector. More... | |
void | residualError (vectorOut_t error) const |
Returns the error vector. More... | |
bool | definesSubmanifoldOf (const HierarchicalIterative &solver) const |
virtual std::ostream & | print (std::ostream &os) const |
template<typename LineSearchType > | |
solver::HierarchicalIterative::Status | solve (vectorOut_t arg, LineSearchType lineSearch) const |
Problem definition | |
const LiegroupSpacePtr_t & | configSpace () const |
Get configuration space on which constraints are defined. More... | |
virtual bool | contains (const ImplicitPtr_t &numericalConstraint) const |
void | add (const DifferentiableFunctionPtr_t &f, const std::size_t &priority) HPP_CONSTRAINTS_DEPRECATED |
void | add (const DifferentiableFunctionPtr_t &f, const std::size_t &priority, const ComparisonTypes_t &comp) HPP_CONSTRAINTS_DEPRECATED |
void | add (const ImplicitPtr_t &constraint, const std::size_t &priority) |
virtual void | merge (const HierarchicalIterative &other) |
void | saturation (const Saturation_t &saturate) |
Set the saturation function. More... | |
const Saturation_t & | saturation () const |
Get the saturation function. More... | |
Problem resolution | |
template<typename LineSearchType > | |
Status | solve (vectorOut_t arg, LineSearchType ls=LineSearchType()) const |
Status | solve (vectorOut_t arg) const |
bool | isSatisfied (vectorIn_t arg) const |
bool | isConstraintSatisfied (const ImplicitPtr_t &constraint, vectorIn_t arg, vectorOut_t error, bool &constraintFound) const |
const value_type & | sigma () const |
Parameters | |
void | freeVariables (const segments_t intervals) |
void | freeVariables (const Indices_t &indices) |
const Indices_t & | freeVariables () const |
Get free velocity variables. More... | |
void | maxIterations (size_type iterations) |
Set maximal number of iterations. More... | |
size_type | maxIterations () const |
Get maximal number of iterations in config projector. More... | |
void | errorThreshold (const value_type &threshold) |
Set error threshold. More... | |
value_type | errorThreshold () const |
Get error threshold. More... | |
value_type | squaredErrorThreshold () const |
Get error threshold. More... | |
value_type | inequalityThreshold () const |
Get the inequality threshold. More... | |
void | inequalityThreshold (const value_type &it) |
set the inequality threshold More... | |
void | lastIsOptional (bool optional) |
bool | lastIsOptional () const |
Stack | |
const ImplicitConstraintSet & | constraints (const std::size_t priority) |
Get set of constraints for a give priority level. More... | |
const NumericalConstraints_t & | constraints () const |
Get constraints (implicit and explicit) More... | |
std::size_t | numberStacks () const |
const size_type & | dimension () const |
const size_type & | reducedDimension () const |
ArrayXb | activeParameters () const |
Configuration parameters involved in the constraint resolution. More... | |
ArrayXb | activeDerivativeParameters () const |
Velocity parameters involved in the constraint resolution. More... | |
Right hand side accessors | |
vector_t | rightHandSideFromConfig (ConfigurationIn_t config) |
virtual bool | rightHandSideFromConfig (const ImplicitPtr_t &constraint, ConfigurationIn_t config) |
virtual bool | rightHandSide (const ImplicitPtr_t &constraint, vectorIn_t rhs) |
virtual bool | getRightHandSide (const ImplicitPtr_t &constraint, vectorOut_t rhs) const |
Get right hand side of a constraints. More... | |
virtual void | rightHandSide (vectorIn_t rhs) |
void | rightHandSideAt (const value_type &s) |
vector_t | rightHandSide () const |
size_type | rightHandSideSize () const |
Access to internal data | |
You should know what you do when you call these functions | |
template<bool ComputeJac> | |
void | computeValue (vectorIn_t arg) const |
Compute the value of each level, and the jacobian if ComputeJac is true. More... | |
void | computeSaturation (vectorIn_t arg) const |
void | getValue (vectorOut_t v) const |
void | getReducedJacobian (matrixOut_t J) const |
void | computeError () const |
const vector_t & | lastStep () const |
Accessor to the last step done. More... | |
virtual bool | integrate (vectorIn_t from, vectorIn_t velocity, vectorOut_t result) const |
Protected Types | |
typedef Eigen::JacobiSVD< matrix_t > | SVD_t |
Protected Member Functions | |
void | update () |
virtual void | computeActiveRowsOfJ (std::size_t iStack) |
void | computeDescentDirection () const |
void | expandDqSmall () const |
void | saturate (vectorOut_t arg) const |
Friends | |
struct | lineSearch::Backtracking |
Solve a system of non-linear equations on a robot configuration
The non-linear system of equations is built by adding equations with method HierarchicalIterative::add.
Note that a hierarchy between the equations can be provided. In this case, the solver will try to solve the highest priority equations first, and then to solve the lower priority equations. Note that priorities are in decreasing order: 0 has higher priority than 1.
The algorithm used is a Newton-Raphson like algorithm that works as follows: let \(f (\mathbf{q}) = 0\) be the system of equations where \(f\) is a \(C^1\) mapping from the robot configuration space to a Lie group space \(\mathcal{L}\).
Starting from initial guess \(\mathbf{q}_0\), the method HierarchicalIterative::solve builds a sequence of configurations \(\mathbf{q}_i\) as follows:
\begin{eqnarray*} \mathbf{q}_{i+1} = \mathbf{q}_i - \alpha_i \frac{\partial f}{\partial \mathbf{q}}(\mathbf{q}_i)^{+} f (\mathbf{q}_i) \end{eqnarray*}
where
The error threshold can be accessed by methods HierarchicalIterative::errorThreshold. The maximal number of iterations can be accessed by methods HierarchicalIterative::maxIterations.
The unknowns \(\mathbf{q}\) may take values in a more general set than the configuration space of a robot. This set should be a Cartesian product of Lie groups: hpp::pinocchio::LiegroupSpace.
To prevent configuration variables to get out of joint limits during Newton Raphson iterations, the user may provide a method of type HierarchicalIterative::Saturation_t using setter and getter HierarchicalIterative::saturation.
Instead of \(f(\mathbf{q}) = 0\), other constraints can be defined. Several comparison types are available:
Some variables can be locked, or computed explicitely. In this case, the iterative resolution will only change the other variables called free variables.
typedef lineSearch::FixedSequence hpp::constraints::solver::HierarchicalIterative::DefaultLineSearch |
typedef boost::function<bool (vectorIn_t q, vectorOut_t qSat, Eigen::VectorXi& saturation)> hpp::constraints::solver::HierarchicalIterative::Saturation_t |
This function checks which degrees of freedom are saturated.
q | a configuration, |
qSat | configuration after saturing values out of bounds |
saturation | vector: for each degree of freedom, saturation is set to
|
|
protected |
hpp::constraints::solver::HierarchicalIterative::HierarchicalIterative | ( | const LiegroupSpacePtr_t & | configSpace | ) |
hpp::constraints::solver::HierarchicalIterative::HierarchicalIterative | ( | const HierarchicalIterative & | other | ) |
|
inlinevirtual |
ArrayXb hpp::constraints::solver::HierarchicalIterative::activeDerivativeParameters | ( | ) | const |
Velocity parameters involved in the constraint resolution.
ArrayXb hpp::constraints::solver::HierarchicalIterative::activeParameters | ( | ) | const |
Configuration parameters involved in the constraint resolution.
void hpp::constraints::solver::HierarchicalIterative::add | ( | const DifferentiableFunctionPtr_t & | f, |
const std::size_t & | priority | ||
) |
Add an implicit equality constraint
f | differentiable function from the robot configuration space to a Lie group (See hpp::pinocchio::LiegroupSpace), |
priority | level of priority of the constraint: priority are in decreasing order: 0 is the highest priority level. |
Constraint is defined by \(f (\mathbf{q}) = 0\).
void hpp::constraints::solver::HierarchicalIterative::add | ( | const DifferentiableFunctionPtr_t & | f, |
const std::size_t & | priority, | ||
const ComparisonTypes_t & | comp | ||
) |
Add an implicit constraint
f | differentiable function from the robot configuration space to a Lie group (See hpp::pinocchio::LiegroupSpace), |
priority | level of priority of the constraint: priority are in decreasing order: 0 is the highest priority level, |
comp | comparison type. See class documentation for details. |
void hpp::constraints::solver::HierarchicalIterative::add | ( | const ImplicitPtr_t & | constraint, |
const std::size_t & | priority | ||
) |
Add an implicit constraint
constraint | implicit constraint |
priority | level of priority of the constraint: priority are in decreasing order: 0 is the highest priority level, |
|
protectedvirtual |
Compute which rows of the jacobian of stack_[iStack] are not zero, using the activeDerivativeParameters of the functions. The result is stored in datas_[i].activeRowsOfJ
Reimplemented in hpp::constraints::solver::BySubstitution.
|
protected |
Compute a SVD decomposition of each level and find the best descent direction at the first order. Linearization of the system of equations rhs - v_{i} = J (q_i) (dq_{i+1} - q_{i}) q_{i+1} - q_{i} = J(q_i)^{+} ( rhs - v_{i} ) dq = J(q_i)^{+} ( rhs - v_{i} )
void hpp::constraints::solver::HierarchicalIterative::computeError | ( | ) | const |
If lastIsOptional() is true, then the last level is ignored.
void hpp::constraints::solver::HierarchicalIterative::computeSaturation | ( | vectorIn_t | arg | ) | const |
void hpp::constraints::solver::HierarchicalIterative::computeValue | ( | vectorIn_t | arg | ) | const |
Compute the value of each level, and the jacobian if ComputeJac is true.
|
inline |
Get configuration space on which constraints are defined.
|
inline |
Get set of constraints for a give priority level.
|
inline |
Get constraints (implicit and explicit)
|
virtual |
Check whether a numerical constraint has been added
numericalConstraint | numerical constraint |
Reimplemented in hpp::constraints::solver::BySubstitution.
bool hpp::constraints::solver::HierarchicalIterative::definesSubmanifoldOf | ( | const HierarchicalIterative & | solver | ) | const |
Inclusion of manifolds
solver | another solver |
This function returns true if the solution manifold of the solver given as input is a submanifold of the solution manifold of this solver. The function tests whether constraints of the input solver are also in this solver.
|
inline |
|
inline |
Set error threshold.
|
inline |
Get error threshold.
|
protected |
|
inline |
Set free velocity variables
The other variables will be left unchanged by the iterative resolution.
intervals | set of index intervals |
|
inline |
Set free velocity variables
The other variables will be left unchanged by the iterative resolution.
|
inline |
Get free velocity variables.
void hpp::constraints::solver::HierarchicalIterative::getReducedJacobian | ( | matrixOut_t | J | ) | const |
|
virtual |
Get right hand side of a constraints.
Reimplemented in hpp::constraints::solver::BySubstitution.
void hpp::constraints::solver::HierarchicalIterative::getValue | ( | vectorOut_t | v | ) | const |
|
inline |
Get the inequality threshold.
|
inline |
set the inequality threshold
|
virtual |
Reimplemented in hpp::constraints::solver::BySubstitution.
bool hpp::constraints::solver::HierarchicalIterative::isConstraintSatisfied | ( | const ImplicitPtr_t & | constraint, |
vectorIn_t | arg, | ||
vectorOut_t | error, | ||
bool & | constraintFound | ||
) | const |
Whether a constraint is satisfied for an input vector
constraint,the | constraint in the solver, |
arg | the input vector |
error | the error of the constraint. |
constraintFound | whether the constraint belongs to the solver, |
|
inline |
|
inline |
|
inline |
|
inline |
Accessor to the last step done.
|
inline |
Set maximal number of iterations.
|
inline |
Get maximal number of iterations in config projector.
|
virtual |
add constraints of another solver
other | other solver |
Add constraints of other to this solver.
|
inline |
|
virtual |
Reimplemented in hpp::constraints::solver::BySubstitution.
|
inline |
Dimension of the problem after removing the rows of the jacobian which do not influence the error (only zeros along those lines).
|
inline |
Returns the squared norm of the error vector.
void hpp::constraints::solver::HierarchicalIterative::residualError | ( | vectorOut_t | error | ) | const |
Returns the error vector.
|
virtual |
Set right hand side of a constraints
constraint | the constraint, |
rhs | right hand side. |
Reimplemented in hpp::constraints::solver::BySubstitution.
|
virtual |
Set the right hand side
rhs | the right hand side |
Reimplemented in hpp::constraints::solver::BySubstitution.
vector_t hpp::constraints::solver::HierarchicalIterative::rightHandSide | ( | ) | const |
Get the right hand side
void hpp::constraints::solver::HierarchicalIterative::rightHandSideAt | ( | const value_type & | s | ) |
Set the right hand side at a given parameter.
s | parameter passed to Implicit::rightHandSideAt |
vector_t hpp::constraints::solver::HierarchicalIterative::rightHandSideFromConfig | ( | ConfigurationIn_t | config | ) |
Compute right hand side of equality constraints from a configuration
config | a configuration. |
for each constraint of type Equality, set right hand side as \(rhs = f(\mathbf{q})\).
|
virtual |
Compute right hand side of a constraint from a configuration
constraint | the constraint, |
config | a configuration. |
Set right hand side as \(rhs = f(\mathbf{q})\).
Reimplemented in hpp::constraints::solver::BySubstitution.
size_type hpp::constraints::solver::HierarchicalIterative::rightHandSideSize | ( | ) | const |
Get size of the right hand side
|
protected |
|
inline |
Set the saturation function.
|
inline |
Get the saturation function.
|
inline |
Returns the lowest singular value. If the jacobian has maximum rank r, then it corresponds to r-th greatest singular value. This value is zero when the jacobian is singular.
|
inline |
Status hpp::constraints::solver::HierarchicalIterative::solve | ( | vectorOut_t | arg, |
LineSearchType | ls = LineSearchType() |
||
) | const |
Solve the system of non linear equations
arg | initial guess, |
ls | line search method used. |
Use Newton Rhapson like iterative method until the error is below the threshold, or until the maximal number of iterations has been reached.
|
inline |
Solve the system of non linear equations
arg | initial guess, |
Use Newton Rhapson like iterative method until the error is below the threshold, or until the maximal number of iterations has been reached. Use the default line search method (fixed sequence of \(\alpha_i\)).
|
inline |
Get error threshold.
|
protected |
Allocate datas and update sizes of the problem Should be called whenever the stack is modified.
|
friend |
|
protected |
|
protected |
Members moved from core::ConfigProjector.
|
mutableprotected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
Unknown of the set of implicit constraints.
|
protected |
|
protected |
Value rank of constraint in its priority level.
|
protected |
Derivative rank of constraint in its priority level.
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
Priority level of constraint.
|
mutableprotected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
|
mutableprotected |
|
mutableprotected |
The smallest non-zero singular value.
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |