10 #ifndef CROCODDYL_MULTIBODY_ACTIONS_CONTACT_FWDDYN_HPP_
11 #define CROCODDYL_MULTIBODY_ACTIONS_CONTACT_FWDDYN_HPP_
15 #include "crocoddyl/core/actuation-base.hpp"
16 #include "crocoddyl/core/constraints/constraint-manager.hpp"
17 #include "crocoddyl/core/costs/cost-sum.hpp"
18 #include "crocoddyl/core/diff-action-base.hpp"
19 #include "crocoddyl/multibody/contacts/multiple-contacts.hpp"
20 #include "crocoddyl/multibody/data/contacts.hpp"
21 #include "crocoddyl/multibody/fwd.hpp"
22 #include "crocoddyl/multibody/states/multibody.hpp"
73 template <
typename _Scalar>
77 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
79 typedef _Scalar Scalar;
90 typedef typename MathBase::VectorXs VectorXs;
91 typedef typename MathBase::MatrixXs MatrixXs;
110 std::shared_ptr<StateMultibody> state,
111 std::shared_ptr<ActuationModelAbstract> actuation,
112 std::shared_ptr<ContactModelMultiple> contacts,
113 std::shared_ptr<CostModelSum> costs,
114 const Scalar JMinvJt_damping = Scalar(0.),
115 const bool enable_force =
false);
135 std::shared_ptr<StateMultibody> state,
136 std::shared_ptr<ActuationModelAbstract> actuation,
137 std::shared_ptr<ContactModelMultiple> contacts,
138 std::shared_ptr<CostModelSum> costs,
139 std::shared_ptr<ConstraintModelManager> constraints,
140 const Scalar JMinvJt_damping = Scalar(0.),
141 const bool enable_force =
false);
153 virtual void calc(
const std::shared_ptr<DifferentialActionDataAbstract>& data,
154 const Eigen::Ref<const VectorXs>& x,
155 const Eigen::Ref<const VectorXs>& u);
169 virtual void calc(
const std::shared_ptr<DifferentialActionDataAbstract>& data,
170 const Eigen::Ref<const VectorXs>& x);
180 const std::shared_ptr<DifferentialActionDataAbstract>& data,
181 const Eigen::Ref<const VectorXs>& x,
const Eigen::Ref<const VectorXs>& u);
195 const std::shared_ptr<DifferentialActionDataAbstract>& data,
196 const Eigen::Ref<const VectorXs>& x);
203 virtual std::shared_ptr<DifferentialActionDataAbstract>
createData();
210 const std::shared_ptr<DifferentialActionDataAbstract>& data);
216 const std::shared_ptr<DifferentialActionDataAbstract>& data,
217 Eigen::Ref<VectorXs> u,
const Eigen::Ref<const VectorXs>& x,
218 const std::size_t maxiter = 100,
const Scalar tol = Scalar(1e-9));
300 virtual void print(std::ostream& os)
const;
310 std::shared_ptr<ActuationModelAbstract> actuation_;
311 std::shared_ptr<ContactModelMultiple> contacts_;
312 std::shared_ptr<CostModelSum> costs_;
313 std::shared_ptr<ConstraintModelManager> constraints_;
314 pinocchio::ModelTpl<Scalar>& pinocchio_;
317 Scalar JMinvJt_damping_;
323 template <
typename _Scalar>
326 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
327 typedef _Scalar Scalar;
333 typedef typename MathBase::VectorXs VectorXs;
334 typedef typename MathBase::MatrixXs MatrixXs;
336 template <
template <
typename Scalar>
class Model>
338 Model<Scalar>*
const model)
340 pinocchio(pinocchio::DataTpl<Scalar>(model->get_pinocchio())),
342 &pinocchio, model->get_actuation()->createData(),
343 std::make_shared<JointDataAbstract>(
344 model->get_state(), model->get_actuation(), model->get_nu()),
345 model->get_contacts()->createData(&pinocchio)),
346 costs(model->get_costs()->createData(&multibody)),
347 Kinv(model->get_state()->get_nv() +
348 model->get_contacts()->get_nc_total(),
349 model->get_state()->get_nv() +
350 model->get_contacts()->get_nc_total()),
351 df_dx(model->get_contacts()->get_nc_total(),
352 model->get_state()->get_ndx()),
353 df_du(model->get_contacts()->get_nc_total(), model->get_nu()),
354 tmp_xstatic(model->get_state()->get_nx()),
355 tmp_Jstatic(model->get_state()->get_nv(),
356 model->get_nu() + model->get_contacts()->get_nc_total()) {
357 multibody.joint->dtau_du.diagonal().setOnes();
358 costs->shareMemory(
this);
359 if (model->get_constraints() !=
nullptr) {
360 constraints = model->get_constraints()->createData(&multibody);
361 constraints->shareMemory(
this);
366 tmp_xstatic.setZero();
367 tmp_Jstatic.setZero();
368 pinocchio.lambda_c.resize(model->get_contacts()->get_nc_total());
369 pinocchio.lambda_c.setZero();
372 pinocchio::DataTpl<Scalar> pinocchio;
374 std::shared_ptr<CostDataSumTpl<Scalar> > costs;
375 std::shared_ptr<ConstraintDataManagerTpl<Scalar> > constraints;
379 VectorXs tmp_xstatic;
380 MatrixXs tmp_Jstatic;
399 #include <crocoddyl/multibody/actions/contact-fwddyn.hxx>
Abstract class for the actuation-mapping model.
Abstract class for differential action model.
std::shared_ptr< StateAbstract > state_
Model of the state.
VectorXs g_ub_
Lower bound of the inequality constraints.
std::size_t nu_
Control dimension.
VectorXs g_lb_
Lower bound of the inequality constraints.
State multibody representation.
MatrixXs Fx
Jacobian of the dynamics w.r.t. the state .
MatrixXs Fu
Jacobian of the dynamics w.r.t. the control .
MatrixXs Luu
Hessian of the cost w.r.t. the control .
VectorXs Lx
Jacobian of the cost w.r.t. the state .
MatrixXs Lxx
Hessian of the cost w.r.t. the state .
VectorXs Lu
Jacobian of the cost w.r.t. the control .
VectorXs xout
evolution state