Biorbd
Release_1.13.0
Toggle main menu visibility
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
14
using namespace
BIORBD_NAMESPACE;
15
16
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
()
17
: internal_forces::muscles::
HillType
() {
18
setType
();
19
}
20
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
(
21
const
utils::String
&
name
,
22
const
internal_forces::muscles::MuscleGeometry
&geometry,
23
const
internal_forces::muscles::Characteristics
&
characteristics
)
24
: internal_forces::muscles::
HillType
(
name
, geometry,
characteristics
) {
25
setType
();
26
}
27
28
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
(
29
const
utils::String
&
name
,
30
const
internal_forces::muscles::MuscleGeometry
&geometry,
31
const
internal_forces::muscles::Characteristics
&
characteristics
,
32
const
internal_forces::muscles::State
&emg)
33
: internal_forces::muscles::
HillType
(
name
, geometry,
characteristics
, emg) {
34
setType
();
35
}
36
37
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
(
38
const
utils::String
&
name
,
39
const
internal_forces::muscles::MuscleGeometry
&geometry,
40
const
internal_forces::muscles::Characteristics
&
characteristics
,
41
const
internal_forces::PathModifiers
&pathModifiers)
42
: internal_forces::muscles::
HillType
(
43
name
,
44
geometry,
45
characteristics
,
46
pathModifiers) {
47
setType
();
48
}
49
50
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
(
51
const
utils::String
&
name
,
52
const
internal_forces::muscles::MuscleGeometry
&geometry,
53
const
internal_forces::muscles::Characteristics
&
characteristics
,
54
const
internal_forces::PathModifiers
&pathModifiers,
55
const
internal_forces::muscles::State
&emg)
56
: internal_forces::muscles::
HillType
(
57
name
,
58
geometry,
59
characteristics
,
60
pathModifiers,
61
emg) {
62
setType
();
63
}
64
65
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
(
66
const
internal_forces::muscles::Muscle
&other)
67
: internal_forces::muscles::
HillType
(other) {}
68
69
internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
(
70
const
std::shared_ptr<Muscle> other)
71
: internal_forces::muscles::
HillType
(other) {}
72
73
internal_forces::muscles::HillDeGrooteType
74
internal_forces::muscles::HillDeGrooteType::DeepCopy
()
const
{
75
internal_forces::muscles::HillDeGrooteType
copy;
76
copy.
DeepCopy
(*
this
);
77
return
copy;
78
}
79
80
void
internal_forces::muscles::HillDeGrooteType::DeepCopy
(
81
const
internal_forces::muscles::HillDeGrooteType
&other) {
82
internal_forces::muscles::HillType::DeepCopy
(other);
83
}
84
85
void
internal_forces::muscles::HillDeGrooteType::computeFlPE
() {
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
101
void
internal_forces::muscles::HillDeGrooteType::computeFvCE
() {
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
117
void
internal_forces::muscles::HillDeGrooteType::computeFlCE
(
118
const
internal_forces::muscles::State
&) {
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
142
void
internal_forces::muscles::HillDeGrooteType::setType
() {
143
*
m_type
= internal_forces::muscles::MUSCLE_TYPE::HILL_DE_GROOTE;
144
}
BIORBD_NAMESPACE::internal_forces::Compound::name
const utils::String & name() const
Return the name of the muscle.
Definition
Compound.cpp:48
BIORBD_NAMESPACE::internal_forces::PathModifiers
Holder of all the path modifiers of a muscle.
Definition
PathModifiers.h:18
BIORBD_NAMESPACE::internal_forces::muscles::Characteristics
Class Holds that muscle characteristics.
Definition
Characteristics.h:19
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType
Muscle based on DeGroote 2016 https://link.springer.com/article/10.1007%2Fs10439-016-1591-9.
Definition
HillDeGrooteType.h:16
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType::computeFlPE
virtual void computeFlPE()
Compute the Force-Length of the passive element.
Definition
HillDeGrooteType.cpp:85
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType::setType
virtual void setType()
Set type to De_Groote.
Definition
HillDeGrooteType.cpp:142
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType::computeFvCE
virtual void computeFvCE()
Compute the Force-Velocity of the passive element.
Definition
HillDeGrooteType.cpp:101
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType::DeepCopy
HillDeGrooteType DeepCopy() const
Deep copy of a DeGroote-type muscle.
Definition
HillDeGrooteType.cpp:74
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType::HillDeGrooteType
HillDeGrooteType()
Contruct a DeGroote-type muscle.
Definition
HillDeGrooteType.cpp:16
BIORBD_NAMESPACE::internal_forces::muscles::HillDeGrooteType::computeFlCE
virtual void computeFlCE(const State &emg)
Compute the Force-Length of the passive element.
Definition
HillDeGrooteType.cpp:117
BIORBD_NAMESPACE::internal_forces::muscles::HillType::HillType
HillType()
Contruct a Hill-type muscle.
Definition
HillType.cpp:18
BIORBD_NAMESPACE::internal_forces::muscles::HillType::DeepCopy
HillType DeepCopy() const
Deep copy of a Hill-type muscle.
Definition
HillType.cpp:177
BIORBD_NAMESPACE::internal_forces::muscles::HillType::m_FlCE
std::shared_ptr< utils::Scalar > m_FlCE
Force-Length of the contractile element.
Definition
HillType.h:216
BIORBD_NAMESPACE::internal_forces::muscles::HillType::m_FvCE
std::shared_ptr< utils::Scalar > m_FvCE
Force-Velocity of the contractile element.
Definition
HillType.h:220
BIORBD_NAMESPACE::internal_forces::muscles::HillType::m_FlPE
std::shared_ptr< utils::Scalar > m_FlPE
Force-Length of the passive element.
Definition
HillType.h:218
BIORBD_NAMESPACE::internal_forces::muscles::MuscleGeometry
Class muscle geometry of the muscle.
Definition
MuscleGeometry.h:34
BIORBD_NAMESPACE::internal_forces::muscles::Muscle
Base class of all muscle.
Definition
Muscle.h:27
BIORBD_NAMESPACE::internal_forces::muscles::Muscle::characteristics
Characteristics & characteristics() const
Return the muscle characteristics.
Definition
Muscle.cpp:254
BIORBD_NAMESPACE::internal_forces::muscles::Muscle::m_position
std::shared_ptr< internal_forces::muscles::MuscleGeometry > m_position
The geometry (position of the nodes) of the muscle.
Definition
Muscle.h:345
BIORBD_NAMESPACE::internal_forces::muscles::Muscle::m_type
std::shared_ptr< MUSCLE_TYPE > m_type
The type of the muscle.
Definition
Muscle.h:343
BIORBD_NAMESPACE::internal_forces::muscles::Muscle::position
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
BIORBD_NAMESPACE::internal_forces::muscles::State
EMG holder to interact with the muscle.
Definition
State.h:17
BIORBD_NAMESPACE::utils::String
Wrapper around the std::string class with augmented functionality.
Definition
String.h:18
src
InternalForces
Muscles
HillDeGrooteType.cpp
Generated by
1.18.0