Biorbd Release_1.13.0
Loading...
Searching...
No Matches
HillDeGrooteType.cpp
1#define BIORBD_API_EXPORTS
2#include "InternalForces/Muscles/HillDeGrooteType.h"
3
4#include <math.h>
5
6#include "InternalForces/Muscles/Characteristics.h"
7#include "InternalForces/Muscles/MuscleGeometry.h"
8#include "Utils/String.h"
9
10#ifdef USE_SMOOTH_IF_ELSE
11#include "Utils/CasadiExpand.h"
12#endif
13
14using namespace BIORBD_NAMESPACE;
15
27
36
38 const utils::String &name,
41 const internal_forces::PathModifiers &pathModifiers)
42 : internal_forces::muscles::HillType(
43 name,
44 geometry,
46 pathModifiers) {
47 setType();
48}
49
51 const utils::String &name,
54 const internal_forces::PathModifiers &pathModifiers,
56 : internal_forces::muscles::HillType(
57 name,
58 geometry,
60 pathModifiers,
61 emg) {
62 setType();
63}
64
68
70 const std::shared_ptr<Muscle> other)
71 : internal_forces::muscles::HillType(other) {}
72
79
84
86 utils::Scalar kpe = 4;
87 utils::Scalar e0 = 0.6;
88 utils::Scalar normLength =
89 position().length() / characteristics().optimalLength();
90 utils::Scalar t5 = exp(kpe * (normLength - 1) / e0);
91 utils::Scalar t7 = exp(kpe);
92
93#ifdef BIORBD_USE_CASADI_MATH
94 *m_FlPE = IF_ELSE_NAMESPACE::if_else_zero(
95 IF_ELSE_NAMESPACE::gt(normLength, 1), (t5 - 1) / (t7 - 1));
96#else
97 *m_FlPE = normLength > 1 ? (t5 - 1) / (t7 - 1) : 0;
98#endif
99}
100
102 utils::Scalar d1 = -0.318;
103 utils::Scalar d2 = -8.149;
104 utils::Scalar d3 = -0.374;
105 utils::Scalar d4 = 0.886;
106 utils::Scalar v = m_position->velocity();
107
108 utils::Scalar norm_v = v / (characteristics().optimalLength() *
109 this->characteristics().maxShorteningSpeed());
110
111 *m_FvCE = d1 * std::log(
112 (d2 * norm_v + d3) +
113 std::sqrt((d2 * norm_v + d3) * (d2 * norm_v + d3) + 1)) +
114 d4;
115}
116
119 utils::Scalar b11 = 0.815;
120 utils::Scalar b21 = 1.055;
121 utils::Scalar b31 = 0.162;
122 utils::Scalar b41 = 0.063;
123 utils::Scalar b12 = 0.433;
124 utils::Scalar b22 = 0.717;
125 utils::Scalar b32 = -0.030;
126 utils::Scalar b42 = 0.200;
127 utils::Scalar b13 = 0.100;
128 utils::Scalar b23 = 1.000;
129 utils::Scalar b33 = 0.354;
130 utils::Scalar b43 = 0.0;
131 utils::Scalar normLength =
132 position().length() / characteristics().optimalLength();
133
134 *m_FlCE = b11 * exp((-0.5 * ((normLength - b21) * (normLength - b21))) /
135 ((b31 + b41 * normLength) * (b31 + b41 * normLength))) +
136 b12 * exp((-0.5 * ((normLength - b22) * (normLength - b22))) /
137 ((b32 + b42 * normLength) * (b32 + b42 * normLength))) +
138 b13 * exp((-0.5 * ((normLength - b23) * (normLength - b23))) /
139 ((b33 + b43 * normLength) * (b33 + b43 * normLength)));
140}
141
143 *m_type = internal_forces::muscles::MUSCLE_TYPE::HILL_DE_GROOTE;
144}
const utils::String & name() const
Return the name of the muscle.
Definition Compound.cpp:48
Holder of all the path modifiers of a muscle.
Muscle based on DeGroote 2016 https://link.springer.com/article/10.1007%2Fs10439-016-1591-9.
virtual void computeFlPE()
Compute the Force-Length of the passive element.
virtual void computeFvCE()
Compute the Force-Velocity of the passive element.
HillDeGrooteType DeepCopy() const
Deep copy of a DeGroote-type muscle.
virtual void computeFlCE(const State &emg)
Compute the Force-Length of the passive element.
HillType DeepCopy() const
Deep copy of a Hill-type muscle.
Definition HillType.cpp:177
std::shared_ptr< utils::Scalar > m_FlCE
Force-Length of the contractile element.
Definition HillType.h:216
std::shared_ptr< utils::Scalar > m_FvCE
Force-Velocity of the contractile element.
Definition HillType.h:220
std::shared_ptr< utils::Scalar > m_FlPE
Force-Length of the passive element.
Definition HillType.h:218
Characteristics & characteristics() const
Return the muscle characteristics.
Definition Muscle.cpp:254
std::shared_ptr< internal_forces::muscles::MuscleGeometry > m_position
The geometry (position of the nodes) of the muscle.
Definition Muscle.h:345
std::shared_ptr< MUSCLE_TYPE > m_type
The type of the muscle.
Definition Muscle.h:343
const internal_forces::muscles::MuscleGeometry & position() const
Return the position of all the points attached to the muscle (0 being the origin).
Definition Muscle.cpp:174
EMG holder to interact with the muscle.
Definition State.h:17
Wrapper around the std::string class with augmented functionality.
Definition String.h:18