centroidal_control_collection
|
Go to the documentation of this file.
5 #include <nmpc_ddp/DDPSolver.h>
21 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
30 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 Eigen::Vector3d
pos = Eigen::Vector3d::Zero();
69 WeightParam(
const Eigen::Vector3d & _running_pos = Eigen::Vector3d::Constant(1.0),
70 const Eigen::Vector3d & _running_linear_momentum = Eigen::Vector3d::Constant(0.0),
71 const Eigen::Vector3d & _running_angular_momentum = Eigen::Vector3d::Constant(1.0),
72 double _running_force = 1e-6,
73 const Eigen::Vector3d & _terminal_pos = Eigen::Vector3d::Constant(1.0),
74 const Eigen::Vector3d & _terminal_linear_momentum = Eigen::Vector3d::Constant(0.0),
75 const Eigen::Vector3d & _terminal_angular_momentum = Eigen::Vector3d::Constant(1.0))
87 class DdpProblem :
public nmpc_ddp::DDPProblem<9, Eigen::Dynamic>
90 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
98 : nmpc_ddp::DDPProblem<9, Eigen::Dynamic>(horizon_dt),
mass_(mass),
weight_param_(weight_param)
118 using DDPProblem::inputDim;
123 virtual int inputDim(
double t)
const override;
161 virtual StateDimVector
stateEq(
double t,
const StateDimVector & x,
const InputDimVector & u)
const override;
169 virtual double runningCost(
double t,
const StateDimVector & x,
const InputDimVector & u)
const override;
176 virtual double terminalCost(
double t,
const StateDimVector & x)
const override;
202 const StateDimVector & x,
203 const InputDimVector & u,
204 Eigen::Ref<StateStateDimMatrix> state_eq_deriv_x,
205 Eigen::Ref<StateInputDimMatrix> state_eq_deriv_u)
const override;
218 const StateDimVector &,
219 const InputDimVector &,
220 Eigen::Ref<StateStateDimMatrix>,
221 Eigen::Ref<StateInputDimMatrix>,
222 std::vector<StateStateDimMatrix> &,
223 std::vector<InputInputDimMatrix> &,
224 std::vector<StateInputDimMatrix> &
227 throw std::runtime_error(
"Second-order derivatives of state equation are not implemented.");
238 const StateDimVector & x,
239 const InputDimVector & u,
240 Eigen::Ref<StateDimVector> running_cost_deriv_x,
241 Eigen::Ref<InputDimVector> running_cost_deriv_u)
const override;
254 const StateDimVector & x,
255 const InputDimVector & u,
256 Eigen::Ref<StateDimVector> running_cost_deriv_x,
257 Eigen::Ref<InputDimVector> running_cost_deriv_u,
258 Eigen::Ref<StateStateDimMatrix> running_cost_deriv_xx,
259 Eigen::Ref<InputInputDimMatrix> running_cost_deriv_uu,
260 Eigen::Ref<StateInputDimMatrix> running_cost_deriv_xu)
const override;
268 const StateDimVector & x,
269 Eigen::Ref<StateDimVector> terminal_cost_deriv_x)
const override;
278 const StateDimVector & x,
279 Eigen::Ref<StateDimVector> terminal_cost_deriv_x,
280 Eigen::Ref<StateStateDimMatrix> terminal_cost_deriv_xx)
const override;
300 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
303 Eigen::Vector3d
pos = Eigen::Vector3d::Zero();
306 Eigen::Vector3d
vel = Eigen::Vector3d::Zero();
316 std::vector<DdpProblem::InputDimVector>
u_list = {};
325 InitialParam(
const DdpProblem::StateDimVector & state,
double mass);
330 DdpProblem::StateDimVector
toState(
double mass)
const;
334 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
342 DdpCentroidal(
double mass,
double horizon_dt,
int horizon_steps,
const WeightParam & weight_param = WeightParam());
351 Eigen::VectorXd
planOnce(
const std::function<MotionParam(
double)> & motion_param_func,
352 const std::function<RefData(
double)> & ref_data_func,
353 const InitialParam & initial_param,
354 double current_time);
361 std::shared_ptr<nmpc_ddp::DDPSolver<9, Eigen::Dynamic>>
ddp_solver_;
Eigen::Vector3d angular_momentum
Angular momentum [kg m^2/s].
WeightParam(const Eigen::Vector3d &_running_pos=Eigen::Vector3d::Constant(1.0), const Eigen::Vector3d &_running_linear_momentum=Eigen::Vector3d::Constant(0.0), const Eigen::Vector3d &_running_angular_momentum=Eigen::Vector3d::Constant(1.0), double _running_force=1e-6, const Eigen::Vector3d &_terminal_pos=Eigen::Vector3d::Constant(1.0), const Eigen::Vector3d &_terminal_linear_momentum=Eigen::Vector3d::Constant(0.0), const Eigen::Vector3d &_terminal_angular_momentum=Eigen::Vector3d::Constant(1.0))
Constructor.
std::shared_ptr< DdpProblem > ddp_problem_
DDP problem.
virtual double runningCost(double t, const StateDimVector &x, const InputDimVector &u) const override
Calculate running cost.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d pos
CoM position [m].
virtual StateDimVector stateEq(double t, const StateDimVector &x, const InputDimVector &u) const override
Calculate discrete state equation.
void setRefDataFunc(const std::function< RefData(double)> &ref_data_func)
Set function of reference data.
virtual void calcStateEqDeriv(double t, const StateDimVector &x, const InputDimVector &u, Eigen::Ref< StateStateDimMatrix > state_eq_deriv_x, Eigen::Ref< StateInputDimMatrix > state_eq_deriv_u) const override
Calculate first-order derivatives of discrete state equation.
Eigen::Vector3d terminal_pos
CoM position weight in terminal cost.
Eigen::Vector3d running_angular_momentum
Angular momentum weight in running cost.
Eigen::Vector3d running_linear_momentum
Linear momentum weight in running cost.
void setMotionParamFunc(const std::function< MotionParam(double)> &motion_param_func)
Set function of motion parameter.
virtual void calcStateEqDeriv(double, const StateDimVector &, const InputDimVector &, Eigen::Ref< StateStateDimMatrix >, Eigen::Ref< StateInputDimMatrix >, std::vector< StateStateDimMatrix > &, std::vector< InputInputDimMatrix > &, std::vector< StateInputDimMatrix > &) const override
Calculate first-order and second-order derivatives of discrete state equation.
Eigen::Vector3d running_pos
CoM position weight in running cost.
virtual double terminalCost(double t, const StateDimVector &x) const override
Calculate terminal cost.
Eigen::Vector3d terminal_angular_momentum
Angular momentum weight in terminal cost.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::vector< std::shared_ptr< ForceColl::Contact > > contact_list
Contact list.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DdpProblem(double horizon_dt, double mass, const WeightParam &weight_param)
Constructor.
double mass_
Robot mass [Kg].
InitialParam()
Constructor.
std::function< MotionParam(double)> motion_param_func_
Function of motion parameter.
DDP problem of centroidal model.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DdpCentroidal(double mass, double horizon_dt, int horizon_steps, const WeightParam &weight_param=WeightParam())
Constructor.
Eigen::Vector3d vel
CoM velocity [m/s].
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d pos
CoM position [m].
virtual void calcRunningCostDeriv(double t, const StateDimVector &x, const InputDimVector &u, Eigen::Ref< StateDimVector > running_cost_deriv_x, Eigen::Ref< InputDimVector > running_cost_deriv_u) const override
Calculate first-order derivatives of running cost.
Differential dynamic programming (DDP) for centroidal model.
double running_force
Force weight in running cost.
std::array< double, 2 > force_scale_limits_
Force scale limits (i.e., limits of in the order of lower, upper)
std::shared_ptr< nmpc_ddp::DDPSolver< 9, Eigen::Dynamic > > ddp_solver_
DDP solver.
virtual int inputDim(double t) const override
Gets the input dimension.
virtual void calcTerminalCostDeriv(double t, const StateDimVector &x, Eigen::Ref< StateDimVector > terminal_cost_deriv_x) const override
Calculate first-order derivatives of terminal cost.
Eigen::Vector3d terminal_linear_momentum
Linear momentum weight in terminal cost.
std::vector< DdpProblem::InputDimVector > u_list
Initial guess of input sequence.
DdpProblem::StateDimVector toState(double mass) const
Get state of DDP problem.
Eigen::VectorXd planOnce(const std::function< MotionParam(double)> &motion_param_func, const std::function< RefData(double)> &ref_data_func, const InitialParam &initial_param, double current_time)
Plan one step.
std::function< RefData(double)> ref_data_func_
Function of reference data.
WeightParam weight_param_
Weight parameter.