|
robotoc
robotoc - efficient ROBOT Optimal Control solvers
|
Optimal control problem solver by Riccati recursion. More...
#include <ocp_solver.hpp>
Public Member Functions | |
| OCPSolver (const OCP &ocp, const SolverOptions &solver_options=SolverOptions()) | |
| Construct optimal control problem solver. More... | |
| OCPSolver () | |
| Default constructor. More... | |
| ~OCPSolver ()=default | |
| Default destructor. More... | |
| OCPSolver (const OCPSolver &)=default | |
| Default copy constructor. More... | |
| OCPSolver & | operator= (const OCPSolver &)=default |
| Default copy assign operator. More... | |
| OCPSolver (OCPSolver &&) noexcept=default | |
| Default move constructor. More... | |
| OCPSolver & | operator= (OCPSolver &&) noexcept=default |
| Default move assign operator. More... | |
| void | setSolverOptions (const SolverOptions &solver_options) |
| Sets the solver option. More... | |
| void | discretize (const double t) |
| Discretizes the problem and reiszes the data structures. More... | |
| void | initConstraints () |
| Initializes the priaml-dual interior point method for inequality constraints. More... | |
| void | solve (const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const bool init_solver=true) |
| Solves the optimal control problem. Internally calls updateSolutio() and discretize(). More... | |
| const SolverStatistics & | getSolverStatistics () const |
| Gets the solver statistics. More... | |
| const Solution & | getSolution () const |
| Get the solution over the horizon. More... | |
| const SplitSolution & | getSolution (const int stage) const |
| Get the split solution of a time stage. For example, the control input torques at the initial stage can be obtained by ocp.getSolution(0).u. More... | |
| std::vector< Eigen::VectorXd > | getSolution (const std::string &name, const std::string &option="") const |
| Get the solution vector over the horizon. More... | |
| const aligned_vector< LQRPolicy > & | getLQRPolicy () const |
| Gets of the local LQR policies over the horizon. More... | |
| const RiccatiFactorization & | getRiccatiFactorization () const |
| Gets the Riccati factorizations. This can be interpreted as locally approximated cost-to-go functions. More... | |
| void | setSolution (const Solution &s) |
| Sets the solution guess over the horizon. More... | |
| void | setSolution (const std::string &name, const Eigen::VectorXd &value) |
| Sets the solution guess over the horizon. More... | |
| double | KKTError (const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v) |
| Computes the KKT residual of the optimal control problem and returns the KKT error, that is, the l2-norm of the KKT residual. More... | |
| double | KKTError () const |
| Returns the l2-norm of the KKT residuals using the results of OCPsolver::updateSolution() or OCPsolver::solve(). More... | |
| const TimeDiscretization & | getTimeDiscretization () const |
| Gets the discretization. More... | |
| void | setRobotProperties (const RobotProperties &properties) |
| Sets a collection of the properties for robot model in this solver. More... | |
| void | disp (std::ostream &os) const |
| Displays the optimal control problem solver onto a ostream. More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const OCPSolver &ocp_solver) |
Optimal control problem solver by Riccati recursion.
| robotoc::OCPSolver::OCPSolver | ( | const OCP & | ocp, |
| const SolverOptions & | solver_options = SolverOptions() |
||
| ) |
Construct optimal control problem solver.
| [in] | ocp | Optimal control problem. |
| [in] | solver_options | Solver options. Default is SolverOptions(). |
| robotoc::OCPSolver::OCPSolver | ( | ) |
Default constructor.
|
default |
Default destructor.
|
default |
Default copy constructor.
|
defaultnoexcept |
Default move constructor.
| void robotoc::OCPSolver::discretize | ( | const double | t | ) |
Discretizes the problem and reiszes the data structures.
| [in] | t | Initial time of the horizon. |
| void robotoc::OCPSolver::disp | ( | std::ostream & | os | ) | const |
Displays the optimal control problem solver onto a ostream.
| const aligned_vector< LQRPolicy > & robotoc::OCPSolver::getLQRPolicy | ( | ) | const |
Gets of the local LQR policies over the horizon.
| const RiccatiFactorization & robotoc::OCPSolver::getRiccatiFactorization | ( | ) | const |
Gets the Riccati factorizations. This can be interpreted as locally approximated cost-to-go functions.
| const Solution & robotoc::OCPSolver::getSolution | ( | ) | const |
Get the solution over the horizon.
| const SplitSolution & robotoc::OCPSolver::getSolution | ( | const int | stage | ) | const |
Get the split solution of a time stage. For example, the control input torques at the initial stage can be obtained by ocp.getSolution(0).u.
| [in] | stage | Time stage of interest. Must be larger than 0 and smaller than N. |
| std::vector< Eigen::VectorXd > robotoc::OCPSolver::getSolution | ( | const std::string & | name, |
| const std::string & | option = "" |
||
| ) | const |
Get the solution vector over the horizon.
| [in] | name | Name of the variable. |
| [in] | option | Option for the solution. If name == "f" and option == "WORLD", the contact forces expressed in the world frame is returned. if option is set to other values, these expressed in the local frame are returned. |
| const SolverStatistics & robotoc::OCPSolver::getSolverStatistics | ( | ) | const |
Gets the solver statistics.
| const TimeDiscretization & robotoc::OCPSolver::getTimeDiscretization | ( | ) | const |
Gets the discretization.
| void robotoc::OCPSolver::initConstraints | ( | ) |
Initializes the priaml-dual interior point method for inequality constraints.
| double robotoc::OCPSolver::KKTError | ( | ) | const |
Returns the l2-norm of the KKT residuals using the results of OCPsolver::updateSolution() or OCPsolver::solve().
| double robotoc::OCPSolver::KKTError | ( | const double | t, |
| const Eigen::VectorXd & | q, | ||
| const Eigen::VectorXd & | v | ||
| ) |
Computes the KKT residual of the optimal control problem and returns the KKT error, that is, the l2-norm of the KKT residual.
| [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 copy assign operator.
Default move assign operator.
| void robotoc::OCPSolver::setRobotProperties | ( | const RobotProperties & | properties | ) |
Sets a collection of the properties for robot model in this solver.
| [in] | properties | A collection of the properties for the robot model. |
| void robotoc::OCPSolver::setSolution | ( | const Solution & | s | ) |
Sets the solution guess over the horizon.
| [in] | s | Solution. |
| void robotoc::OCPSolver::setSolution | ( | const std::string & | name, |
| const Eigen::VectorXd & | value | ||
| ) |
Sets the solution guess over the horizon.
| [in] | name | Name of the variable. |
| [in] | value | Value of the specified variable. |
| void robotoc::OCPSolver::setSolverOptions | ( | const SolverOptions & | solver_options | ) |
Sets the solver option.
| [in] | solver_options | Solver options. |
| void robotoc::OCPSolver::solve | ( | const double | t, |
| const Eigen::VectorXd & | q, | ||
| const Eigen::VectorXd & | v, | ||
| const bool | init_solver = true |
||
| ) |
Solves the optimal control problem. Internally calls updateSolutio() and discretize().
| [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] | init_solver | If true, initializes the solver, that is, calls discretize(), initConstraints(), and clears the line search filter. Default is true. |
|
friend |