| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /////////////////////////////////////////////////////////////////////////////// | ||
| 2 | // BSD 3-Clause License | ||
| 3 | // | ||
| 4 | // Copyright (C) 2019-2025, LAAS-CNRS, University of Edinburgh, | ||
| 5 | // Heriot-Watt University | ||
| 6 | // Copyright note valid unless otherwise stated in individual files. | ||
| 7 | // All rights reserved. | ||
| 8 | /////////////////////////////////////////////////////////////////////////////// | ||
| 9 | |||
| 10 | namespace crocoddyl { | ||
| 11 | |||
| 12 | template <typename Scalar> | ||
| 13 | ✗ | ActuationModelAbstractTpl<Scalar>::ActuationModelAbstractTpl( | |
| 14 | std::shared_ptr<StateAbstract> state, const std::size_t nu) | ||
| 15 | ✗ | : nu_(nu), state_(state) {} | |
| 16 | |||
| 17 | template <typename Scalar> | ||
| 18 | std::shared_ptr<ActuationDataAbstractTpl<Scalar> > | ||
| 19 | ✗ | ActuationModelAbstractTpl<Scalar>::createData() { | |
| 20 | return std::allocate_shared<ActuationDataAbstract>( | ||
| 21 | ✗ | Eigen::aligned_allocator<ActuationDataAbstract>(), this); | |
| 22 | } | ||
| 23 | |||
| 24 | template <typename Scalar> | ||
| 25 | ✗ | void ActuationModelAbstractTpl<Scalar>::calc( | |
| 26 | const std::shared_ptr<ActuationDataAbstract>&, | ||
| 27 | ✗ | const Eigen::Ref<const VectorXs>&) {} | |
| 28 | |||
| 29 | template <typename Scalar> | ||
| 30 | ✗ | void ActuationModelAbstractTpl<Scalar>::calcDiff( | |
| 31 | const std::shared_ptr<ActuationDataAbstract>&, | ||
| 32 | ✗ | const Eigen::Ref<const VectorXs>&) {} | |
| 33 | |||
| 34 | template <typename Scalar> | ||
| 35 | ✗ | void ActuationModelAbstractTpl<Scalar>::torqueTransform( | |
| 36 | const std::shared_ptr<ActuationDataAbstract>& data, | ||
| 37 | const Eigen::Ref<const VectorXs>& x, const Eigen::Ref<const VectorXs>& u) { | ||
| 38 | ✗ | if (static_cast<std::size_t>(x.size()) != state_->get_nx()) { | |
| 39 | ✗ | throw_pretty( | |
| 40 | "Invalid argument: " << "x has wrong dimension (it should be " + | ||
| 41 | std::to_string(state_->get_nx()) + ")"); | ||
| 42 | } | ||
| 43 | ✗ | if (static_cast<std::size_t>(u.size()) != nu_) { | |
| 44 | ✗ | throw_pretty( | |
| 45 | "Invalid argument: " << "u has wrong dimension (it should be " + | ||
| 46 | std::to_string(nu_) + ")"); | ||
| 47 | } | ||
| 48 | ✗ | calc(data, x, u); | |
| 49 | ✗ | calcDiff(data, x, u); | |
| 50 | ✗ | data->Mtau = pseudoInverse(data->dtau_du); | |
| 51 | ✗ | } | |
| 52 | |||
| 53 | template <typename Scalar> | ||
| 54 | ✗ | std::size_t ActuationModelAbstractTpl<Scalar>::get_nu() const { | |
| 55 | ✗ | return nu_; | |
| 56 | } | ||
| 57 | |||
| 58 | template <typename Scalar> | ||
| 59 | const std::shared_ptr<StateAbstractTpl<Scalar> >& | ||
| 60 | ✗ | ActuationModelAbstractTpl<Scalar>::get_state() const { | |
| 61 | ✗ | return state_; | |
| 62 | } | ||
| 63 | |||
| 64 | template <typename Scalar> | ||
| 65 | ✗ | std::ostream& operator<<(std::ostream& os, | |
| 66 | const ActuationModelAbstractTpl<Scalar>& model) { | ||
| 67 | ✗ | model.print(os); | |
| 68 | ✗ | return os; | |
| 69 | } | ||
| 70 | |||
| 71 | template <typename Scalar> | ||
| 72 | ✗ | void ActuationModelAbstractTpl<Scalar>::print(std::ostream& os) const { | |
| 73 | ✗ | os << boost::core::demangle(typeid(*this).name()); | |
| 74 | ✗ | } | |
| 75 | |||
| 76 | } // namespace crocoddyl | ||
| 77 |