9 #ifndef CROCODDYL_CORE_ACTUATION_SQUASHING_HPP_
10 #define CROCODDYL_CORE_ACTUATION_SQUASHING_HPP_
12 #include "crocoddyl/core/actuation-base.hpp"
13 #include "crocoddyl/core/actuation/squashing-base.hpp"
14 #include "crocoddyl/core/fwd.hpp"
18 template <
typename _Scalar>
21 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
23 typedef _Scalar Scalar;
30 typedef typename MathBase::VectorXs VectorXs;
31 typedef typename MathBase::MatrixXs MatrixXs;
34 boost::shared_ptr<ActuationModelAbstract> actuation,
35 boost::shared_ptr<SquashingModelAbstract> squashing,
const std::size_t nu)
36 :
Base(actuation->get_state(), nu),
37 squashing_(squashing),
38 actuation_(actuation) {};
42 virtual void calc(
const boost::shared_ptr<ActuationDataAbstract>& data,
43 const Eigen::Ref<const VectorXs>& x,
44 const Eigen::Ref<const VectorXs>& u) {
45 Data* d =
static_cast<Data*
>(data.get());
47 squashing_->calc(d->squashing, u);
48 actuation_->calc(d->actuation, x, d->squashing->u);
49 data->tau = d->actuation->tau;
50 data->tau_set = d->actuation->tau_set;
53 virtual void calcDiff(
const boost::shared_ptr<ActuationDataAbstract>& data,
54 const Eigen::Ref<const VectorXs>& x,
55 const Eigen::Ref<const VectorXs>& u) {
56 Data* d =
static_cast<Data*
>(data.get());
58 squashing_->calcDiff(d->squashing, u);
59 actuation_->calcDiff(d->actuation, x, d->squashing->u);
60 data->dtau_du.noalias() = d->actuation->dtau_du * d->squashing->du_ds;
63 virtual void commands(
const boost::shared_ptr<ActuationDataAbstract>& data,
64 const Eigen::Ref<const VectorXs>& x,
65 const Eigen::Ref<const VectorXs>& tau) {
66 if (
static_cast<std::size_t
>(tau.size()) != this->state_->get_nv()) {
67 throw_pretty(
"Invalid argument: "
68 <<
"tau has wrong dimension (it should be " +
69 std::to_string(this->
state_->get_nv()) +
")");
72 data->u.noalias() = data->Mtau * tau;
76 return boost::allocate_shared<Data>(Eigen::aligned_allocator<Data>(),
this);
79 const boost::shared_ptr<SquashingModelAbstract>& get_squashing()
const {
82 const boost::shared_ptr<ActuationModelAbstract>& get_actuation()
const {
87 boost::shared_ptr<SquashingModelAbstract> squashing_;
88 boost::shared_ptr<ActuationModelAbstract> actuation_;
91 template <
typename _Scalar>
93 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
95 typedef _Scalar Scalar;
99 typedef typename MathBase::VectorXs VectorXs;
100 typedef typename MathBase::MatrixXs MatrixXs;
102 template <
template <
typename Scalar>
class Model>
105 squashing(model->get_squashing()->createData()),
106 actuation(model->get_actuation()->createData()) {}
110 boost::shared_ptr<SquashingDataAbstract> squashing;
111 boost::shared_ptr<ActuationDataAbstract> actuation;
Abstract class for the actuation-mapping model.
boost::shared_ptr< StateAbstract > state_
Model of the state.
virtual void torqueTransform(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the torque transform from generalized torques to joint torque inputs.
boost::shared_ptr< ActuationDataAbstract > createData()
Create the actuation data.
virtual void calcDiff(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the Jacobians of the actuation function.
virtual void calc(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u)
Compute the actuation signal from the state point and joint torque inputs .
virtual void commands(const boost::shared_ptr< ActuationDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &tau)
Compute the joint torque input from the generalized torques.
std::vector< bool > tau_set
True for joints that are actuacted.
VectorXs tau
Generalized torques.