10#ifndef CROCODDYL_MULTIBODY_ACTUATIONS_FULL_HPP_ 11#define CROCODDYL_MULTIBODY_ACTUATIONS_FULL_HPP_ 13#include "crocoddyl/core/actuation-base.hpp" 14#include "crocoddyl/core/state-base.hpp" 15#include "crocoddyl/multibody/fwd.hpp" 16#include "crocoddyl/multibody/states/multibody.hpp" 31template <
typename _Scalar>
34 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
37 typedef _Scalar Scalar;
42 typedef typename MathBase::VectorXs VectorXs;
43 typedef typename MathBase::MatrixXs MatrixXs;
51 : Base(state, state->get_nv()) {
68 virtual void calc(
const std::shared_ptr<Data>& data,
69 const Eigen::Ref<const VectorXs>& ,
70 const Eigen::Ref<const VectorXs>& u)
override {
71 if (
static_cast<std::size_t
>(u.size()) !=
nu_) {
73 "Invalid argument: " <<
"u has wrong dimension (it should be " +
74 std::to_string(
nu_) +
")");
87 virtual void calcDiff(
const std::shared_ptr<Data>& data,
88 const Eigen::Ref<const VectorXs>& ,
89 const Eigen::Ref<const VectorXs>&)
override {
91 virtual void calcDiff(
const std::shared_ptr<Data>&,
92 const Eigen::Ref<const VectorXs>& ,
93 const Eigen::Ref<const VectorXs>&)
override {
96 assert_pretty(data->dtau_dx.isZero(),
"dtau_dx has wrong value");
97 assert_pretty(MatrixXs(data->dtau_du)
98 .isApprox(MatrixXs::Identity(
state_->get_nv(),
nu_)),
99 "dtau_du has wrong value");
102 virtual void commands(
const std::shared_ptr<Data>& data,
103 const Eigen::Ref<const VectorXs>&,
104 const Eigen::Ref<const VectorXs>& tau)
override {
105 if (
static_cast<std::size_t
>(tau.size()) !=
nu_) {
107 "Invalid argument: " <<
"tau has wrong dimension (it should be " +
108 std::to_string(
nu_) +
")");
115 const Eigen::Ref<const VectorXs>&,
116 const Eigen::Ref<const VectorXs>&)
override {
119 const Eigen::Ref<const VectorXs>&,
120 const Eigen::Ref<const VectorXs>&)
override {
123 assert_pretty(MatrixXs(data->Mtau).isApprox(MatrixXs::Identity(
nu_,
nu_)),
124 "Mtau has wrong value");
134 std::shared_ptr<Data> data =
135 std::allocate_shared<Data>(Eigen::aligned_allocator<Data>(),
this);
136 data->dtau_du.diagonal().setOnes();
137 data->Mtau.setIdentity();
141 template <
typename NewScalar>
144 ReturnType ret(
state_->template cast<NewScalar>());
153 virtual void print(std::ostream& os)
const override {
154 os <<
"ActuationModelFull {nu=" <<
nu_ <<
", nv=" <<
state_->get_nv()
165CROCODDYL_DECLARE_EXTERN_TEMPLATE_CLASS(crocoddyl::ActuationModelFullTpl)
std::shared_ptr< StateAbstract > state_
ActuationModelAbstractTpl(std::shared_ptr< StateAbstract > state, const std::size_t nu)
Initialize the actuation model.
std::shared_ptr< StateAbstract > state_
virtual void calc(const std::shared_ptr< Data > &data, const Eigen::Ref< const VectorXs > &, const Eigen::Ref< const VectorXs > &u) override
Compute the full actuation.
virtual std::shared_ptr< Data > createData() override
Create the full actuation data.
virtual void commands(const std::shared_ptr< Data > &data, const Eigen::Ref< const VectorXs > &, const Eigen::Ref< const VectorXs > &tau) override
Compute the joint torque input from the generalized torques.
virtual void torqueTransform(const std::shared_ptr< Data > &data, const Eigen::Ref< const VectorXs > &, const Eigen::Ref< const VectorXs > &) override
Compute the torque transform from generalized torques to joint torque inputs.
ActuationModelFullTpl(std::shared_ptr< StateAbstract > state)
Initialize the full actuation model.
virtual void calcDiff(const std::shared_ptr< Data > &data, const Eigen::Ref< const VectorXs > &, const Eigen::Ref< const VectorXs > &) override
Compute the Jacobians of the full actuation model.
virtual void print(std::ostream &os) const override
Print relevant information of the joint-effort residual.
Abstract class for the state representation.
State multibody representation.
const std::shared_ptr< PinocchioModel > & get_pinocchio() const
Return the Pinocchio model (i.e., model of the rigid body system).