GCC Code Coverage Report


Directory: ./
File: include/crocoddyl/core/data/joint.hpp
Date: 2025-05-13 10:30:51
Exec Total Coverage
Lines: 0 20 0.0%
Branches: 0 41 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2022, University of Edinburgh, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef CROCODDYL_CORE_DATA_JOINT_HPP_
10 #define CROCODDYL_CORE_DATA_JOINT_HPP_
11
12 #include "crocoddyl/core/data-collector-base.hpp"
13 #include "crocoddyl/core/data/actuation.hpp"
14 #include "crocoddyl/core/fwd.hpp"
15 #include "crocoddyl/core/state-base.hpp"
16
17 namespace crocoddyl {
18
19 template <typename _Scalar>
20 struct JointDataAbstractTpl {
21 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
22
23 typedef _Scalar Scalar;
24 typedef MathBaseTpl<Scalar> MathBase;
25 typedef StateAbstractTpl<Scalar> StateAbstract;
26 typedef ActuationModelAbstractTpl<Scalar> ActuationModelAbstract;
27 typedef typename MathBase::VectorXs VectorXs;
28 typedef typename MathBase::MatrixXs MatrixXs;
29
30 /**
31 * @brief Initialize a joint data structure containing generalized
32 * accelerations and joint efforts, and their derivatives.
33 *
34 * @param state State description
35 * @param actuation Actuation model
36 * @param nu Dimension of control input
37 */
38 JointDataAbstractTpl(std::shared_ptr<StateAbstract> state,
39 std::shared_ptr<ActuationModelAbstract> actuation,
40 const std::size_t nu)
41 : tau(actuation->get_nu()),
42 a(state->get_nv()),
43 dtau_dx(actuation->get_nu(), state->get_ndx()),
44 dtau_du(actuation->get_nu(), nu),
45 da_dx(state->get_nv(), state->get_ndx()),
46 da_du(state->get_nv(), nu) {
47 tau.setZero();
48 a.setZero();
49 dtau_dx.setZero();
50 dtau_du.setZero();
51 da_dx.setZero();
52 da_du.setZero();
53 }
54 virtual ~JointDataAbstractTpl() {}
55
56 VectorXs tau; //!< Joint efforts
57 VectorXs a; //!< Generalized joint acceleration
58 MatrixXs dtau_dx; //!< Partial derivatives of the joint efforts w.r.t. the
59 //!< state point
60 MatrixXs dtau_du; //!< Partial derivatives of the joint efforts w.r.t. the
61 //!< control input
62 MatrixXs da_dx; //!< Partial derivatives of the generalized joint
63 //!< accelerations w.r.t. the state point
64 MatrixXs da_du; //!< Partial derivatives of the generalized joint
65 //!< accelerations w.r.t. the control input
66 };
67
68 template <typename Scalar>
69 struct DataCollectorJointTpl : virtual DataCollectorAbstractTpl<Scalar> {
70 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
71
72 DataCollectorJointTpl(std::shared_ptr<JointDataAbstractTpl<Scalar> > joint)
73 : DataCollectorAbstractTpl<Scalar>(), joint(joint) {}
74 virtual ~DataCollectorJointTpl() {}
75
76 std::shared_ptr<JointDataAbstractTpl<Scalar> > joint;
77 };
78
79 template <typename Scalar>
80 struct DataCollectorJointActuationTpl : DataCollectorActuationTpl<Scalar> {
81 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
82
83 /**
84 * @brief Initialize the joint-actuation data collector
85 *
86 * @param[in] actuation Actuation data
87 * @param[in] joint Joint data
88 */
89 DataCollectorJointActuationTpl(
90 std::shared_ptr<ActuationDataAbstractTpl<Scalar> > actuation,
91 std::shared_ptr<JointDataAbstractTpl<Scalar> > joint)
92 : DataCollectorActuationTpl<Scalar>(actuation), joint(joint) {}
93 virtual ~DataCollectorJointActuationTpl() {}
94
95 std::shared_ptr<JointDataAbstractTpl<Scalar> > joint;
96 };
97
98 } // namespace crocoddyl
99
100 CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(crocoddyl::JointDataAbstractTpl)
101 CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(crocoddyl::DataCollectorJointTpl)
102 CROCODDYL_DECLARE_EXTERN_TEMPLATE_STRUCT(
103 crocoddyl::DataCollectorJointActuationTpl)
104
105 #endif // CROCODDYL_CORE_DATA_JOINT_HPP_
106