Directory: | ./ |
---|---|
File: | include/crocoddyl/core/data/joint.hpp |
Date: | 2025-02-24 23:41:29 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 18 | 21 | 85.7% |
Branches: | 12 | 24 | 50.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 <memory> | ||
13 | |||
14 | #include "crocoddyl/core/data-collector-base.hpp" | ||
15 | #include "crocoddyl/core/data/actuation.hpp" | ||
16 | #include "crocoddyl/core/fwd.hpp" | ||
17 | #include "crocoddyl/core/state-base.hpp" | ||
18 | |||
19 | namespace crocoddyl { | ||
20 | |||
21 | template <typename _Scalar> | ||
22 | struct JointDataAbstractTpl { | ||
23 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
24 | |||
25 | typedef _Scalar Scalar; | ||
26 | typedef MathBaseTpl<Scalar> MathBase; | ||
27 | typedef StateAbstractTpl<Scalar> StateAbstract; | ||
28 | typedef ActuationModelAbstractTpl<Scalar> ActuationModelAbstract; | ||
29 | typedef typename MathBase::VectorXs VectorXs; | ||
30 | typedef typename MathBase::MatrixXs MatrixXs; | ||
31 | |||
32 | /** | ||
33 | * @brief Initialize a joint data structure containing generalized | ||
34 | * accelerations and joint efforts, and their derivatives. | ||
35 | * | ||
36 | * @param state State description | ||
37 | * @param actuation Actuation model | ||
38 | * @param nu Dimension of control input | ||
39 | */ | ||
40 | 91317 | JointDataAbstractTpl(std::shared_ptr<StateAbstract> state, | |
41 | std::shared_ptr<ActuationModelAbstract> actuation, | ||
42 | const std::size_t nu) | ||
43 |
1/2✓ Branch 2 taken 91317 times.
✗ Branch 3 not taken.
|
91317 | : tau(actuation->get_nu()), |
44 |
1/2✓ Branch 3 taken 91317 times.
✗ Branch 4 not taken.
|
91317 | a(state->get_nv()), |
45 |
1/2✓ Branch 5 taken 91317 times.
✗ Branch 6 not taken.
|
91317 | dtau_dx(actuation->get_nu(), state->get_ndx()), |
46 |
1/2✓ Branch 3 taken 91317 times.
✗ Branch 4 not taken.
|
91317 | dtau_du(actuation->get_nu(), nu), |
47 |
1/2✓ Branch 5 taken 91317 times.
✗ Branch 6 not taken.
|
91317 | da_dx(state->get_nv(), state->get_ndx()), |
48 |
1/2✓ Branch 4 taken 91317 times.
✗ Branch 5 not taken.
|
182634 | da_du(state->get_nv(), nu) { |
49 |
1/2✓ Branch 1 taken 91317 times.
✗ Branch 2 not taken.
|
91317 | tau.setZero(); |
50 |
1/2✓ Branch 1 taken 91317 times.
✗ Branch 2 not taken.
|
91317 | a.setZero(); |
51 |
1/2✓ Branch 1 taken 91317 times.
✗ Branch 2 not taken.
|
91317 | dtau_dx.setZero(); |
52 |
1/2✓ Branch 1 taken 91317 times.
✗ Branch 2 not taken.
|
91317 | dtau_du.setZero(); |
53 |
1/2✓ Branch 1 taken 91317 times.
✗ Branch 2 not taken.
|
91317 | da_dx.setZero(); |
54 |
1/2✓ Branch 1 taken 91317 times.
✗ Branch 2 not taken.
|
91317 | da_du.setZero(); |
55 | 91317 | } | |
56 | 182614 | virtual ~JointDataAbstractTpl() {} | |
57 | |||
58 | VectorXs tau; //!< Joint efforts | ||
59 | VectorXs a; //!< Generalized joint acceleration | ||
60 | MatrixXs dtau_dx; //!< Partial derivatives of the joint efforts w.r.t. the | ||
61 | //!< state point | ||
62 | MatrixXs dtau_du; //!< Partial derivatives of the joint efforts w.r.t. the | ||
63 | //!< control input | ||
64 | MatrixXs da_dx; //!< Partial derivatives of the generalized joint | ||
65 | //!< accelerations w.r.t. the state point | ||
66 | MatrixXs da_du; //!< Partial derivatives of the generalized joint | ||
67 | //!< accelerations w.r.t. the control input | ||
68 | }; | ||
69 | |||
70 | template <typename Scalar> | ||
71 | struct DataCollectorJointTpl : virtual DataCollectorAbstractTpl<Scalar> { | ||
72 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
73 | |||
74 | 91321 | DataCollectorJointTpl(std::shared_ptr<JointDataAbstractTpl<Scalar> > joint) | |
75 | 91321 | : DataCollectorAbstractTpl<Scalar>(), joint(joint) {} | |
76 | 91329 | virtual ~DataCollectorJointTpl() {} | |
77 | |||
78 | std::shared_ptr<JointDataAbstractTpl<Scalar> > joint; | ||
79 | }; | ||
80 | |||
81 | template <typename Scalar> | ||
82 | struct DataCollectorJointActuationTpl : DataCollectorActuationTpl<Scalar> { | ||
83 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
84 | |||
85 | /** | ||
86 | * @brief Initialize the joint-actuation data collector | ||
87 | * | ||
88 | * @param[in] actuation Actuation data | ||
89 | * @param[in] joint Joint data | ||
90 | */ | ||
91 | ✗ | DataCollectorJointActuationTpl( | |
92 | std::shared_ptr<ActuationDataAbstractTpl<Scalar> > actuation, | ||
93 | std::shared_ptr<JointDataAbstractTpl<Scalar> > joint) | ||
94 | ✗ | : DataCollectorActuationTpl<Scalar>(actuation), joint(joint) {} | |
95 | ✗ | virtual ~DataCollectorJointActuationTpl() {} | |
96 | |||
97 | std::shared_ptr<JointDataAbstractTpl<Scalar> > joint; | ||
98 | }; | ||
99 | |||
100 | } // namespace crocoddyl | ||
101 | |||
102 | #endif // CROCODDYL_CORE_DATA_JOINT_HPP_ | ||
103 |