1#ifndef ROBOTOC_MPC_CRAWL_HPP_
2#define ROBOTOC_MPC_CRAWL_HPP_
7#include "Eigen/Geometry"
89 const
double swing_height, const
double stance_time,
90 const
double swing_time, const
double swing_start_time);
101 void init(const
double t, const Eigen::VectorXd& q, const Eigen::VectorXd& v,
116 void reset(const Eigen::VectorXd& q, const Eigen::VectorXd& v);
134 const Eigen::VectorXd& v);
171 double KKTError(
const double t,
const Eigen::VectorXd& q,
172 const Eigen::VectorXd& v);
234 return contact_sequence_;
244 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
247 std::shared_ptr<ContactPlannerBase> foot_step_planner_;
248 std::shared_ptr<ContactSequence> contact_sequence_;
249 std::shared_ptr<CostFunction> cost_;
250 std::shared_ptr<Constraints> constraints_;
255 double swing_height_, swing_time_, stance_time_, swing_start_time_,
256 T_, dt_, dtm_, ts_last_, eps_;
257 int N_, current_step_, predict_step_;
258 bool enable_stance_phase_;
260 std::shared_ptr<ConfigurationSpaceCost> config_cost_;
261 std::shared_ptr<ConfigurationSpaceCost> base_rot_cost_;
262 std::shared_ptr<TaskSpace3DCost> LF_foot_cost_, LH_foot_cost_,
263 RF_foot_cost_, RH_foot_cost_;
264 std::shared_ptr<CoMCost> com_cost_;
265 std::shared_ptr<MPCPeriodicConfigurationRef> base_rot_ref_;
266 std::shared_ptr<MPCPeriodicSwingFootRef> LF_foot_ref_, LH_foot_ref_,
267 RF_foot_ref_, RH_foot_ref_;
268 std::shared_ptr<MPCPeriodicCoMRef> com_ref_;
269 std::shared_ptr<FrictionCone> friction_cone_;
271 bool addStep(
const double t);
273 void resetContactPlacements(
const double t,
const Eigen::VectorXd& q,
274 const Eigen::VectorXd& v);
The state feedback and feedforward policy of LQR subproblem at a time stage.
Definition: lqr_policy.hpp:16
MPC solver for the crawl gait of quadrupeds.
Definition: mpc_crawl.hpp:40
std::shared_ptr< CostFunction > getCostHandle()
Gets the cost function handle.
void reset()
Resets the optimal control problem solover via the solution computed by init().
void setRobotProperties(const RobotProperties &properties)
Sets a collection of the properties for robot model in this MPC.
MPCCrawl(const Robot &robot, const double T, const int N)
Construct MPC solver.
const OCPSolver & getSolver() const
Gets the const handle of the MPC solver.
Definition: mpc_crawl.hpp:227
double KKTError(const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v)
Computes the KKT residual of the optimal control problem.
std::shared_ptr< CoMCost > getCoMCostHandle()
Gets the com cost handle.
std::shared_ptr< ConfigurationSpaceCost > getConfigCostHandle()
Gets the configuration space cost handle.
MPCCrawl(const MPCCrawl &)=default
Default copy constructor.
MPCCrawl()
Default constructor.
void setSolverOptions(const SolverOptions &solver_options)
Sets the solver options.
const Eigen::VectorXd & getInitialControlInput() const
Get the initial control input.
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.
const Solution & getSolution() const
Get the solution over the horizon.
std::vector< std::shared_ptr< TaskSpace3DCost > > getSwingFootCostHandle()
Gets the swing foot task space costs (LF, LH, RF, RH feet) handle.
MPCCrawl(MPCCrawl &&) noexcept=default
Default move constructor.
std::shared_ptr< ConfigurationSpaceCost > getBaseRotationCostHandle()
Gets the base rotation cost handle.
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.
void init(const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const SolverOptions &solver_options)
Initializes the optimal control problem solover.
const aligned_vector< LQRPolicy > & getLQRPolicy() const
Gets of the local LQR policies over the horizon.
double KKTError() const
Returns the l2-norm of the KKT residuals. MPCCrawl::updateSolution() must be computed.
MPCCrawl & operator=(const MPCCrawl &)=default
Default copy assign operator.
std::shared_ptr< Constraints > getConstraintsHandle()
Gets the constraints handle.
const std::shared_ptr< ContactSequence > & getContactSequence() const
Gets the const handle of the contact sequence.
Definition: mpc_crawl.hpp:233
ControlPolicy getControlPolicy(const double t) const
Gets the control policy at the specified time.
Definition: mpc_crawl.hpp:159
std::shared_ptr< FrictionCone > getFrictionConeHandle()
Gets the friction cone constraints handle.
Optimal control problem solver by Riccati recursion.
Definition: ocp_solver.hpp:41
Dynamics and kinematics model of robots. Wraps pinocchio::Model and pinocchio::Data....
Definition: robot.hpp:32
Definition: constraint_component_base.hpp:17
aligned_vector< SplitSolution > Solution
Solution to the optimal control problem.
Definition: solution.hpp:16
std::vector< T, Eigen::aligned_allocator< T > > aligned_vector
std vector with Eigen::aligned_allocator.
Definition: aligned_vector.hpp:14
Control pocily constructed for the MPC solution.
Definition: control_policy.hpp:17
Collection of the robot properties, which can change after constructing robot models.
Definition: robot_properties.hpp:30
Options of optimal control solvers.
Definition: solver_options.hpp:17