class
#include <iDynTree/ConstraintsGroup.h>
ConstraintsGroup Class grouping constraints associated with a TimeRange.
This class allows to define a set of constraints which are enabled only for a particular time range. This allow to change the constraint structure depending on time. Given a specific time instant, only one constraint is enabled (the one whose TimeRange contains the instant and has the higher initTime). If the specified time instant does not fall into any time constraint time range, a dummy constraint wil be evaluated, i.e. . All the constraints that will be added to the group should have dimension at most equal to maxConstraintSize. If the constraint size is smaller than the maxConstraintSize, dummy constraints as the above will be added on the bottom. This allow to keep a constant structure even if the constraints have different dimensions. A typical example is when a constraint is enabled only for a certain period of time.
Constructors, destructors, conversion operators
- ConstraintsGroup(const std::string& name, unsigned int maxConstraintSize)
- Default constructor.
- ~ConstraintsGroup()
- ConstraintsGroup(const ConstraintsGroup& other) deleted
Public functions
- auto name() const -> const std::string
- Return the name of the group.
- auto constraintsDimension() const -> unsigned int
- Return the maximum constraint dimension of the group.
- auto addConstraint(std::shared_ptr<Constraint> constraint, const TimeRange& timeRange) -> bool
- Add a constraint to the group.
- auto addConstraint(std::shared_ptr<LinearConstraint> linearConstraint, const TimeRange& timeRange) -> bool
- Add a linear constraint to the group.
- auto updateTimeRange(const std::string& name, const TimeRange& timeRange) -> bool
- Update the TimeRange of a previously added constraint.
- auto removeConstraint(const std::string& name) -> bool
- Remove a previously added constraint.
- auto getTimeRange(const std::string& name, TimeRange& timeRange) -> bool
- Get the TimeRange of the specified constraint.
- auto getTimeRanges() -> std::vector<TimeRange>&
- Get a vector containing all the TimeRanges of the added constraints.
- auto isFeasibilePoint(double time, const VectorDynSize& state, const VectorDynSize& control) -> bool
- Check whether, at the specified time, the enabled constraint is satisfied.
- auto evaluateConstraints(double time, const VectorDynSize& state, const VectorDynSize& control, VectorDynSize& constraints) -> bool
- Evaluate the constraint which is enabled at the specified time.
- auto getLowerBound(double time, VectorDynSize& lowerBound) -> bool
- Get the constraints lower bound.
- auto getUpperBound(double time, VectorDynSize& upperBound) -> bool
- Get the constraints upper bound.
- auto constraintJacobianWRTState(double time, const VectorDynSize& state, const VectorDynSize& control, MatrixDynSize& jacobian) -> bool
- Evaluate the constraint jacobian with respect to the state, given the specified time instant.
- auto constraintJacobianWRTControl(double time, const VectorDynSize& state, const VectorDynSize& control, MatrixDynSize& jacobian) -> bool
- Evaluate the constraint jacobian with respect to the control, given the specified time instant.
-
auto constraintJacobianWRTStateSparsity(iDynTree::
optimalcontrol:: SparsityStructure& stateSparsity) const -> bool - Returns the set of nonzeros elements in terms of row and colun index, in the state jacobian.
-
auto constraintJacobianWRTControlSparsity(iDynTree::
optimalcontrol:: SparsityStructure& controlSparsity) const -> bool - Returns the set of nonzeros elements in terms of row and colun index, in the control jacobian.
- auto constraintSecondPartialDerivativeWRTState(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) -> bool
- Evaluate constraint second partial derivative wrt the state variables.
- auto constraintSecondPartialDerivativeWRTControl(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) -> bool
- Evaluate constraint second partial derivative wrt the control.
- auto constraintSecondPartialDerivativeWRTStateControl(double time, const VectorDynSize& state, const VectorDynSize& control, const VectorDynSize& lambda, MatrixDynSize& hessian) -> bool
- Evaluate constraint second partial derivative wrt the state and control.
-
auto constraintsSecondPartialDerivativeWRTStateSparsity(iDynTree::
optimalcontrol:: SparsityStructure& stateSparsity) -> bool - Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.
-
auto constraintsSecondPartialDerivativeWRTStateControlSparsity(iDynTree::
optimalcontrol:: SparsityStructure& stateControlSparsity) -> bool - Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.
-
auto constraintsSecondPartialDerivativeWRTControlSparsity(iDynTree::
optimalcontrol:: SparsityStructure& controlSparsity) -> bool - Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.
- auto isAnyTimeGroup() -> bool
- Flag returning true if the group is an "AnyTime" group.
- auto numberOfConstraints() const -> unsigned int
- Number of constraints added in the group.
- auto listConstraints() const -> const std::vector<std::string>
- Lists the available constraints.
- auto isLinearGroup() const -> bool
- Tells if the groups contains only linear constraints.
Function documentation
iDynTree:: optimalcontrol:: ConstraintsGroup:: ConstraintsGroup(const std::string& name,
unsigned int maxConstraintSize)
Default constructor.
Parameters | |
---|---|
name in | Univocal name of the group |
maxConstraintSize in | Maximum dimension allowed when adding a constraint. |
const std::string iDynTree:: optimalcontrol:: ConstraintsGroup:: name() const
Return the name of the group.
Returns | The univocal name of the constraint group. |
---|
unsigned int iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintsDimension() const
Return the maximum constraint dimension of the group.
Returns | The maximum constraint dimension of the group. |
---|
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: addConstraint(std::shared_ptr<Constraint> constraint,
const TimeRange& timeRange)
Add a constraint to the group.
Parameters | |
---|---|
constraint in | Shared pointer to the user defined constraint. |
timeRange in | Time range in which the constraint will be enabled. |
Returns | True if successfull. Posible causes of failures are: empty pointer, dimension bigger than maxConstraintSize, invalid TimeRange. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: addConstraint(std::shared_ptr<LinearConstraint> linearConstraint,
const TimeRange& timeRange)
Add a linear constraint to the group.
Parameters | |
---|---|
linearConstraint in | Shared pointer to a linear constraint. |
timeRange in | Time range in which the constraint will be enabled. |
Returns | True if successfull. Posible causes of failures are: empty pointer, dimension bigger than maxConstraintSize, invalid TimeRange. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: updateTimeRange(const std::string& name,
const TimeRange& timeRange)
Update the TimeRange of a previously added constraint.
Parameters | |
---|---|
name in | The name of the constraint whose TimeRange has to be updated. |
timeRange in | The new TimeRange. |
Returns | True if successfull. Possible causes of failure: invalid TimeRange, a constraint does not exist with the specified name. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: removeConstraint(const std::string& name)
Remove a previously added constraint.
Parameters | |
---|---|
name in | The name of the constraint that has to be removed |
Returns | True if successfull. Possible causes of failure: a constraint does not exist with the specified name. |
Note: the sparsity pattern is not updated.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: getTimeRange(const std::string& name,
TimeRange& timeRange)
Get the TimeRange of the specified constraint.
Parameters | |
---|---|
name in | The name of the constraint whose TimeRange you are interested in. |
timeRange out | The requested TimeRange. |
Returns | True if successfull. Possible causes of failure: a constraint does not exist with the specified name. |
std::vector<TimeRange>& iDynTree:: optimalcontrol:: ConstraintsGroup:: getTimeRanges()
Get a vector containing all the TimeRanges of the added constraints.
Returns | A vector containing all the TimeRanges of the added constraints. |
---|
The order corresponds to the one get via the listConstraints method.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: isFeasibilePoint(double time,
const VectorDynSize& state,
const VectorDynSize& control)
Check whether, at the specified time, the enabled constraint is satisfied.
Parameters | |
---|---|
time in | The time at which the constraint group is evaluated. |
state in | The state at which the constraint group is evaluated. |
control in | The control at which the constraint group is evaluated. |
Returns | True if, at the specified time, the enabled constraint is satisfied. |
Given the time instant, this method search for the constraint to be enabled according to the specified TimeRange. Then calls the constraint to check the feasibility of the constraint given the specified state and control.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: evaluateConstraints(double time,
const VectorDynSize& state,
const VectorDynSize& control,
VectorDynSize& constraints)
Evaluate the constraint which is enabled at the specified time.
Parameters | |
---|---|
time in | The time at which the constraint group is evaluated. |
state in | The state at which the constraint group is evaluated. |
control in | The control at which the constraint group is evaluated. |
constraints out | The value obtained by evaluating the enbled constraint. |
Returns | True if the evaluation of the enabled constraint was successfull. |
Given the time instant, this method search for the constraint to be enabled according to the specified TimeRange. Then it evaluates it given the specified state and control.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: getLowerBound(double time,
VectorDynSize& lowerBound)
Get the constraints lower bound.
Parameters | |
---|---|
time in | Time at which querying the lower bound. |
lowerBound out | The lowerBound value. |
Returns | True if, for the given instant, a lower bound is set. False otherwise. |
This value depends upon the chosen time instant.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: getUpperBound(double time,
VectorDynSize& upperBound)
Get the constraints upper bound.
Parameters | |
---|---|
time in | Time at which querying the upper bound. |
upperBound out | The upperBound value. |
Returns | True if, for the given instant, a upper bound is set. False otherwise. |
This value depends upon the chosen time instant.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintJacobianWRTState(double time,
const VectorDynSize& state,
const VectorDynSize& control,
MatrixDynSize& jacobian)
Evaluate the constraint jacobian with respect to the state, given the specified time instant.
Parameters | |
---|---|
time in | Time at which the jacobian is evaluted. |
state in | The state at which the jacobian is evaluated. |
control in | The control at which the jacobian is evaluated. |
jacobian out | The output jacobian. |
Returns | True if the evaluation of the corresponding method of the enabled constraint return true. False otherwise. |
Given the time instant, this method search for the constraint to be enabled according to the specified TimeRange. Then it evaluates its jacobian given the specified state and control.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintJacobianWRTControl(double time,
const VectorDynSize& state,
const VectorDynSize& control,
MatrixDynSize& jacobian)
Evaluate the constraint jacobian with respect to the control, given the specified time instant.
Parameters | |
---|---|
time in | Time at which the jacobian is evaluted. |
state in | The state at which the jacobian is evaluated. |
control in | The control at which the jacobian is evaluated. |
jacobian out | The output jacobian. |
Returns | True if the evaluation of the corresponding method of the enabled constraint return true. False otherwise. |
Given the time instant, this method search for the constraint to be enabled according to the specified TimeRange. Then it evaluates its jacobian given the specified state and control.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintJacobianWRTStateSparsity(iDynTree:: optimalcontrol:: SparsityStructure& stateSparsity) const
Returns the set of nonzeros elements in terms of row and colun index, in the state jacobian.
Parameters | |
---|---|
stateSparsity | Sparsity structure of the partial derivative of the jacobian wrt state variables. |
Returns | true if the sparsity is available. False otherwise. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintJacobianWRTControlSparsity(iDynTree:: optimalcontrol:: SparsityStructure& controlSparsity) const
Returns the set of nonzeros elements in terms of row and colun index, in the control jacobian.
Parameters | |
---|---|
controlSparsity | Sparsity structure of the partial derivative of the jacobian wrt control variables. |
Returns | true if the sparsity is available. False otherwise. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintSecondPartialDerivativeWRTState(double time,
const VectorDynSize& state,
const VectorDynSize& control,
const VectorDynSize& lambda,
MatrixDynSize& hessian)
Evaluate constraint second partial derivative wrt the state variables.
Parameters | |
---|---|
time in | The time at which the partial derivative is computed. |
state in | The state value at which the partial derivative is computed. |
control in | The control value at which the partial derivative is computed.. |
lambda in | The lagrange multipliers |
hessian out | The output partial derivative. |
Returns | True if successfull, false otherwise (or if not implemented). |
It is the result of
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintSecondPartialDerivativeWRTControl(double time,
const VectorDynSize& state,
const VectorDynSize& control,
const VectorDynSize& lambda,
MatrixDynSize& hessian)
Evaluate constraint second partial derivative wrt the control.
Parameters | |
---|---|
time in | The time at which the partial derivative is computed. |
state in | The state value at which the partial derivative is computed. |
control in | The control value at which the partial derivative is computed. |
lambda in | The lagrange multipliers |
hessian out | The output partial derivative. |
Returns | True if successfull, false otherwise (or if not implemented). |
It is the result of
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintSecondPartialDerivativeWRTStateControl(double time,
const VectorDynSize& state,
const VectorDynSize& control,
const VectorDynSize& lambda,
MatrixDynSize& hessian)
Evaluate constraint second partial derivative wrt the state and control.
Parameters | |
---|---|
time in | The time at which the partial derivative is computed. |
state in | The state value at which the partial derivative is computed. |
control in | The control value at which the partial derivative is computed. |
lambda in | The lagrange multipliers |
hessian out | The output partial derivative. |
Returns | True if successfull, false otherwise (or if not implemented). |
It is the result of , thus it has number of rows equals to the number of states and number of cols equal to the number of control inputs.
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintsSecondPartialDerivativeWRTStateSparsity(iDynTree:: optimalcontrol:: SparsityStructure& stateSparsity)
Returns the set of nonzeros elements in terms of row and colun index, in the state hessian.
Parameters | |
---|---|
stateSparsity | Sparsity structure of the partial derivative of the jacobian wrt state variables. |
Returns | true if the sparsity is available. False otherwise. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintsSecondPartialDerivativeWRTStateControlSparsity(iDynTree:: optimalcontrol:: SparsityStructure& stateControlSparsity)
Returns the set of nonzeros elements in terms of row and colun index, in the mixed hessian.
Parameters | |
---|---|
stateControlSparsity | Sparsity structure of the partial derivative of the jacobian wrt state and control variables. |
Returns | true if the sparsity is available. False otherwise. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: constraintsSecondPartialDerivativeWRTControlSparsity(iDynTree:: optimalcontrol:: SparsityStructure& controlSparsity)
Returns the set of nonzeros elements in terms of row and colun index, in the control hessian.
Parameters | |
---|---|
controlSparsity | Sparsity structure of the partial derivative of the jacobian wrt control variables. |
Returns | true if the sparsity is available. False otherwise. |
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: isAnyTimeGroup()
Flag returning true if the group is an "AnyTime" group.
Returns | true if the group contains a single constraint always enables. False otherwise. |
---|
An "AnyTime" group contains only one constraint which is always enabled. It corresponds to a simple constraint.
unsigned int iDynTree:: optimalcontrol:: ConstraintsGroup:: numberOfConstraints() const
Number of constraints added in the group.
Returns | The number of constraints currently loaded in the group. |
---|
const std::vector<std::string> iDynTree:: optimalcontrol:: ConstraintsGroup:: listConstraints() const
Lists the available constraints.
Returns | The list of the names of the constraints added to the group. |
---|
bool iDynTree:: optimalcontrol:: ConstraintsGroup:: isLinearGroup() const
Tells if the groups contains only linear constraints.
Returns | true if contains only linear constraints. False if at least one generic constraint is added. |
---|