Biorbd Release_1.13.0
Loading...
Searching...
No Matches
LigamentSpringSecondOrder.cpp
1#define BIORBD_API_EXPORTS
2
3#include "InternalForces/Ligaments/LigamentSpringSecondOrder.h"
4
5#include "InternalForces/Compound.h"
6#include "InternalForces/Geometry.h"
7#include "InternalForces/Ligaments/LigamentCharacteristics.h"
8#include "InternalForces/Ligaments/LigamentsEnums.h"
9#include "InternalForces/PathModifiers.h"
10#include "RigidBody/GeneralizedCoordinates.h"
11#include "RigidBody/GeneralizedVelocity.h"
12#include "RigidBody/Joints.h"
13#include "Utils/Error.h"
14
15using namespace BIORBD_NAMESPACE;
18 : internal_forces::ligaments::Ligament(),
19 m_stiffness(std::make_shared<utils::Scalar>()),
20 m_epsilon(std::make_shared<utils::Scalar>(1)) {
21 setType();
22}
23
26 const utils::Scalar &stiffness,
27 const utils::Scalar &epsilon,
28 const utils::String &name,
32 : internal_forces::ligaments::Ligament(name, position, characteristics),
33 m_stiffness(std::make_shared<utils::Scalar>(stiffness)),
34 m_epsilon(std::make_shared<utils::Scalar>(epsilon)) {
35 setType();
36}
37
40 const utils::Scalar &stiffness,
41 const utils::Scalar &epsilon,
42 const utils::String &name,
46 const internal_forces::PathModifiers &pathModifiers)
47 : internal_forces::ligaments::Ligament(
48 name,
51 pathModifiers),
52 m_stiffness(std::make_shared<utils::Scalar>(stiffness)),
53 m_epsilon(std::make_shared<utils::Scalar>(epsilon)) {
54 setType();
55}
56
69
70const utils::Scalar &
74
76 const utils::Scalar &val) {
77 *m_stiffness = val;
78}
79
80const utils::Scalar &
84
86 const utils::Scalar &val) {
87 *m_epsilon = val;
88}
89
99
101 LigamentSpringSecondOrder(const std::shared_ptr<Ligament> other)
102 : internal_forces::ligaments::Ligament(other) {
103 const std::shared_ptr<internal_forces::ligaments::LigamentSpringSecondOrder>
104 ligament_tp(
105 std::dynamic_pointer_cast<
108 ligament_tp != nullptr, "ligament must be of a spring second order Type");
109 m_stiffness = ligament_tp->m_stiffness;
110 m_epsilon = ligament_tp->m_epsilon;
111}
112
115
117 *m_type =
118 internal_forces::ligaments::LIGAMENT_TYPE::LIGAMENT_SPRING_SECOND_ORDER;
119}
120
122 utils::Scalar d =
123 position().length() - characteristics().ligamentSlackLength();
124 *m_Fl = (*m_stiffness / 2) * (d + std::sqrt(d * d + *m_epsilon * *m_epsilon));
125}
const utils::String & name() const
Return the name of the muscle.
Definition Compound.cpp:48
Class Geometry of the muscle.
Definition Geometry.h:31
Holder of all the path modifiers of a muscle.
Class LigamentSpringSecondOrder is a ligament with same behavior than second order spring defined by:...
LigamentSpringSecondOrder DeepCopy() const
Deep copy of a second order spring like ligament.
std::shared_ptr< utils::Scalar > m_stiffness
stiffness of the ligament
virtual void computeFl()
Compute the Force-length of the contractile element.
void setStiffness(const utils::Scalar &stiffness)
Set the stiffness.
virtual void setType()
Set type to second order spring like ligament.
std::shared_ptr< utils::Scalar > m_epsilon
small parameter to avoid negative value
const internal_forces::Geometry & position() const
Return the position of all the points attached to the ligament (0 being the origin).
Definition Ligament.cpp:148
void DeepCopy(const Ligament &other)
Deep copy of a ligament in new ligament.
Definition Ligament.cpp:93
const LigamentCharacteristics & characteristics() const
Return the ligament characteristics.
Definition Ligament.cpp:237
std::shared_ptr< utils::Scalar > m_Fl
Force-Length.
Definition Ligament.h:292
std::shared_ptr< LIGAMENT_TYPE > m_type
The type of the ligament.
Definition Ligament.h:274
static void check(bool cond, const String &message)
Assert that raises the error message if false.
Definition Error.cpp:10
Wrapper around the std::string class with augmented functionality.
Definition String.h:18