1#define BIORBD_API_EXPORTS
3#include "InternalForces/Muscles/HillType.h"
5#include "InternalForces/Muscles/Characteristics.h"
6#include "InternalForces/Muscles/MuscleGeometry.h"
7#include "InternalForces/Muscles/State.h"
8#include "RigidBody/GeneralizedCoordinates.h"
9#include "RigidBody/GeneralizedVelocity.h"
10#include "RigidBody/Joints.h"
11#include "Utils/Error.h"
13#ifdef USE_SMOOTH_IF_ELSE
14#include "Utils/CasadiExpand.h"
17using namespace BIORBD_NAMESPACE;
19 : internal_forces::muscles::
Muscle(),
20 m_damping(std::make_shared<utils::Scalar>()),
21 m_FlCE(std::make_shared<utils::Scalar>()),
22 m_FlPE(std::make_shared<utils::Scalar>()),
23 m_FvCE(std::make_shared<utils::Scalar>()),
28 std::make_shared<utils::Scalar>(
42 m_damping(std::make_shared<utils::Scalar>()),
43 m_FlCE(std::make_shared<utils::Scalar>()),
44 m_FlPE(std::make_shared<utils::Scalar>()),
45 m_FvCE(std::make_shared<utils::Scalar>()),
50 std::make_shared<utils::Scalar>(
65 m_damping(std::make_shared<utils::Scalar>()),
66 m_FlCE(std::make_shared<utils::Scalar>()),
67 m_FlPE(std::make_shared<utils::Scalar>()),
68 m_FvCE(std::make_shared<utils::Scalar>()),
73 std::make_shared<utils::Scalar>(
87 : internal_forces::muscles::
Muscle(
92 m_damping(std::make_shared<utils::Scalar>()),
93 m_FlCE(std::make_shared<utils::Scalar>()),
94 m_FlPE(std::make_shared<utils::Scalar>()),
95 m_FvCE(std::make_shared<utils::Scalar>()),
100 std::make_shared<utils::Scalar>(
114 : internal_forces::muscles::
Muscle(
120 m_damping(std::make_shared<utils::Scalar>()),
121 m_FlCE(std::make_shared<utils::Scalar>()),
122 m_FlPE(std::make_shared<utils::Scalar>()),
123 m_FvCE(std::make_shared<utils::Scalar>()),
128 std::make_shared<utils::Scalar>(
139 : internal_forces::muscles::
Muscle(other) {
157 const std::shared_ptr<Muscle> other)
158 : internal_forces::muscles::
Muscle(other) {
159 const std::shared_ptr<internal_forces::muscles::HillType> m_tp(
160 std::dynamic_pointer_cast<internal_forces::muscles::HillType>(other));
218 bool updateMuscleParameters) {
259 *
m_type = internal_forces::muscles::MUSCLE_TYPE::HILL;
263#ifdef BIORBD_USE_CASADI_MATH
264 *
m_damping = IF_ELSE_NAMESPACE::if_else_zero(
297#ifdef BIORBD_USE_CASADI_MATH
298 *
m_FvCE = IF_ELSE_NAMESPACE::if_else(
299 IF_ELSE_NAMESPACE::le(v, 0),
321#ifdef BIORBD_USE_CASADI_MATH
322 *
m_FlPE = IF_ELSE_NAMESPACE::if_else_zero(
342 utils::Scalar damping_param;
const utils::String & name() const
Return the name of the muscle.
std::shared_ptr< utils::Scalar > m_force
The last computed force.
virtual const utils::Scalar & force()
Return the last computed muscle force norm.
Holder of all the path modifiers of a muscle.
Class Holds that muscle characteristics.
Base class for all HillType muscles.
std::shared_ptr< utils::Scalar > m_cste_FlPE_2
constant 2 used in the FlPE
HillType()
Contruct a Hill-type muscle.
const utils::Scalar & FvCE()
Return the Force-Velocity of the contractile element.
std::shared_ptr< utils::Scalar > m_damping
Muscle damping (spring force).
std::shared_ptr< utils::Scalar > m_cste_FlPE_1
constant 1 used in the FlPE
HillType DeepCopy() const
Deep copy of a Hill-type muscle.
const utils::Scalar & FlCE(const State &emg)
Return the Force-Length of the contractile element.
std::shared_ptr< utils::Scalar > m_cste_FlCE_2
constant 2 used in the FlCE
virtual void computeFlCE(const State &emg)
Compute the Force-length of the contractile element.
virtual void computeFvCE()
Compute the Force-Velocity of the contractile element.
std::shared_ptr< utils::Scalar > m_FlCE
Force-Length of the contractile element.
const utils::Scalar & damping()
Return the muscle damping (spring force).
virtual void computeDamping()
Compute the muscle damping.
std::shared_ptr< utils::Scalar > m_FvCE
Force-Velocity of the contractile element.
virtual void computeFlPE()
Compute the Force-Length of the passive element.
std::shared_ptr< utils::Scalar > m_cste_FvCE_1
constant 1 used in the FvCE
std::shared_ptr< utils::Scalar > m_cste_FvCE_2
constant 2 used in the FvCE
std::shared_ptr< utils::Scalar > m_cste_FlCE_1
constant 1 used in the FlCE
virtual utils::Scalar getForceFromActivation(const State &emg)
Function allowing modification of the way the multiplication is done in computeForce(EMG).
virtual void setType()
Set type to Hill.
std::shared_ptr< utils::Scalar > m_cste_damping
parameters used in damping
std::shared_ptr< utils::Scalar > m_FlPE
Force-Length of the passive element.
const utils::Scalar & FlPE()
Return the Force-Length of the passive element.
std::shared_ptr< utils::Scalar > m_cste_eccentricForceMultiplier
Constant used for ForceVelocity.
virtual void normalizeEmg(State &emg)
Normalize the EMG data.
virtual const utils::Scalar & force(const State &emg)
Return the muscle force vector at origin and insertion.
Class muscle geometry of the muscle.
Base class of all muscle.
std::shared_ptr< Characteristics > m_characteristics
The muscle characteristics.
Characteristics & characteristics() const
Return the muscle characteristics.
Muscle()
Construct a muscle.
virtual void computeForce(const State &emg)
Computer the forces from a specific emg.
std::shared_ptr< internal_forces::muscles::MuscleGeometry > m_position
The geometry (position of the nodes) of the muscle.
const utils::Scalar & length(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, bool updateMuscleParameters=true)
Get the length of the muscle.
std::shared_ptr< MUSCLE_TYPE > m_type
The type of the muscle.
const internal_forces::muscles::MuscleGeometry & position() const
Return the position of all the points attached to the muscle (0 being the origin).
const State & state() const
Return the dynamic state.
const utils::Scalar & velocity(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, bool updateMuscleParameters=true)
Return the velocity of the muscle.
void DeepCopy(const Muscle &other)
Deep copy of a muscle in new muscle.
void updateOrientations(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q)
Update the position of the origin and insertion positions of the muscle.
EMG holder to interact with the muscle.
const utils::Scalar & normalizeExcitation(const State &emgMax, bool turnOffWarnings=false)
Compute and return the normalized excitation.
const utils::Scalar & activation() const
Return the muscle activation.
Class GeneralizedCoordinates.
Class GeneralizedVelocity.
This is the core of the musculoskeletal model in biorbd.
static void raise(const String &message)
Throw an error message.
static void check(bool cond, const String &message)
Assert that raises the error message if false.
Wrapper around the std::string class with augmented functionality.