Biorbd Release_1.13.0
Loading...
Searching...
No Matches
Muscle.h
1#ifndef BIORBD_MUSCLES_H
2#define BIORBD_MUSCLES_H
3
4#include "biorbdConfig.h"
5
6#include "InternalForces/Compound.h"
7#include "InternalForces/Muscles/MuscleGeometry.h"
8#include "InternalForces/Muscles/MusclesEnums.h"
9#include "Utils/Scalar.h"
10
11namespace BIORBD_NAMESPACE {
12namespace utils {
13class Matrix;
14class Vector3d;
15} // namespace utils
16
17namespace internal_forces {
18
19namespace muscles {
20class Characteristics;
21class State;
22class Muscles;
23
27class BIORBD_API Muscle : public Compound {
28 friend Muscles;
29
30 public:
34 Muscle();
35
42 Muscle(
43 const utils::String& name,
46
54 Muscle(
55 const utils::String& name,
58 const State& emg);
59
67 Muscle(
68 const utils::String& name,
71 const internal_forces::PathModifiers& pathModifiers);
72
81 Muscle(
82 const utils::String& name,
85 const internal_forces::PathModifiers& pathModifiers,
86 const State& emg);
87
92 Muscle(const Muscle& other);
93
98 Muscle(const std::shared_ptr<Muscle> other);
99
103 virtual ~Muscle();
104
109 void DeepCopy(const Muscle& other);
110
111 // Get and set
112
121 const utils::Scalar& length(
122 rigidbody::Joints& updatedModel,
124 bool updateMuscleParameters = true);
125
134 const utils::Scalar& musculoTendonLength(
135 rigidbody::Joints& updatedModel,
137 bool updateMuscleParameters = true);
138
148 const utils::Scalar& velocity(
149 rigidbody::Joints& updatedModel,
152 bool updateMuscleParameters = true);
153
161 rigidbody::Joints& updatedModel,
163
171 rigidbody::Joints& updatedModel,
174
182 std::vector<utils::Vector3d>& musclePointsInGlobal,
183 utils::Matrix& jacoPointsInGlobal);
184
193 std::vector<utils::Vector3d>& musclePointsInGlobal,
194 utils::Matrix& jacoPointsInGlobal,
196
203
210
216
222
232 const std::vector<utils::Vector3d>& musclesPointsInGlobal(
233 rigidbody::Joints& updatedModel,
235 bool updateMuscleParameters = true);
236
242 const std::vector<utils::Vector3d>& musclesPointsInGlobal() const;
243
248 void setForceIsoMax(const utils::Scalar& forceMax);
249
254 void setState(const State& emg);
255
260 const State& state() const;
261
266 State& state();
267
274 const utils::Scalar& activationDot(
275 const State& state,
276 bool alreadyNormalized = false) const;
277
283 virtual const utils::Scalar& force(const State& emg) = 0;
284
295 virtual const utils::Scalar& force(
296 rigidbody::Joints& updatedModel,
299 const State& emg,
300 bool updateMuscleParameters = true) = 0;
301
311 virtual const utils::Scalar& force(
312 rigidbody::Joints& updatedModel,
314 const State& emg,
315 bool updateMuscleParameters = true) = 0;
316
321 MUSCLE_TYPE type() const;
322
323 protected:
328 virtual void computeForce(const State& emg);
329
336 virtual utils::Scalar getForceFromActivation(const State& emg) = 0;
337
341 virtual void setType();
342
343 std::shared_ptr<MUSCLE_TYPE> m_type;
344 std::shared_ptr<internal_forces::muscles::MuscleGeometry>
346 std::shared_ptr<Characteristics>
348 std::shared_ptr<State> m_state;
349 std::shared_ptr<utils::Scalar> m_muscleLength;
350};
351
352} // namespace muscles
353} // namespace internal_forces
354} // namespace BIORBD_NAMESPACE
355
356#endif // BIORBD_MUSCLES_H
const utils::String & name() const
Return the name of the muscle.
Definition Compound.cpp:48
Compound()
Construct muscle compound.
Definition Compound.cpp:11
Holder of all the path modifiers of a muscle.
void setState(const State &emg)
Set the dynamic state.
Definition Muscle.cpp:259
std::shared_ptr< Characteristics > m_characteristics
The muscle characteristics.
Definition Muscle.h:347
Characteristics & characteristics() const
Return the muscle characteristics.
Definition Muscle.cpp:254
virtual const utils::Scalar & force(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, const State &emg, bool updateMuscleParameters=true)=0
Return the computed force norm from EMG.
std::shared_ptr< State > m_state
The dynamic state.
Definition Muscle.h:348
const utils::Scalar & activationDot(const State &state, bool alreadyNormalized=false) const
Return the activation time derivative.
Definition Muscle.cpp:209
void setCharacteristics(const Characteristics &characteristics)
Set the muscle characteristics.
Definition Muscle.cpp:248
virtual void setType()
Set the type of muscle.
Definition Muscle.cpp:134
virtual void computeForce(const State &emg)
Computer the forces from a specific emg.
Definition Muscle.cpp:222
std::shared_ptr< internal_forces::muscles::MuscleGeometry > m_position
The geometry (position of the nodes) of the muscle.
Definition Muscle.h:345
const utils::Scalar & musculoTendonLength(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, bool updateMuscleParameters=true)
Return the musculo tendon length.
Definition Muscle.cpp:188
const utils::Scalar & length(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, bool updateMuscleParameters=true)
Get the length of the muscle.
Definition Muscle.cpp:178
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
virtual const utils::Scalar & force(const State &emg)=0
Computes and returns the forces norm from the EMG.
const State & state() const
Return the dynamic state.
Definition Muscle.cpp:277
virtual utils::Scalar getForceFromActivation(const State &emg)=0
Function allowing modification of the way the multiplication is done in computeForce(EMG).
void setForceIsoMax(const utils::Scalar &forceMax)
Set the maximal isometric force.
Definition Muscle.cpp:243
virtual const utils::Scalar & force(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, const State &emg, bool updateMuscleParameters=true)=0
Return the computed force norm from EMG.
MUSCLE_TYPE type() const
Return the type of the muscle.
Definition Muscle.cpp:129
const std::vector< utils::Vector3d > & musclesPointsInGlobal(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, bool updateMuscleParameters=true)
Return the muscle points in global reference frame.
Definition Muscle.cpp:228
const utils::Scalar & velocity(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, bool updateMuscleParameters=true)
Return the velocity of the muscle.
Definition Muscle.cpp:198
std::shared_ptr< utils::Scalar > m_muscleLength
muscle tendon length
Definition Muscle.h:349
void DeepCopy(const Muscle &other)
Deep copy of a muscle in new muscle.
Definition Muscle.cpp:120
void setPosition(const internal_forces::muscles::MuscleGeometry &positions)
Set the position of all the points attached to the muscle (0 being the origin).
Definition Muscle.cpp:169
void updateOrientations(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q)
Update the position of the origin and insertion positions of the muscle.
Definition Muscle.cpp:138
EMG holder to interact with the muscle.
Definition State.h:17
This is the core of the musculoskeletal model in biorbd.
Definition Joints.h:48
A wrapper for the Eigen::MatrixXd.
Definition Matrix.h:18
Wrapper around the std::string class with augmented functionality.
Definition String.h:18
Wrapper around Eigen Vector3d and attach it to a parent.
Definition Vector3d.h:27