Biorbd Release_1.13.0
Loading...
Searching...
No Matches
ExternalForceSet.h
1#ifndef BIORBD_UTILS_EXTERNAL_FORCE_H
2#define BIORBD_UTILS_EXTERNAL_FORCE_H
3
4#include "biorbdConfig.h"
5
6#include <memory>
7
8#include "RigidBody/RotoTransNodes.h"
9#include "Utils/RotoTransNode.h"
10#include "Utils/Scalar.h"
11#include "Utils/SpatialVector.h"
12
13namespace BIORBD_NAMESPACE {
14class Model;
15namespace utils {
16class Vector3d;
17class String;
18} // namespace utils
19
20namespace rigidbody {
23class NodeSegment;
24class RotoTransNodes;
25class Joints;
26
31class BIORBD_API ExternalForceSet {
32 protected:
33#ifndef SWIG
39 public:
45 void addNode(
46 const utils::SpatialVector& vector,
48 m_nodes.push_back(node);
49 m_vectors.push_back(vector);
50 }
51
57 std::pair<utils::SpatialVector, utils::RotoTransNode> get(int index) {
58 return std::pair<utils::SpatialVector, utils::RotoTransNode>(
59 m_vectors[index], m_nodes[index]);
60 }
61
66 size_t size() const { return m_nodes.size(); }
67
71 void clear() {
72 m_nodes.clear();
73 m_vectors.clear();
74 }
75
76 std::vector<utils::RotoTransNode>
78 std::vector<utils::SpatialVector>
81 };
82#endif
83
84 public:
94 Model& model,
95 bool useTranslationalForces = true,
96 bool useSoftContacts = true);
97
102
111 void add(
112 const utils::String& segmentName,
113 const utils::SpatialVector& vector);
114
123 void add(
124 const utils::String& segmentName,
125 const utils::SpatialVector& vector,
126 const utils::Vector3d& pointOfApplication);
127
138 const utils::String& segmentName,
139 const utils::SpatialVector& vector,
140 const utils::Vector3d& pointOfApplication);
141
150 const utils::Vector3d& forceInGlobal,
151 const utils::String& segmentName,
152 const utils::Vector3d& pointOfApplicationInLocal);
153
161 const utils::Vector3d& force,
162 const rigidbody::NodeSegment& pointOfApplication);
163
169 void setZero();
170
171#ifndef SWIG
172
179 std::vector<RigidBodyDynamics::Math::SpatialVector> computeRbdlSpatialVectors(
180 rigidbody::Joints& updatedModel);
181
189 std::vector<RigidBodyDynamics::Math::SpatialVector> computeRbdlSpatialVectors(
190 rigidbody::Joints& updatedModel,
192
200 std::vector<RigidBodyDynamics::Math::SpatialVector> computeRbdlSpatialVectors(
201 rigidbody::Joints& updatedModel,
204
211 std::vector<utils::SpatialVector> computeSpatialVectors(
212 rigidbody::Joints& updatedModel);
213
221 std::vector<utils::SpatialVector> computeSpatialVectors(
222 rigidbody::Joints& updatedModel,
224
232 std::vector<utils::SpatialVector> computeSpatialVectors(
233 rigidbody::Joints& updatedModel,
236#endif // !SWIG
237
245
246 protected:
258 rigidbody::Joints& updatedModel,
260 std::vector<utils::SpatialVector>& out);
261
272 rigidbody::Joints& updatedModel,
274 std::vector<utils::SpatialVector>& out) const;
275
287 rigidbody::Joints& updatedModel,
290 std::vector<utils::SpatialVector>& out) const;
291
301 const utils::Vector3d& force,
302 const rigidbody::NodeSegment& pointOfApplication) const;
303
313 const utils::SpatialVector& v,
314 const rigidbody::NodeSegment& pointOfApplication) const;
315
316 protected:
318 bool
321
322 std::vector<utils::SpatialVector>
324
329
330 std::vector<std::pair<utils::Vector3d, rigidbody::NodeSegment>>
335};
336} // namespace rigidbody
337} // namespace BIORBD_NAMESPACE
338
339#endif // BIORBD_UTILS_EXTERNAL_FORCE_H
The actual musculoskeletal model that holds everything in biorbd.
This is an internal structure holding the information for the local forces. RotoTransNodes could have...
size_t size() const
Return the number of forces stored.
std::pair< utils::SpatialVector, utils::RotoTransNode > get(int index)
Return the pair force vector/point of application in the local reference frame.
std::vector< utils::RotoTransNode > m_nodes
All the points of application of the forces.
void addNode(const utils::SpatialVector &vector, utils::RotoTransNode node)
Add a force vector and its point of application.
utils::SpatialVector transportAtOrigin(const utils::SpatialVector &v, const rigidbody::NodeSegment &pointOfApplication) const
Get the rigid contacts in a list of spatial vector of dimension 6xNdof.
bool hasExternalForceInLocalReferenceFrame() const
Return if there is at least one external force expressed in the local reference frame....
Model & m_model
A reference to the kinematic model.
std::vector< utils::SpatialVector > m_externalForces
The vector that holds all the external forces.
bool m_useSoftContacts
If soft contacts should be included.
void combineSoftContactForces(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, std::vector< utils::SpatialVector > &out) const
Add the soft contact forces to the internal Set.
void combineTranslationalForces(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, std::vector< utils::SpatialVector > &out) const
Add the translational forces to the internal Set.
std::vector< std::pair< utils::Vector3d, rigidbody::NodeSegment > > m_translationalForces
std::vector< RigidBodyDynamics::Math::SpatialVector > computeRbdlSpatialVectors(rigidbody::Joints &updatedModel)
The forces in a rbdl compatible format. This won't work if useTranslationalForces or useSoftContacts ...
bool m_useTranslationalForces
If translational forces should be included.
std::vector< utils::SpatialVector > computeSpatialVectors(rigidbody::Joints &updatedModel)
The forces in a rbdl compatible format. This won't work if useTranslationalForces or useSoftContacts ...
void setZero()
Initialize and zero out all the spatial vectors of the Set. Note this should always be called before ...
void addInSegmentReferenceFrame(const utils::String &segmentName, const utils::SpatialVector &vector, const utils::Vector3d &pointOfApplication)
Apply a new value to the specified spatial vector of the Set. WARNING: This vector is expected to be ...
void combineLocalReferenceFrameForces(rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, std::vector< utils::SpatialVector > &out)
Add the forces expressed in the local reference to the internal Set.
ExternalForceSet(Model &model, bool useTranslationalForces=true, bool useSoftContacts=true)
Construct ExternalForceSet.
utils::SpatialVector transportForceAtOrigin(const utils::Vector3d &force, const rigidbody::NodeSegment &pointOfApplication) const
Get the rigid contacts in a list of spatial vector of dimension 6xNdof.
void add(const utils::String &segmentName, const utils::SpatialVector &vector)
Apply a new value to the specified spatial vector of the Set. WARNING: This vector is expected to be ...
void addTranslationalForce(const utils::Vector3d &forceInGlobal, const utils::String &segmentName, const utils::Vector3d &pointOfApplicationInLocal)
Add a pure force at a specific point on the kinematic chain.
This is the core of the musculoskeletal model in biorbd.
Definition Joints.h:48
A point attached to a segment, generally speaking a skin marker.
Definition NodeSegment.h:20
A RotoTrans which is attached to a segment.
Wrapper of the Eigen::Matrix<double, 6, 1> or Casadi::MX(6, 1).
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