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"
30 template <
typename _Scalar>
33 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
36 typedef _Scalar Scalar;
41 typedef typename MathBase::VectorXs VectorXs;
42 typedef typename MathBase::MatrixXs MatrixXs;
50 :
Base(state, state->get_nv()) {};
60 virtual void calc(
const std::shared_ptr<Data>& data,
61 const Eigen::Ref<const VectorXs>& ,
62 const Eigen::Ref<const VectorXs>& u)
override {
63 if (
static_cast<std::size_t
>(u.size()) !=
nu_) {
65 "Invalid argument: " <<
"u has wrong dimension (it should be " +
66 std::to_string(
nu_) +
")");
79 virtual void calcDiff(
const std::shared_ptr<Data>& data,
80 const Eigen::Ref<const VectorXs>& ,
81 const Eigen::Ref<const VectorXs>&)
override {
83 virtual void calcDiff(
const std::shared_ptr<Data>&,
84 const Eigen::Ref<const VectorXs>& ,
85 const Eigen::Ref<const VectorXs>&)
override {
88 assert_pretty(data->dtau_dx.isZero(),
"dtau_dx has wrong value");
89 assert_pretty(MatrixXs(data->dtau_du)
90 .isApprox(MatrixXs::Identity(
state_->get_nv(),
nu_)),
91 "dtau_du has wrong value");
94 virtual void commands(
const std::shared_ptr<Data>& data,
95 const Eigen::Ref<const VectorXs>&,
96 const Eigen::Ref<const VectorXs>& tau)
override {
97 if (
static_cast<std::size_t
>(tau.size()) !=
nu_) {
99 "Invalid argument: " <<
"tau has wrong dimension (it should be " +
100 std::to_string(
nu_) +
")");
107 const Eigen::Ref<const VectorXs>&,
108 const Eigen::Ref<const VectorXs>&)
override {
111 const Eigen::Ref<const VectorXs>&,
112 const Eigen::Ref<const VectorXs>&)
override {
115 assert_pretty(MatrixXs(data->Mtau).isApprox(MatrixXs::Identity(
nu_,
nu_)),
116 "Mtau has wrong value");
126 std::shared_ptr<Data> data =
127 std::allocate_shared<Data>(Eigen::aligned_allocator<Data>(),
this);
128 data->dtau_du.diagonal().setOnes();
129 data->Mtau.setIdentity();
133 template <
typename NewScalar>
136 ReturnType ret(
state_->template cast<NewScalar>());
145 virtual void print(std::ostream& os)
const override {
146 os <<
"ActuationModelFull {nu=" <<
nu_ <<
", nv=" <<
state_->get_nv()
Abstract class for the actuation-mapping model.
std::shared_ptr< StateAbstract > state_
Model of the state.
std::size_t nu_
Dimension of joint torque inputs.
std::shared_ptr< StateAbstract > state_
Model of the 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.
std::size_t nu_
Dimension of joint torque inputs.
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.