Directory: | ./ |
---|---|
File: | include/crocoddyl/core/actuation-base.hxx |
Date: | 2025-03-26 19:23:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 19 | 26 | 73.1% |
Branches: | 4 | 44 | 9.1% |
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 | #include <boost/core/demangle.hpp> | ||
11 | |||
12 | namespace crocoddyl { | ||
13 | |||
14 | template <typename Scalar> | ||
15 | 4354 | ActuationModelAbstractTpl<Scalar>::ActuationModelAbstractTpl( | |
16 | std::shared_ptr<StateAbstract> state, const std::size_t nu) | ||
17 | 4354 | : nu_(nu), state_(state) {} | |
18 | |||
19 | template <typename Scalar> | ||
20 | std::shared_ptr<ActuationDataAbstractTpl<Scalar> > | ||
21 | 12 | ActuationModelAbstractTpl<Scalar>::createData() { | |
22 | return std::allocate_shared<ActuationDataAbstract>( | ||
23 |
1/2✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
24 | Eigen::aligned_allocator<ActuationDataAbstract>(), this); |
24 | } | ||
25 | |||
26 | template <typename Scalar> | ||
27 | 1882 | void ActuationModelAbstractTpl<Scalar>::calc( | |
28 | const std::shared_ptr<ActuationDataAbstract>&, | ||
29 | 1882 | const Eigen::Ref<const VectorXs>&) {} | |
30 | |||
31 | template <typename Scalar> | ||
32 | 414 | void ActuationModelAbstractTpl<Scalar>::calcDiff( | |
33 | const std::shared_ptr<ActuationDataAbstract>&, | ||
34 | 414 | const Eigen::Ref<const VectorXs>&) {} | |
35 | |||
36 | template <typename Scalar> | ||
37 | 6144 | void ActuationModelAbstractTpl<Scalar>::torqueTransform( | |
38 | const std::shared_ptr<ActuationDataAbstract>& data, | ||
39 | const Eigen::Ref<const VectorXs>& x, const Eigen::Ref<const VectorXs>& u) { | ||
40 |
1/2✗ Branch 3 not taken.
✓ Branch 4 taken 3072 times.
|
6144 | if (static_cast<std::size_t>(x.size()) != state_->get_nx()) { |
41 | ✗ | throw_pretty( | |
42 | "Invalid argument: " << "x has wrong dimension (it should be " + | ||
43 | std::to_string(state_->get_nx()) + ")"); | ||
44 | } | ||
45 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3072 times.
|
6144 | if (static_cast<std::size_t>(u.size()) != nu_) { |
46 | ✗ | throw_pretty( | |
47 | "Invalid argument: " << "u has wrong dimension (it should be " + | ||
48 | std::to_string(nu_) + ")"); | ||
49 | } | ||
50 | 6144 | calc(data, x, u); | |
51 | 6144 | calcDiff(data, x, u); | |
52 |
1/2✓ Branch 3 taken 3072 times.
✗ Branch 4 not taken.
|
6144 | data->Mtau = pseudoInverse(data->dtau_du); |
53 | 6144 | } | |
54 | |||
55 | template <typename Scalar> | ||
56 | 1312598 | std::size_t ActuationModelAbstractTpl<Scalar>::get_nu() const { | |
57 | 1312598 | return nu_; | |
58 | } | ||
59 | |||
60 | template <typename Scalar> | ||
61 | const std::shared_ptr<StateAbstractTpl<Scalar> >& | ||
62 | 1264288 | ActuationModelAbstractTpl<Scalar>::get_state() const { | |
63 | 1264288 | return state_; | |
64 | } | ||
65 | |||
66 | template <typename Scalar> | ||
67 | ✗ | std::ostream& operator<<(std::ostream& os, | |
68 | const ActuationModelAbstractTpl<Scalar>& model) { | ||
69 | ✗ | model.print(os); | |
70 | ✗ | return os; | |
71 | } | ||
72 | |||
73 | template <typename Scalar> | ||
74 | ✗ | void ActuationModelAbstractTpl<Scalar>::print(std::ostream& os) const { | |
75 | ✗ | os << boost::core::demangle(typeid(*this).name()); | |
76 | } | ||
77 | |||
78 | } // namespace crocoddyl | ||
79 |