Biorbd Release_1.13.0
Loading...
Searching...
No Matches
FatigueDynamicStateXia.cpp
1#define BIORBD_API_EXPORTS
2#include "InternalForces/Muscles/FatigueDynamicStateXia.h"
3
4#include <cmath>
5
6#include "InternalForces/Muscles/Characteristics.h"
7#include "InternalForces/Muscles/FatigueParameters.h"
8#include "InternalForces/Muscles/StateDynamics.h"
9#include "Utils/Error.h"
10
11using namespace BIORBD_NAMESPACE;
12
14 const utils::Scalar& active,
15 const utils::Scalar& fatigued,
16 const utils::Scalar& resting)
17 : internal_forces::muscles::FatigueDynamicState(active, fatigued, resting) {
18 setType();
19}
20
22 const std::shared_ptr<FatigueState> other)
23 : internal_forces::muscles::FatigueDynamicState(other) {}
24
31
36
39 const internal_forces::muscles::Characteristics& characteristics) {
40#ifdef BIORBD_USE_CASADI_MATH
42 "timeDerivativeState for FatigueDynamicStateXia is not implemented yet");
43#else
44 // Getting the command
45 utils::Scalar targetCommand(emg.activation());
46 utils::Scalar command(0);
47 if (*m_activeFibers < targetCommand) {
48 if (*m_restingFibers > targetCommand - *m_activeFibers) {
49 command = characteristics.fatigueParameters().developFactor() *
50 (targetCommand - *m_activeFibers);
51 } else {
52 command = characteristics.fatigueParameters().developFactor() *
54 }
55 } else {
56 command = characteristics.fatigueParameters().recoveryFactor() *
57 (targetCommand - *m_activeFibers);
58 }
59
60 // Applying the command to the fibers
62 command -
63 characteristics.fatigueParameters().fatigueRate() * *m_activeFibers;
65 -command +
66 characteristics.fatigueParameters().recoveryRate() * *m_fatiguedFibers;
68 characteristics.fatigueParameters().fatigueRate() * *m_activeFibers -
69 characteristics.fatigueParameters().recoveryRate() * *m_fatiguedFibers;
70
73 1e-7,
74 "Sum of time derivates of fatigue states must be equal to 0");
75#endif
76}
77
79 *m_type = internal_forces::muscles::STATE_FATIGUE_TYPE::DYNAMIC_XIA;
80}
const FatigueParameters & fatigueParameters() const
Return the fatigue parameters.
Implementation of Xia (https://www.sciencedirect.com/science/article/pii/S0021929008003692) dynamic f...
FatigueDynamicStateXia(const utils::Scalar &active=1, const utils::Scalar &fatigued=0, const utils::Scalar &resting=0)
Construct FatigueDynamicStateXia.
virtual void setType()
Set type of fatigue dynamic state xia.
FatigueDynamicStateXia DeepCopy() const
Deep copy of the fatigue dynamic state xia.
virtual void timeDerivativeState(const StateDynamics &emg, const Characteristics &characteristics)
Time derivative state of the current states.
std::shared_ptr< utils::Scalar > m_fatiguedFibersDot
The fatigued fibers derivative.
FatigueDynamicState(const utils::Scalar &active=0, const utils::Scalar &fatigued=0, const utils::Scalar &resting=1)
Construct the fatigue dynamic state.
std::shared_ptr< utils::Scalar > m_activeFibersDot
The active fibers derivative.
std::shared_ptr< utils::Scalar > m_restingFibersDot
The resting fibers derivative.
const utils::Scalar & recoveryFactor() const
Return the recovery factor.
const utils::Scalar & fatigueRate() const
Return the fatigue rate.
const utils::Scalar & recoveryRate() const
Return the recovery rate.
const utils::Scalar & developFactor() const
Return the develop factor.
FatigueState DeepCopy() const
Deep copy of the fatigue state.
std::shared_ptr< STATE_FATIGUE_TYPE > m_type
Type of the muscle fatigue model.
std::shared_ptr< utils::Scalar > m_fatiguedFibers
Proportion of fatigued muscle fibers.
std::shared_ptr< utils::Scalar > m_activeFibers
Proportion of active muscle fibers.
std::shared_ptr< utils::Scalar > m_restingFibers
Proportion of resting muscle fibers.
EMG with the capability to compute the time derivative.
const utils::Scalar & activation() const
Return the muscle activation.
Definition State.cpp:117
static void raise(const String &message)
Throw an error message.
Definition Error.cpp:6
static void check(bool cond, const String &message)
Assert that raises the error message if false.
Definition Error.cpp:10