GCC Code Coverage Report


Directory: ./
File: include/crocoddyl/core/actuation-base.hxx
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 20 27 74.1%
Branches: 4 42 9.5%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2024, 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 #include "crocoddyl/core/utils/math.hpp"
13
14 namespace crocoddyl {
15
16 template <typename Scalar>
17 2131 ActuationModelAbstractTpl<Scalar>::ActuationModelAbstractTpl(
18 boost::shared_ptr<StateAbstract> state, const std::size_t nu)
19 2131 : nu_(nu), state_(state) {}
20
21 template <typename Scalar>
22 4278 ActuationModelAbstractTpl<Scalar>::~ActuationModelAbstractTpl() {}
23
24 template <typename Scalar>
25 boost::shared_ptr<ActuationDataAbstractTpl<Scalar> >
26 6 ActuationModelAbstractTpl<Scalar>::createData() {
27 return boost::allocate_shared<ActuationDataAbstract>(
28
1/2
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 Eigen::aligned_allocator<ActuationDataAbstract>(), this);
29 }
30
31 template <typename Scalar>
32 941 void ActuationModelAbstractTpl<Scalar>::calc(
33 const boost::shared_ptr<ActuationDataAbstract>&,
34 941 const Eigen::Ref<const VectorXs>&) {}
35
36 template <typename Scalar>
37 207 void ActuationModelAbstractTpl<Scalar>::calcDiff(
38 const boost::shared_ptr<ActuationDataAbstract>&,
39 207 const Eigen::Ref<const VectorXs>&) {}
40
41 template <typename Scalar>
42 3062 void ActuationModelAbstractTpl<Scalar>::torqueTransform(
43 const boost::shared_ptr<ActuationDataAbstract>& data,
44 const Eigen::Ref<const VectorXs>& x, const Eigen::Ref<const VectorXs>& u) {
45
1/2
✗ Branch 3 not taken.
✓ Branch 4 taken 3062 times.
3062 if (static_cast<std::size_t>(x.size()) != state_->get_nx()) {
46 throw_pretty(
47 "Invalid argument: " << "x has wrong dimension (it should be " +
48 std::to_string(state_->get_nx()) + ")");
49 }
50
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3062 times.
3062 if (static_cast<std::size_t>(u.size()) != nu_) {
51 throw_pretty(
52 "Invalid argument: " << "u has wrong dimension (it should be " +
53 std::to_string(nu_) + ")");
54 }
55 3062 calc(data, x, u);
56 3062 calcDiff(data, x, u);
57
1/2
✓ Branch 3 taken 3062 times.
✗ Branch 4 not taken.
3062 data->Mtau = pseudoInverse(data->dtau_du);
58 3062 }
59
60 template <typename Scalar>
61 657817 std::size_t ActuationModelAbstractTpl<Scalar>::get_nu() const {
62 657817 return nu_;
63 }
64
65 template <typename Scalar>
66 const boost::shared_ptr<StateAbstractTpl<Scalar> >&
67 633850 ActuationModelAbstractTpl<Scalar>::get_state() const {
68 633850 return state_;
69 }
70
71 template <typename Scalar>
72 std::ostream& operator<<(std::ostream& os,
73 const ActuationModelAbstractTpl<Scalar>& model) {
74 model.print(os);
75 return os;
76 }
77
78 template <typename Scalar>
79 void ActuationModelAbstractTpl<Scalar>::print(std::ostream& os) const {
80 os << boost::core::demangle(typeid(*this).name());
81 }
82
83 } // namespace crocoddyl
84