Biorbd
Release_1.13.0
Toggle main menu visibility
Loading...
Searching...
No Matches
HillThelenType.cpp
1
#define BIORBD_API_EXPORTS
2
#include "InternalForces/Muscles/HillThelenType.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::HillThelenType::HillThelenType
()
17
: internal_forces::muscles::
HillType
() {
18
setType
();
19
}
20
internal_forces::muscles::HillThelenType::HillThelenType
(
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::HillThelenType::HillThelenType
(
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::HillThelenType::HillThelenType
(
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::HillThelenType::HillThelenType
(
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::HillThelenType::HillThelenType
(
66
const
internal_forces::muscles::Muscle
&other)
67
: internal_forces::muscles::
HillType
(other) {}
68
69
internal_forces::muscles::HillThelenType::HillThelenType
(
70
const
std::shared_ptr<Muscle> other)
71
: internal_forces::muscles::
HillType
(other) {}
72
73
internal_forces::muscles::HillThelenType
74
internal_forces::muscles::HillThelenType::DeepCopy
()
const
{
75
internal_forces::muscles::HillThelenType
copy;
76
copy.
DeepCopy
(*
this
);
77
return
copy;
78
}
79
80
void
internal_forces::muscles::HillThelenType::DeepCopy
(
81
const
internal_forces::muscles::HillThelenType
&other) {
82
internal_forces::muscles::HillType::DeepCopy
(other);
83
}
84
85
void
internal_forces::muscles::HillThelenType::computeFlPE
() {
86
utils::Scalar normLength =
87
position
().length() /
characteristics
().optimalLength();
88
utils::Scalar kpe = 5.0;
89
utils::Scalar e0 = 0.6;
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::HillThelenType::computeFlCE
(
102
const
internal_forces::muscles::State
&) {
103
utils::Scalar normLength =
104
position
().length() /
characteristics
().optimalLength();
105
*
m_FlCE
= exp(-((normLength - 1) * (normLength - 1)) / 0.45);
106
}
107
108
void
internal_forces::muscles::HillThelenType::computeFvCE
() {
109
utils::Scalar v =
m_position
->velocity();
110
utils::Scalar norm_v = v / (
characteristics
().optimalLength() *
111
this->
characteristics
().maxShorteningSpeed());
112
utils::Scalar kvce = 0.06;
113
utils::Scalar flen = 1.6;
114
115
// WARNING CONCENTRIC IS NOT FROM THELEN (see header file for precisions)
116
utils::Scalar a = 3.0 / 11.0;
117
utils::Scalar b = 3.0 / 11.0;
118
119
#ifdef BIORBD_USE_CASADI_MATH
120
*
m_FvCE
= IF_ELSE_NAMESPACE::if_else(
121
IF_ELSE_NAMESPACE::ge(norm_v, 0),
122
((1 + norm_v * flen / kvce) / (1 + norm_v / kvce)),
// If norm_v >= 0
123
IF_ELSE_NAMESPACE::if_else(
124
IF_ELSE_NAMESPACE::ge(norm_v, -1),
125
(1 + a) * b / (-norm_v + b) - a,
// if norm_v >= -1
126
0
// if norm_v < -1
127
));
128
#else
129
130
if
(norm_v >= 0) {
131
*
m_FvCE
= (1 + norm_v * flen / kvce) / (1 + norm_v / kvce);
132
}
else
if
(norm_v >= -1) {
133
*
m_FvCE
= (1 + a) * b / (-norm_v + b) - a;
134
}
else
{
135
*
m_FvCE
= 0;
136
}
137
#endif
138
}
139
void
internal_forces::muscles::HillThelenType::setType
() {
140
*
m_type
= internal_forces::muscles::MUSCLE_TYPE::HILL_THELEN;
141
}
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::HillThelenType
Muscle of Hill type augmented by Thelen https://simtk-confluence.stanford.edu/display/OpenSim/Thelen+...
Definition
HillThelenType.h:24
BIORBD_NAMESPACE::internal_forces::muscles::HillThelenType::setType
virtual void setType()
Set type to Hill_Thelen.
Definition
HillThelenType.cpp:139
BIORBD_NAMESPACE::internal_forces::muscles::HillThelenType::DeepCopy
HillThelenType DeepCopy() const
Deep copy of a Hill-Thelen-type muscle.
Definition
HillThelenType.cpp:74
BIORBD_NAMESPACE::internal_forces::muscles::HillThelenType::computeFlCE
virtual void computeFlCE(const State &emg)
Compute the Force-Length of the passive element.
Definition
HillThelenType.cpp:101
BIORBD_NAMESPACE::internal_forces::muscles::HillThelenType::computeFlPE
virtual void computeFlPE()
Compute the Force-Length of the passive element.
Definition
HillThelenType.cpp:85
BIORBD_NAMESPACE::internal_forces::muscles::HillThelenType::HillThelenType
HillThelenType()
Contruct a Hill-Thelen-type muscle.
Definition
HillThelenType.cpp:16
BIORBD_NAMESPACE::internal_forces::muscles::HillThelenType::computeFvCE
virtual void computeFvCE()
Compute the Force-Velocity of the passive element.
Definition
HillThelenType.cpp:108
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
HillThelenType.cpp
Generated by
1.18.0