1#ifndef ROBOTOC_CONSTRAINTS_HPP_
2#define ROBOTOC_CONSTRAINTS_HPP_
6#include <unordered_map>
34 = std::shared_ptr<ImpactConstraintComponentBase>;
44 const double fraction_to_boundary_rule=0.995);
76 bool exist(const std::
string& name) const;
99 void erase(const std::
string& name);
130 const
int time_stage=-1) const;
366 void disp(std::ostream& os) const;
368 friend std::ostream& operator<<(std::ostream& os, const
Constraints& constraints);
370 friend std::ostream& operator<<(std::ostream& os,
375 velocity_level_constraints_,
376 acceleration_level_constraints_;
378 std::unordered_map<std::
string,
size_t> position_level_constraint_names_,
379 velocity_level_constraint_names_,
380 acceleration_level_constraint_names_,
381 impact_level_constraint_names_;
382 double barrier_, fraction_to_boundary_rule_;
Data for constraints. Composed of ConstraintComponentData corrensponding to the components of Constra...
Definition: constraints_data.hpp:16
Stack of the inequality constraints. Composed by constraint components that inherits ConstraintCompon...
Definition: constraints.hpp:30
std::vector< std::string > getPositionLevelConstraintList() const
Gets a list of the position-level constraints.
Constraints(const Constraints &)=default
Default copy constructor.
std::vector< std::string > getConstraintList() const
Gets a list of the constraints.
Constraints & operator=(const Constraints &)=default
Default copy operator.
void evalConstraint(Robot &robot, const ContactStatus &contact_status, ConstraintsData &data, const SplitSolution &s) const
Computes the primal residual, residual in the complementary slackness, and the log-barrier function o...
void setFractionToBoundaryRule(const double fraction_to_boundary_rule)
Sets the parameter of the fraction-to-boundary-rule for all the constraint components.
double maxDualStepSize(const ConstraintsData &data) const
Computes and returns the maximum step size by applying fraction-to-boundary-rule to the directions of...
Constraints(Constraints &&) noexcept=default
Default move constructor.
ConstraintComponentBasePtr getConstraintComponent(const std::string &name) const
Gets a constraint component. If a component of the specified name does not exist, throws an exeption.
void condenseSlackAndDual(const ContactStatus &contact_status, ConstraintsData &data, SplitKKTMatrix &kkt_matrix, SplitKKTResidual &kkt_residual) const
Condenses the slack and dual variables. linearizeConstraints() must be called before this function.
void add(const std::string &name, ConstraintComponentBasePtr constraint)
Adds a constraint component. If a component of the same name exists, throws an exeption.
void linearizeConstraints(Robot &robot, const ContactStatus &contact_status, ConstraintsData &data, const SplitSolution &s, SplitKKTResidual &kkt_residual) const
Evaluates the constraints (i.e., calls evalConstraint()) and adds the products of the Jacobian of the...
double maxSlackStepSize(const ConstraintsData &data) const
Computes and returns the maximum step size by applying fraction-to-boundary-rule to the directions of...
void erase(const std::string &name)
Erases a constraint component. If a component of the specified name does not exist,...
void setBarrierParam(const double barrier_param)
Sets the barrier parameter for all the constraint components.
double getBarrierParam() const
Gets the barrier parameter.
std::vector< std::string > getVelocityLevelConstraintList() const
Gets a list of the velocity-level constraints.
void expandSlackAndDual(const ContactStatus &contact_status, ConstraintsData &data, const SplitDirection &d) const
Expands the slack and dual, i.e., computes the directions of the slack and dual variables from the di...
static void updateSlack(ConstraintsData &data, const double step_size)
Updates the slack variables according to step_size.
bool isFeasible(Robot &robot, const ContactStatus &contact_status, ConstraintsData &data, const SplitSolution &s) const
Checks whether the current split solution s is feasible or not.
std::shared_ptr< ImpactConstraintComponentBase > ImpactConstraintComponentBasePtr
Definition: constraints.hpp:34
Constraints(const double barrier_param=1.0e-03, const double fraction_to_boundary_rule=0.995)
Constructor.
ImpactConstraintComponentBasePtr getImpactConstraintComponent(const std::string &name) const
Gets a constraint component. If a component of the specified name does not exist, throws an exeption.
std::vector< std::string > getAccelerationLevelConstraintList() const
Gets a list of the acceleration-level constraints.
ConstraintsData createConstraintsData(const Robot &robot, const int time_stage=-1) const
Creates ConstraintsData according to robot model and constraint components.
~Constraints()=default
Default destructor.
void setSlackAndDual(Robot &robot, const ContactStatus &contact_status, ConstraintsData &data, const SplitSolution &s) const
Sets the slack and dual variables of each constraint components.
void clear()
Clears constraints by removing all components.
double getFractionToBoundaryRule() const
Gets the parameter of the fraction-to-boundary-rule.
std::vector< std::string > getImpactLevelConstraintList() const
Gets a list of the impact-level constraints.
std::shared_ptr< ConstraintComponentBase > ConstraintComponentBasePtr
Definition: constraints.hpp:32
void disp(std::ostream &os) const
Displays the constraints onto a ostream.
static void updateDual(ConstraintsData &data, const double step_size)
Updates the dual variables according to step_size.
bool exist(const std::string &name) const
Checks if thsi has a constraint component of the specified name.
Impact status of robot model. Wrapper of ContactStatus to treat impacts.
Definition: impact_status.hpp:21
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
Newton direction of the solution to the optimal control problem split into a time stage.
Definition: split_direction.hpp:20
The KKT matrix split into a time stage.
Definition: split_kkt_matrix.hpp:18
KKT residual split into each time stage.
Definition: split_kkt_residual.hpp:18
Solution to the optimal control problem split into a time stage.
Definition: split_solution.hpp:20
Definition: constraint_component_base.hpp:17