1#define BIORBD_API_EXPORTS
3#include "InternalForces/Ligaments/Ligament.h"
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"
15#ifdef USE_SMOOTH_IF_ELSE
16#include "Utils/CasadiExpand.h"
19using namespace BIORBD_NAMESPACE;
24 std::make_shared<internal_forces::ligaments::LIGAMENT_TYPE>(
25 internal_forces::ligaments::LIGAMENT_TYPE::NO_LIGAMENT_TYPE)),
29 m_Fl(std::make_shared<utils::Scalar>()),
30 m_damping(std::make_shared<utils::Scalar>())
43 std::make_shared<internal_forces::ligaments::LIGAMENT_TYPE>(
44 internal_forces::ligaments::LIGAMENT_TYPE::NO_LIGAMENT_TYPE)),
48 m_Fl(std::make_shared<utils::Scalar>()),
49 m_damping(std::make_shared<utils::Scalar>()) {
61 std::make_shared<internal_forces::ligaments::LIGAMENT_TYPE>(
62 internal_forces::ligaments::LIGAMENT_TYPE::NO_LIGAMENT_TYPE)),
66 m_Fl(std::make_shared<utils::Scalar>()),
67 m_damping(std::make_shared<utils::Scalar>()) {
81 const std::shared_ptr<Ligament> other)
103internal_forces::ligaments::LIGAMENT_TYPE
109 *
m_type = internal_forces::ligaments::LIGAMENT_TYPE::NO_LIGAMENT_TYPE;
128 std::vector<utils::Vector3d> &ligamentPointsInGlobal,
132 ligamentPointsInGlobal, jacoPointsInGlobal,
nullptr);
135 std::vector<utils::Vector3d> &ligamentPointsInGlobal,
140 ligamentPointsInGlobal, jacoPointsInGlobal, &Qdot);
155 bool updateLigamentKinematics) {
156 if (updateLigamentKinematics)
165 bool updateLigamentKinematics) {
166 if (updateLigamentKinematics) {
177 bool updateLigamentKinematics) {
190 bool updateLigamentKinematics) {
215const std::vector<utils::Vector3d> &
219 bool updateLigamentKinematics) {
220 if (updateLigamentKinematics)
225const std::vector<utils::Vector3d> &
252#ifdef BIORBD_USE_CASADI_MATH
253 *
m_damping = IF_ELSE_NAMESPACE::if_else_zero(
const utils::String & name() const
Return the name of the muscle.
void DeepCopy(const Compound &other)
Deep copy of a compound.
std::shared_ptr< utils::Scalar > m_force
The last computed force.
Compound()
Construct muscle compound.
std::shared_ptr< internal_forces::PathModifiers > m_pathChanger
The set of path modifiers.
Class Geometry of the muscle.
void updateKinematics(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates *Q=nullptr, const rigidbody::GeneralizedVelocity *Qdot=nullptr)
Updates the position and dynamic elements of the muscles.
Holder of all the path modifiers of a muscle.
Class Holds that ligament characteristics.
Base class of all ligament.
void setCharacteristics(const LigamentCharacteristics &characteristics)
Set the ligament characteristics.
const utils::Scalar & velocity(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, bool updateLigamentKinematics=true)
Return the velocity of the ligament.
const std::vector< utils::Vector3d > & ligamentsPointsInGlobal(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, bool updateLigamentKinematics=true)
Return the ligament points in global reference frame.
std::shared_ptr< internal_forces::Geometry > m_position
const internal_forces::Geometry & position() const
Return the position of all the points attached to the ligament (0 being the origin).
virtual void computeFl()=0
Compute the Force-length.
std::shared_ptr< utils::Scalar > m_damping
The ligament damping term.
const utils::Scalar & length(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, bool updateLigamentKinematics=true)
Get the length of the ligament.
const std::vector< utils::Vector3d > & ligamentsPointsInGlobal() const
Return the previously computed ligament points in global reference frame.
void computeDamping()
Compute the ligament damping.
const utils::Scalar & Fl()
Return the Force-Length of the passive element.
void DeepCopy(const Ligament &other)
Deep copy of a ligament in new ligament.
virtual utils::Scalar getForce()
Function allowing modification of the way the force is computed in computeForce().
const LigamentCharacteristics & characteristics() const
Return the ligament characteristics.
std::shared_ptr< utils::Scalar > m_Fl
Force-Length.
void updateOrientations(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q)
Update the position of the origin and insertion positions of the ligament.
LIGAMENT_TYPE type() const
Return the type of the ligament.
virtual void computeForce()
Compute the force of the ligament.
void setPosition(const internal_forces::Geometry &positions)
Set the position of all the points attached to the ligament (0 being the origin).
const utils::Scalar & damping()
Return the ligament damping (spring force).
virtual ~Ligament()
Destroy class properly.
std::shared_ptr< LigamentCharacteristics > m_characteristics
The ligament characteristics.
virtual const utils::Scalar & force()
Return the computed force norm. The ligament orientation had to be computed before calling this funct...
Ligament()
Construct a ligament.
std::shared_ptr< LIGAMENT_TYPE > m_type
The type of the ligament.
virtual void setType()
Set the type of ligament.
Class GeneralizedCoordinates.
Class GeneralizedVelocity.
This is the core of the musculoskeletal model in biorbd.
A wrapper for the Eigen::MatrixXd.
Wrapper around the std::string class with augmented functionality.