centroidal_control_collection
|
Go to the documentation of this file.
5 #include <nmpc_ddp/DDPSolver.h>
27 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
39 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42 Eigen::Vector3d
pos = Eigen::Vector3d::Zero();
45 Eigen::Vector3d
ori = Eigen::Vector3d::Zero();
89 WeightParam(
const Eigen::Vector3d & _running_pos = Eigen::Vector3d::Constant(1.0),
90 const Eigen::Vector3d & _running_ori = Eigen::Vector3d::Constant(1.0),
91 const Eigen::Vector3d & _running_linear_vel = Eigen::Vector3d::Constant(0.01),
92 const Eigen::Vector3d & _running_angular_vel = Eigen::Vector3d::Constant(0.01),
93 double _running_force = 1e-6,
94 const Eigen::Vector3d & _terminal_pos = Eigen::Vector3d::Constant(1.0),
95 const Eigen::Vector3d & _terminal_ori = Eigen::Vector3d::Constant(1.0),
96 const Eigen::Vector3d & _terminal_linear_vel = Eigen::Vector3d::Constant(0.01),
97 const Eigen::Vector3d & _terminal_angular_vel = Eigen::Vector3d::Constant(0.01))
110 class DdpProblem :
public nmpc_ddp::DDPProblem<12, Eigen::Dynamic>
113 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
121 : nmpc_ddp::DDPProblem<12, Eigen::Dynamic>(horizon_dt),
mass_(mass),
weight_param_(weight_param)
141 using DDPProblem::inputDim;
146 virtual int inputDim(
double t)
const override;
189 virtual StateDimVector
stateEq(
double t,
const StateDimVector & x,
const InputDimVector & u)
const override;
197 virtual double runningCost(
double t,
const StateDimVector & x,
const InputDimVector & u)
const override;
204 virtual double terminalCost(
double t,
const StateDimVector & x)
const override;
239 const StateDimVector & x,
240 const InputDimVector & u,
241 Eigen::Ref<StateStateDimMatrix> state_eq_deriv_x,
242 Eigen::Ref<StateInputDimMatrix> state_eq_deriv_u)
const override;
255 const StateDimVector &,
256 const InputDimVector &,
257 Eigen::Ref<StateStateDimMatrix>,
258 Eigen::Ref<StateInputDimMatrix>,
259 std::vector<StateStateDimMatrix> &,
260 std::vector<InputInputDimMatrix> &,
261 std::vector<StateInputDimMatrix> &
264 throw std::runtime_error(
"Second-order derivatives of state equation are not implemented.");
275 const StateDimVector & x,
276 const InputDimVector & u,
277 Eigen::Ref<StateDimVector> running_cost_deriv_x,
278 Eigen::Ref<InputDimVector> running_cost_deriv_u)
const override;
291 const StateDimVector & x,
292 const InputDimVector & u,
293 Eigen::Ref<StateDimVector> running_cost_deriv_x,
294 Eigen::Ref<InputDimVector> running_cost_deriv_u,
295 Eigen::Ref<StateStateDimMatrix> running_cost_deriv_xx,
296 Eigen::Ref<InputInputDimMatrix> running_cost_deriv_uu,
297 Eigen::Ref<StateInputDimMatrix> running_cost_deriv_xu)
const override;
305 const StateDimVector & x,
306 Eigen::Ref<StateDimVector> terminal_cost_deriv_x)
const override;
315 const StateDimVector & x,
316 Eigen::Ref<StateDimVector> terminal_cost_deriv_x,
317 Eigen::Ref<StateStateDimMatrix> terminal_cost_deriv_xx)
const override;
337 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
340 Eigen::Vector3d
pos = Eigen::Vector3d::Zero();
343 Eigen::Vector3d
ori = Eigen::Vector3d::Zero();
356 std::vector<DdpProblem::InputDimVector>
u_list = {};
367 DdpProblem::StateDimVector
toState()
const;
371 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
382 const WeightParam & weight_param = WeightParam());
391 Eigen::VectorXd
planOnce(
const std::function<MotionParam(
double)> & motion_param_func,
392 const std::function<RefData(
double)> & ref_data_func,
393 const InitialParam & initial_param,
394 double current_time);
401 std::shared_ptr<nmpc_ddp::DDPSolver<12, Eigen::Dynamic>>
ddp_solver_;
Differential dynamic programming (DDP) for centroidal model with single rigid-body dynamics (SRBD) ap...
Eigen::Vector3d terminal_pos
CoM position weight in terminal cost.
Eigen::Vector3d ori
Base link orientation [rad].
std::shared_ptr< DdpProblem > ddp_problem_
DDP problem.
Eigen::Vector3d linear_vel
Linear velocity [m/s].
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::vector< std::shared_ptr< ForceColl::Contact > > contact_list
Contact list.
std::array< double, 2 > force_scale_limits_
Force scale limits (i.e., limits of in the order of lower, upper)
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_ori
Base link orientation weight in terminal cost.
Eigen::Vector3d angular_vel
Angular velocity [rad/s].
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.
Eigen::Vector3d running_linear_vel
Linear velocity weight in running cost.
Eigen::Matrix3d inertia_mat
Inertia matrix [kg m^2].
WeightParam weight_param_
Weight parameter.
double running_force
Force weight in running cost.
virtual int inputDim(double t) const override
Gets the input dimension.
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.
void setMotionParamFunc(const std::function< MotionParam(double)> &motion_param_func)
Set function of motion parameter.
Eigen::Vector3d terminal_angular_vel
Angular velocity weight in terminal cost.
DdpProblem::StateDimVector toState() const
Get state of DDP problem.
virtual StateDimVector stateEq(double t, const StateDimVector &x, const InputDimVector &u) const override
Calculate discrete state equation.
virtual double terminalCost(double t, const StateDimVector &x) const override
Calculate terminal cost.
WeightParam(const Eigen::Vector3d &_running_pos=Eigen::Vector3d::Constant(1.0), const Eigen::Vector3d &_running_ori=Eigen::Vector3d::Constant(1.0), const Eigen::Vector3d &_running_linear_vel=Eigen::Vector3d::Constant(0.01), const Eigen::Vector3d &_running_angular_vel=Eigen::Vector3d::Constant(0.01), double _running_force=1e-6, const Eigen::Vector3d &_terminal_pos=Eigen::Vector3d::Constant(1.0), const Eigen::Vector3d &_terminal_ori=Eigen::Vector3d::Constant(1.0), const Eigen::Vector3d &_terminal_linear_vel=Eigen::Vector3d::Constant(0.01), const Eigen::Vector3d &_terminal_angular_vel=Eigen::Vector3d::Constant(0.01))
Constructor.
std::vector< DdpProblem::InputDimVector > u_list
Initial guess of input sequence.
std::function< RefData(double)> ref_data_func_
Function of reference data.
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.
std::function< MotionParam(double)> motion_param_func_
Function of motion parameter.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DdpSingleRigidBody(double mass, double horizon_dt, int horizon_steps, const WeightParam &weight_param=WeightParam())
Constructor.
DDP problem of centroidal model with single rigid-body dynamics (SRBD) approximation.
Eigen::Vector3d running_angular_vel
Angular velocity weight in running cost.
Eigen::Vector3d ori
Base link orientation [rad].
double mass_
Robot mass [Kg].
InitialParam()
Constructor.
std::shared_ptr< nmpc_ddp::DDPSolver< 12, Eigen::Dynamic > > ddp_solver_
DDP solver.
void setRefDataFunc(const std::function< RefData(double)> &ref_data_func)
Set function of reference data.
Eigen::Vector3d running_ori
Base link orientation weight in running cost.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d pos
CoM position [m].
EIGEN_MAKE_ALIGNED_OPERATOR_NEW DdpProblem(double horizon_dt, double mass, const WeightParam &weight_param)
Constructor.
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 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_vel
Linear velocity weight in terminal cost.
Eigen::Vector3d running_pos
CoM position weight in running cost.