robotoc
robotoc - efficient ROBOT Optimal Control solvers
|
MPC solver for the crawl gait of quadrupeds. More...
#include <mpc_crawl.hpp>
Public Member Functions | |
MPCCrawl (const Robot &robot, const double T, const int N) | |
Construct MPC solver. More... | |
MPCCrawl () | |
Default constructor. More... | |
~MPCCrawl () | |
Destructor. More... | |
MPCCrawl (const MPCCrawl &)=default | |
Default copy constructor. More... | |
MPCCrawl & | operator= (const MPCCrawl &)=default |
Default copy assign operator. More... | |
MPCCrawl (MPCCrawl &&) noexcept=default | |
Default move constructor. More... | |
MPCCrawl & | operator= (MPCCrawl &&) noexcept=default |
Default move assign operator. More... | |
void | setGaitPattern (const std::shared_ptr< ContactPlannerBase > &foot_step_planner, const double swing_height, const double stance_time, const double swing_time, const double swing_start_time) |
Sets the gait pattern. More... | |
void | init (const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const SolverOptions &solver_options) |
Initializes the optimal control problem solover. More... | |
void | reset () |
Resets the optimal control problem solover via the solution computed by init(). More... | |
void | reset (const Eigen::VectorXd &q, const Eigen::VectorXd &v) |
Resets the optimal control problem solover via the solution computed by init(), q, and v. More... | |
void | setSolverOptions (const SolverOptions &solver_options) |
Sets the solver options. More... | |
void | updateSolution (const double t, const double dt, const Eigen::VectorXd &q, const Eigen::VectorXd &v) |
Updates the solution by iterationg the Newton-type method. More... | |
const Eigen::VectorXd & | getInitialControlInput () const |
Get the initial control input. More... | |
const Solution & | getSolution () const |
Get the solution over the horizon. More... | |
const aligned_vector< LQRPolicy > & | getLQRPolicy () const |
Gets of the local LQR policies over the horizon. More... | |
ControlPolicy | getControlPolicy (const double t) const |
Gets the control policy at the specified time. More... | |
double | KKTError (const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v) |
Computes the KKT residual of the optimal control problem. More... | |
double | KKTError () const |
Returns the l2-norm of the KKT residuals. MPCCrawl::updateSolution() must be computed. More... | |
std::shared_ptr< CostFunction > | getCostHandle () |
Gets the cost function handle. More... | |
std::shared_ptr< ConfigurationSpaceCost > | getConfigCostHandle () |
Gets the configuration space cost handle. More... | |
std::shared_ptr< ConfigurationSpaceCost > | getBaseRotationCostHandle () |
Gets the base rotation cost handle. More... | |
std::vector< std::shared_ptr< TaskSpace3DCost > > | getSwingFootCostHandle () |
Gets the swing foot task space costs (LF, LH, RF, RH feet) handle. More... | |
std::shared_ptr< CoMCost > | getCoMCostHandle () |
Gets the com cost handle. More... | |
std::shared_ptr< Constraints > | getConstraintsHandle () |
Gets the constraints handle. More... | |
std::shared_ptr< FrictionCone > | getFrictionConeHandle () |
Gets the friction cone constraints handle. More... | |
const OCPSolver & | getSolver () const |
Gets the const handle of the MPC solver. More... | |
const std::shared_ptr< ContactSequence > & | getContactSequence () const |
Gets the const handle of the contact sequence. More... | |
void | setRobotProperties (const RobotProperties &properties) |
Sets a collection of the properties for robot model in this MPC. More... | |
MPC solver for the crawl gait of quadrupeds.
robotoc::MPCCrawl::MPCCrawl | ( | const Robot & | robot, |
const double | T, | ||
const int | N | ||
) |
Construct MPC solver.
[in] | robot | Robot model. |
[in] | T | Length of the horizon. |
[in] | N | Number of the discretization grids of the horizon. |
robotoc::MPCCrawl::MPCCrawl | ( | ) |
Default constructor.
robotoc::MPCCrawl::~MPCCrawl | ( | ) |
Destructor.
|
default |
Default copy constructor.
|
defaultnoexcept |
Default move constructor.
std::shared_ptr< ConfigurationSpaceCost > robotoc::MPCCrawl::getBaseRotationCostHandle | ( | ) |
Gets the base rotation cost handle.
std::shared_ptr< CoMCost > robotoc::MPCCrawl::getCoMCostHandle | ( | ) |
Gets the com cost handle.
std::shared_ptr< ConfigurationSpaceCost > robotoc::MPCCrawl::getConfigCostHandle | ( | ) |
Gets the configuration space cost handle.
std::shared_ptr< Constraints > robotoc::MPCCrawl::getConstraintsHandle | ( | ) |
Gets the constraints handle.
|
inline |
Gets the const handle of the contact sequence.
|
inline |
Gets the control policy at the specified time.
[in] | t | The specified time. |
std::shared_ptr< CostFunction > robotoc::MPCCrawl::getCostHandle | ( | ) |
Gets the cost function handle.
std::shared_ptr< FrictionCone > robotoc::MPCCrawl::getFrictionConeHandle | ( | ) |
Gets the friction cone constraints handle.
const Eigen::VectorXd & robotoc::MPCCrawl::getInitialControlInput | ( | ) | const |
Get the initial control input.
const aligned_vector< LQRPolicy > & robotoc::MPCCrawl::getLQRPolicy | ( | ) | const |
Gets of the local LQR policies over the horizon.
const Solution & robotoc::MPCCrawl::getSolution | ( | ) | const |
Get the solution over the horizon.
|
inline |
Gets the const handle of the MPC solver.
std::vector< std::shared_ptr< TaskSpace3DCost > > robotoc::MPCCrawl::getSwingFootCostHandle | ( | ) |
Gets the swing foot task space costs (LF, LH, RF, RH feet) handle.
void robotoc::MPCCrawl::init | ( | const double | t, |
const Eigen::VectorXd & | q, | ||
const Eigen::VectorXd & | v, | ||
const SolverOptions & | solver_options | ||
) |
Initializes the optimal control problem solover.
[in] | t | Initial time of the horizon. |
[in] | q | Initial configuration. Size must be Robot::dimq(). |
[in] | v | Initial velocity. Size must be Robot::dimv(). |
[in] | solver_options | Solver options for the initialization. |
double robotoc::MPCCrawl::KKTError | ( | ) | const |
Returns the l2-norm of the KKT residuals. MPCCrawl::updateSolution() must be computed.
double robotoc::MPCCrawl::KKTError | ( | const double | t, |
const Eigen::VectorXd & | q, | ||
const Eigen::VectorXd & | v | ||
) |
Computes the KKT residual of the optimal control problem.
[in] | t | Initial time of the horizon. |
[in] | q | Initial configuration. Size must be Robot::dimq(). |
[in] | v | Initial velocity. Size must be Robot::dimv(). |
Default move assign operator.
void robotoc::MPCCrawl::reset | ( | ) |
Resets the optimal control problem solover via the solution computed by init().
void robotoc::MPCCrawl::reset | ( | const Eigen::VectorXd & | q, |
const Eigen::VectorXd & | v | ||
) |
Resets the optimal control problem solover via the solution computed by init(), q, and v.
void robotoc::MPCCrawl::setGaitPattern | ( | const std::shared_ptr< ContactPlannerBase > & | foot_step_planner, |
const double | swing_height, | ||
const double | stance_time, | ||
const double | swing_time, | ||
const double | swing_start_time | ||
) |
Sets the gait pattern.
[in] | foot_step_planner | Foot step planner of the gait. |
[in] | swing_height | Swing height of the gait. |
[in] | swing_time | Swing time of the gait. |
[in] | stance_time | Stance time of the gait. |
[in] | swing_start_time | Start time of the gait. |
void robotoc::MPCCrawl::setRobotProperties | ( | const RobotProperties & | properties | ) |
Sets a collection of the properties for robot model in this MPC.
[in] | properties | A collection of the properties for the robot model. |
void robotoc::MPCCrawl::setSolverOptions | ( | const SolverOptions & | solver_options | ) |
Sets the solver options.
[in] | solver_options | Solver options. |
void robotoc::MPCCrawl::updateSolution | ( | const double | t, |
const double | dt, | ||
const Eigen::VectorXd & | q, | ||
const Eigen::VectorXd & | v | ||
) |
Updates the solution by iterationg the Newton-type method.
[in] | t | Initial time of the horizon. |
[in] | dt | Sampling time of MPC. Must be positive. |
[in] | q | Configuration. Size must be Robot::dimq(). |
[in] | v | Velocity. Size must be Robot::dimv(). |