Directory: | ./ |
---|---|
File: | include/crocoddyl/multibody/impulses/impulse-6d.hpp |
Date: | 2025-01-16 08:47:40 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 24 | 24 | 100.0% |
Branches: | 27 | 54 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | ||
2 | // BSD 3-Clause License | ||
3 | // | ||
4 | // Copyright (C) 2019-2023, 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 | #ifndef CROCODDYL_MULTIBODY_IMPULSES_IMPULSE_6D_HPP_ | ||
11 | #define CROCODDYL_MULTIBODY_IMPULSES_IMPULSE_6D_HPP_ | ||
12 | |||
13 | #include <pinocchio/multibody/data.hpp> | ||
14 | #include <pinocchio/spatial/motion.hpp> | ||
15 | |||
16 | #include "crocoddyl/multibody/fwd.hpp" | ||
17 | #include "crocoddyl/multibody/impulse-base.hpp" | ||
18 | |||
19 | namespace crocoddyl { | ||
20 | |||
21 | template <typename _Scalar> | ||
22 | class ImpulseModel6DTpl : public ImpulseModelAbstractTpl<_Scalar> { | ||
23 | public: | ||
24 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
25 | |||
26 | typedef _Scalar Scalar; | ||
27 | typedef MathBaseTpl<Scalar> MathBase; | ||
28 | typedef ImpulseModelAbstractTpl<Scalar> Base; | ||
29 | typedef ImpulseData6DTpl<Scalar> Data; | ||
30 | typedef StateMultibodyTpl<Scalar> StateMultibody; | ||
31 | typedef ImpulseDataAbstractTpl<Scalar> ImpulseDataAbstract; | ||
32 | typedef typename MathBase::Vector2s Vector2s; | ||
33 | typedef typename MathBase::Vector3s Vector3s; | ||
34 | typedef typename MathBase::VectorXs VectorXs; | ||
35 | typedef typename MathBase::MatrixXs MatrixXs; | ||
36 | typedef typename MathBase::Matrix3s Matrix3s; | ||
37 | |||
38 | /** | ||
39 | * @brief Initialize the 6d impulse model | ||
40 | * | ||
41 | * @param[in] state State of the multibody system | ||
42 | * @param[in] id Reference frame id of the impulse | ||
43 | * @param[in] type Type of impulse (default LOCAL) | ||
44 | */ | ||
45 | ImpulseModel6DTpl( | ||
46 | boost::shared_ptr<StateMultibody> state, const pinocchio::FrameIndex id, | ||
47 | const pinocchio::ReferenceFrame type = pinocchio::ReferenceFrame::LOCAL); | ||
48 | virtual ~ImpulseModel6DTpl(); | ||
49 | |||
50 | /** | ||
51 | * @brief Compute the 3d impulse Jacobian | ||
52 | * | ||
53 | * @param[in] data 3d impulse data | ||
54 | * @param[in] x State point \f$\mathbf{x}\in\mathbb{R}^{ndx}\f$ | ||
55 | */ | ||
56 | virtual void calc(const boost::shared_ptr<ImpulseDataAbstract>& data, | ||
57 | const Eigen::Ref<const VectorXs>& x); | ||
58 | |||
59 | /** | ||
60 | * @brief Compute the derivatives of the 3d impulse holonomic constraint | ||
61 | * | ||
62 | * @param[in] data 3d impulse data | ||
63 | * @param[in] x State point \f$\mathbf{x}\in\mathbb{R}^{ndx}\f$ | ||
64 | */ | ||
65 | virtual void calcDiff(const boost::shared_ptr<ImpulseDataAbstract>& data, | ||
66 | const Eigen::Ref<const VectorXs>& x); | ||
67 | |||
68 | /** | ||
69 | * @brief Convert the force into a stack of spatial forces | ||
70 | * | ||
71 | * @param[in] data 3d impulse data | ||
72 | * @param[in] force 3d impulse | ||
73 | */ | ||
74 | virtual void updateForce(const boost::shared_ptr<ImpulseDataAbstract>& data, | ||
75 | const VectorXs& force); | ||
76 | |||
77 | /** | ||
78 | * @brief Create the 3d impulse data | ||
79 | */ | ||
80 | virtual boost::shared_ptr<ImpulseDataAbstract> createData( | ||
81 | pinocchio::DataTpl<Scalar>* const data); | ||
82 | |||
83 | /** | ||
84 | * @brief Print relevant information of the 6d impulse model | ||
85 | * | ||
86 | * @param[out] os Output stream object | ||
87 | */ | ||
88 | virtual void print(std::ostream& os) const; | ||
89 | |||
90 | protected: | ||
91 | using Base::id_; | ||
92 | using Base::state_; | ||
93 | using Base::type_; | ||
94 | }; | ||
95 | |||
96 | template <typename _Scalar> | ||
97 | struct ImpulseData6DTpl : public ImpulseDataAbstractTpl<_Scalar> { | ||
98 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
99 | typedef _Scalar Scalar; | ||
100 | typedef MathBaseTpl<Scalar> MathBase; | ||
101 | typedef ImpulseDataAbstractTpl<Scalar> Base; | ||
102 | typedef typename MathBase::Matrix3s Matrix3s; | ||
103 | typedef typename MathBase::Matrix6xs Matrix6xs; | ||
104 | typedef typename MathBase::MatrixXs MatrixXs; | ||
105 | typedef typename pinocchio::SE3Tpl<Scalar> SE3; | ||
106 | typedef typename pinocchio::MotionTpl<Scalar> Motion; | ||
107 | typedef typename pinocchio::ForceTpl<Scalar> Force; | ||
108 | |||
109 | template <template <typename Scalar> class Model> | ||
110 | 6948 | ImpulseData6DTpl(Model<Scalar>* const model, | |
111 | pinocchio::DataTpl<Scalar>* const data) | ||
112 | : Base(model, data), | ||
113 | 6948 | lwaMl(SE3::Identity()), | |
114 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | v0(Motion::Zero()), |
115 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | f_local(Force::Zero()), |
116 |
1/2✓ Branch 4 taken 6948 times.
✗ Branch 5 not taken.
|
6948 | dv0_local_dq(6, model->get_state()->get_nv()), |
117 |
1/2✓ Branch 4 taken 6948 times.
✗ Branch 5 not taken.
|
6948 | fJf(6, model->get_state()->get_nv()), |
118 |
1/2✓ Branch 4 taken 6948 times.
✗ Branch 5 not taken.
|
6948 | v_partial_dq(6, model->get_state()->get_nv()), |
119 |
1/2✓ Branch 4 taken 6948 times.
✗ Branch 5 not taken.
|
6948 | v_partial_dv(6, model->get_state()->get_nv()), |
120 |
8/16✓ Branch 2 taken 6948 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6948 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6948 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 6948 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 6948 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 6948 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 6948 times.
✗ Branch 21 not taken.
✓ Branch 26 taken 6948 times.
✗ Branch 27 not taken.
|
13896 | fJf_df(6, model->get_state()->get_nv()) { |
121 | 6948 | frame = model->get_id(); | |
122 | 6948 | jMf = | |
123 |
1/2✓ Branch 7 taken 6948 times.
✗ Branch 8 not taken.
|
6948 | model->get_state()->get_pinocchio()->frames[model->get_id()].placement; |
124 |
2/4✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6948 times.
✗ Branch 5 not taken.
|
6948 | fXj = jMf.inverse().toActionMatrix(); |
125 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | fJf.setZero(); |
126 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | v_partial_dq.setZero(); |
127 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | v_partial_dv.setZero(); |
128 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | vv_skew.setZero(); |
129 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | vw_skew.setZero(); |
130 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | vv_world_skew.setZero(); |
131 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | vw_world_skew.setZero(); |
132 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | fv_skew.setZero(); |
133 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | fw_skew.setZero(); |
134 |
1/2✓ Branch 1 taken 6948 times.
✗ Branch 2 not taken.
|
6948 | fJf_df.setZero(); |
135 | 6948 | } | |
136 | |||
137 | using Base::df_dx; | ||
138 | using Base::dv0_dq; | ||
139 | using Base::f; | ||
140 | using Base::frame; | ||
141 | using Base::fXj; | ||
142 | using Base::Jc; | ||
143 | using Base::jMf; | ||
144 | using Base::pinocchio; | ||
145 | |||
146 | SE3 lwaMl; | ||
147 | Motion v0; | ||
148 | Force f_local; | ||
149 | Matrix6xs dv0_local_dq; | ||
150 | Matrix6xs fJf; | ||
151 | Matrix6xs v_partial_dq; | ||
152 | Matrix6xs v_partial_dv; | ||
153 | Matrix3s vv_skew; | ||
154 | Matrix3s vw_skew; | ||
155 | Matrix3s vv_world_skew; | ||
156 | Matrix3s vw_world_skew; | ||
157 | Matrix3s fv_skew; | ||
158 | Matrix3s fw_skew; | ||
159 | MatrixXs fJf_df; | ||
160 | }; | ||
161 | |||
162 | } // namespace crocoddyl | ||
163 | |||
164 | /* --- Details -------------------------------------------------------------- */ | ||
165 | /* --- Details -------------------------------------------------------------- */ | ||
166 | /* --- Details -------------------------------------------------------------- */ | ||
167 | #include "crocoddyl/multibody/impulses/impulse-6d.hxx" | ||
168 | |||
169 | #endif // CROCODDYL_MULTIBODY_IMPULSES_IMPULSE_6D_HPP_ | ||
170 |