1 #define BIORBD_API_EXPORTS
2 #include "RigidBody/Contacts.h"
4 #include <rbdl/Kinematics.h>
5 #include "Utils/String.h"
6 #include "Utils/Error.h"
7 #include "RigidBody/GeneralizedCoordinates.h"
8 #include "Utils/Vector3d.h"
9 #include "Utils/RotoTrans.h"
10 #include "Utils/Rotation.h"
11 #include "Utils/SpatialVector.h"
12 #include "RigidBody/Joints.h"
15 RigidBodyDynamics::ConstraintSet (),
16 m_nbreConstraint(std::make_shared<unsigned int>(0)),
17 m_isBinded(std::make_shared<bool>(false))
31 static_cast<RigidBodyDynamics::ConstraintSet&
>(*this) = other;
44 return RigidBodyDynamics::ConstraintSet::AddContactConstraint(body_id, body_point, world_normal, name.c_str(), acc);
54 for (
unsigned int i=0; i<axis.length(); ++i){
57 ret += RigidBodyDynamics::ConstraintSet::AddContactConstraint(
59 else if (axis.
tolower()[i] ==
'y')
60 ret += RigidBodyDynamics::ConstraintSet::AddContactConstraint(
62 else if (axis.
tolower()[i] ==
'z')
63 ret += RigidBodyDynamics::ConstraintSet::AddContactConstraint(
72 unsigned int body_id_predecessor,
73 unsigned int body_id_successor,
78 bool enableStabilization,
79 double stabilizationParam)
82 return RigidBodyDynamics::ConstraintSet::AddLoopConstraint(
83 body_id_predecessor, body_id_successor,
84 RigidBodyDynamics::Math::SpatialTransform(X_predecessor.
rot(), X_predecessor.
trans()),
85 RigidBodyDynamics::Math::SpatialTransform(X_successor.
rot(), X_successor.
trans()),
87 enableStabilization, stabilizationParam, name.c_str());
108 if (*m_nbreConstraint>0)
return
116 return *m_nbreConstraint;
121 std::vector<biorbd::utils::String> names;
122 for (
auto name : RigidBodyDynamics::ConstraintSet::name){
123 names.push_back(name);
131 return RigidBodyDynamics::ConstraintSet::name[i];
146 std::vector<biorbd::utils::Vector3d> tp;
150 for (
unsigned int i=0; i<size(); ++i)
151 tp.push_back(RigidBodyDynamics::CalcBodyToBaseCoordinates(
152 model, Q, body[i], point[i],
false));
biorbd::utils::Vector getForce() const
Return the force acting on the contraint.
unsigned int AddLoopConstraint(unsigned int body_id_predecessor, unsigned int body_id_successor, const biorbd::utils::RotoTrans &X_predecessor, const biorbd::utils::RotoTrans &X_successor, const biorbd::utils::SpatialVector &axis, const biorbd::utils::String &name, bool enableStabilization=false, double stabilizationParam=0.1)
Add a loop constraint to the constraint set.
bool hasContacts() const
Check if there are contacts.
Wrapper of the Eigen::Matrix<double, 6, 1> or Casadi::MX(6, 1)
Wrapper of the Eigen VectorXd.
Wrapper around Eigen Vector3d and attach it to a parent.
std::vector< biorbd::utils::Vector3d > constraintsInGlobal(const biorbd::rigidbody::GeneralizedCoordinates &Q, bool updateKin)
Return the contraints position in the global reference.
Class GeneralizedCoordinates.
std::shared_ptr< unsigned int > m_nbreConstraint
Number of constraints.
static void raise(const biorbd::utils::String &message)
Throw an error message.
biorbd::utils::Vector3d trans() const
Return the translation vector.
unsigned int nbContacts() const
Return the number of contacts.
This is the core of the musculoskeletal model in biorbd.
Homogenous matrix to describe translations and rotations simultaneously.
static biorbd::utils::String tolower(const biorbd::utils::String &str)
Convert a string to a lower case string.
biorbd::rigidbody::Contacts DeepCopy() const
Deep copy of contacts.
Wrapper around the std::string class with augmented functionality.
std::vector< biorbd::utils::String > contactNames()
Return the name of the all contacts.
unsigned int AddConstraint(unsigned int body_id, const biorbd::utils::Vector3d &body_point, const biorbd::utils::Vector3d &world_normal, const biorbd::utils::String &name, double acc=0)
Add a constraint to the constraint set.
std::shared_ptr< bool > m_isBinded
If the model is ready.
Contacts()
Construct contacts.
virtual ~Contacts()
Destroy the class properly.
void UpdateKinematicsCustom(const biorbd::rigidbody::GeneralizedCoordinates *Q=nullptr, const biorbd::rigidbody::GeneralizedVelocity *Qdot=nullptr, const biorbd::rigidbody::GeneralizedAcceleration *Qddot=nullptr)
Update the kinematic variables such as body velocities and accelerations in the model to reflect the ...
biorbd::utils::String contactName(unsigned int i)
Return the name of the contact of a specified axis.
static void check(bool cond, const biorbd::utils::String &message)
Assert that raises the error message if false.
biorbd::utils::Rotation rot() const
Return the rotation matrix.
Contacts & getConstraints()
Get constraints.