Biorbd Release_1.13.0
Loading...
Searching...
No Matches
BIORBD_NAMESPACE::rigidbody::Contacts Class Reference

Class Contacts. More...

#include <Contacts.h>

Inheritance diagram for BIORBD_NAMESPACE::rigidbody::Contacts:
BIORBD_NAMESPACE::Model

Public Member Functions

 Contacts ()
 Construct contacts.
Contacts DeepCopy () const
 Deep copy of contacts.
void DeepCopy (const Contacts &other)
 Deep copy of contacts.
size_t AddConstraint (size_t bodyId, const utils::Vector3d &bodyPoint, const utils::Vector3d &worldNormal, const utils::String &name, const utils::String &parentName)
 Add a constraint to the constraint set.
size_t AddConstraint (size_t bodyId, const utils::Vector3d &bodyPoint, const utils::String &axis, const utils::String &name, const utils::String &parentName)
 Add a constraint to the constraint set.
size_t AddLoopConstraint (size_t body_id_predecessor, size_t body_id_successor, const utils::RotoTrans &X_predecessor, const utils::RotoTrans &X_successor, const utils::SpatialVector &axis, const utils::String &name, bool enableStabilization=false, double stabilizationParam=0.1)
 Add a loop constraint to the constraint set.
std::vector< utils::SpatialVector > calcLoopConstraintForces (const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, const rigidbody::GeneralizedTorque &Tau)
 compute the forces generated from loop constraints
std::vector< utils::SpatialVector > calcLoopConstraintForces (const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, const rigidbody::GeneralizedTorque &Tau, rigidbody::ExternalForceSet &externalForces)
 compute the forces generated from loop constraints
virtual ~Contacts ()
 Destroy the class properly.
Contacts & getConstraints ()
 Get constraints.
bool hasContacts () const
 Check if there are contacts.
bool hasLoopConstraints () const
 Check if there are loop constraints.
size_t nbContacts () const
 Return the number of contacts.
size_t nbLoopConstraints () const
 Return the number of loop constraints.
std::vector< utils::String > contactNames ()
 Return the name of the all contacts.
utils::String contactName (size_t i)
 Return the name of the contact of a specified axis.
size_t contactRbdlId (const utils::String &name)
 Return the index of the contact corresponding to the given name.
std::vector< utils::Vector3d > constraintsInGlobal (const GeneralizedCoordinates &Q, bool updateKin)
 Return the constraints position in the global reference.
utils::Vector getForce () const
 Return the force acting on the constraint.
int contactSegmentBiorbdId (int idx) const
 Return the segment idx of the contact in biorbd formalism.
std::vector< size_t > segmentRigidContactIdx (int segment_idx) const
 Return the index of rigid contacts for a specified segment index.
int nbRigidContacts () const
 Returns the number of rigid contacts (ignoring the loop constraints).
const std::vector< NodeSegment > & rigidContacts () const
 Returns all the rigid contacts as declared in the model.
const NodeSegment & rigidContact (size_t idx) const
 Returns the rigid contact idx as declared in the model.
utils::Vector3d rigidContact (const GeneralizedCoordinates &Q, size_t idx, bool updateKin)
 Return the rigidContact position in the global reference.
std::vector< utils::Vector3d > rigidContacts (const GeneralizedCoordinates &Q, bool updateKin)
 Return all the rigidContacts position in the global reference.
utils::Vector3d rigidContactVelocity (const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, size_t idx, bool updateKin=true)
 Return the velocity of the chosen contact.
std::vector< utils::Vector3d > rigidContactsVelocity (const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, bool updateKin=true)
 Return the velocities of all the contacts.
utils::Vector3d rigidContactAcceleration (const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, const rigidbody::GeneralizedAcceleration &dQdot, size_t idx, bool updateKin=true)
 Return the acceleration of the chosen contact.
std::vector< utils::Vector3d > rigidContactsAcceleration (const rigidbody::GeneralizedCoordinates &Q, const rigidbody::GeneralizedVelocity &Qdot, const rigidbody::GeneralizedAcceleration &dQdot, bool updateKin=true)
 Return the acceleration of all the contacts.
utils::Matrix rigidContactJacobian (rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q, size_t idx)
 Compute the Jacobian of a single rigid contact.
utils::Matrix rigidContactJacobian (const rigidbody::GeneralizedCoordinates &Q, size_t idx, bool updateKin=true)
 Compute the Jacobian of a single rigid contact.
std::vector< utils::Matrix > rigidContactsJacobian (rigidbody::Joints &updatedModel, const rigidbody::GeneralizedCoordinates &Q)
 Compute the Jacobians of all rigid contacts.
std::vector< utils::Matrix > rigidContactsJacobian (const rigidbody::GeneralizedCoordinates &Q, bool updateKin=true)
 Compute the Jacobians of all rigid contacts.

Protected Member Functions

utils::String swapAxes (const utils::String &axesToSwap) const
 Swap the status of the axes provided, that is adding x, y or z if it is not there and remove them otherwise. This effectively transform an allowed axes set to a axes to remove set, or vice versa.

Static Protected Member Functions

static utils::Matrix projectContactJacobian (const utils::Matrix &J, const rigidbody::NodeSegment &contact)
 Project a 3D point Jacobian onto active contact axes.

Protected Attributes

std::shared_ptr< size_t > m_nbreConstraint
 Number of constraints.
std::shared_ptr< bool > m_isBinded
 If the model is ready.
std::shared_ptr< std::vector< rigidbody::NodeSegment > > m_rigidContacts
std::shared_ptr< size_t > m_nbLoopConstraint
 Number of constraints.

Detailed Description

Class Contacts.

Definition at line 36 of file Contacts.h.

Constructor & Destructor Documentation

◆ Contacts()

rigidbody::Contacts::Contacts ( )

Construct contacts.

Definition at line 25 of file Contacts.cpp.

◆ ~Contacts()

rigidbody::Contacts::~Contacts ( )
virtual

Destroy the class properly.

Definition at line 225 of file Contacts.cpp.

Member Function Documentation

◆ AddConstraint() [1/2]

size_t rigidbody::Contacts::AddConstraint ( size_t bodyId,
const utils::Vector3d & bodyPoint,
const utils::String & axis,
const utils::String & name,
const utils::String & parentName )

Add a constraint to the constraint set.

Parameters
bodyIdThe body which is affected directly by the constraint
bodyPointThe point that is constrained relative to the contact body
axisThe axis along which the constraint acts
nameA human readable name
parentNameA human readable name of the parent (should correspond to the body_id)
Returns
The index of the new constraint

Definition at line 93 of file Contacts.cpp.

◆ AddConstraint() [2/2]

size_t rigidbody::Contacts::AddConstraint ( size_t bodyId,
const utils::Vector3d & bodyPoint,
const utils::Vector3d & worldNormal,
const utils::String & name,
const utils::String & parentName )

Add a constraint to the constraint set.

Parameters
bodyIdThe body which is affected directly by the constraint
bodyPointThe point that is constrained relative to the contact body
worldNormalThe normal along the constraint acts (in base coordinates)
nameA human readable name
parentNameA human readable name of the parent (should correspond to the body_id)
Returns
The index of the new constraint

Definition at line 46 of file Contacts.cpp.

◆ AddLoopConstraint()

size_t rigidbody::Contacts::AddLoopConstraint ( size_t body_id_predecessor,
size_t body_id_successor,
const utils::RotoTrans & X_predecessor,
const utils::RotoTrans & X_successor,
const utils::SpatialVector & axis,
const utils::String & name,
bool enableStabilization = false,
double stabilizationParam = 0.1 )

Add a loop constraint to the constraint set.

Parameters
body_id_predecessorThe identifier of the predecessor body
body_id_successorThe identifier of the successor body
X_predecessorA spatial transform localizing the constrained frames on the predecessor body, expressed with respect to the predecessor body frame
X_successorA spatial transform localizing the constrained frames on the successor body, expressed with respect to the successor body frame
axisA spatial vector indicating the axis along which the constraint acts
nameA human readable name
enableStabilizationWhether stabilization should be enabled or not
stabilizationParamThe value used for stabilization
Returns
The index of the new constraint

Definition at line 139 of file Contacts.cpp.

◆ calcLoopConstraintForces() [1/2]

std::vector< utils::SpatialVector > rigidbody::Contacts::calcLoopConstraintForces ( const rigidbody::GeneralizedCoordinates & Q,
const rigidbody::GeneralizedVelocity & Qdot,
const rigidbody::GeneralizedTorque & Tau )

compute the forces generated from loop constraints

Parameters
QThe generalized coordinates
QdotThe generalized velocities
TauThe generalized torques
Returns
The forces generated by the loop closure at the predecessor in the global frame

Definition at line 163 of file Contacts.cpp.

◆ calcLoopConstraintForces() [2/2]

std::vector< utils::SpatialVector > rigidbody::Contacts::calcLoopConstraintForces ( const rigidbody::GeneralizedCoordinates & Q,
const rigidbody::GeneralizedVelocity & Qdot,
const rigidbody::GeneralizedTorque & Tau,
rigidbody::ExternalForceSet & externalForces )

compute the forces generated from loop constraints

Parameters
QThe generalized coordinates
QdotThe generalized velocities
TauThe generalized torques
externalForcesthe external forces
Returns
The forces generated by the loop closure at the predecessor in the global frame

Definition at line 171 of file Contacts.cpp.

◆ constraintsInGlobal()

std::vector< utils::Vector3d > rigidbody::Contacts::constraintsInGlobal ( const GeneralizedCoordinates & Q,
bool updateKin )

Return the constraints position in the global reference.

Parameters
QThe generalized coordinates of the joints
updateKinWhether the kinematics of the model should be updated from Q
Returns
The constraints positions in the global reference

Definition at line 284 of file Contacts.cpp.

◆ contactName()

utils::String rigidbody::Contacts::contactName ( size_t i)

Return the name of the contact of a specified axis.

Parameters
iThe axis
Returns
The name of the contact of a specified axis

Definition at line 267 of file Contacts.cpp.

◆ contactNames()

std::vector< utils::String > rigidbody::Contacts::contactNames ( )

Return the name of the all contacts.

Returns
The name of the contacts

Definition at line 259 of file Contacts.cpp.

◆ contactRbdlId()

size_t BIORBD_NAMESPACE::rigidbody::Contacts::contactRbdlId ( const utils::String & name)

Return the index of the contact corresponding to the given name.

Parameters
nameThe name of the contact
Returns
The index of the contact
Exceptions
std::runtime_errorif the contact does not exist

Definition at line 273 of file Contacts.cpp.

◆ contactSegmentBiorbdId()

int rigidbody::Contacts::contactSegmentBiorbdId ( int idx) const

Return the segment idx of the contact in biorbd formalism.

Parameters
idxThe index of the contact
Returns
segment idx of the contact in biorbd formalism

Definition at line 497 of file Contacts.cpp.

◆ DeepCopy() [1/2]

rigidbody::Contacts rigidbody::Contacts::DeepCopy ( ) const

Deep copy of contacts.

Returns
Copy of contacts

Definition at line 32 of file Contacts.cpp.

◆ DeepCopy() [2/2]

void rigidbody::Contacts::DeepCopy ( const Contacts & other)

Deep copy of contacts.

Parameters
otherThe contacts to copy

Definition at line 38 of file Contacts.cpp.

◆ getConstraints()

rigidbody::Contacts & rigidbody::Contacts::getConstraints ( )

Get constraints.

Returns
The constraints

Definition at line 227 of file Contacts.cpp.

◆ getForce()

utils::Vector rigidbody::Contacts::getForce ( ) const

Return the force acting on the constraint.

Returns
The force acting on the constraint

Definition at line 478 of file Contacts.cpp.

◆ hasContacts()

bool rigidbody::Contacts::hasContacts ( ) const

Check if there are contacts.

Returns
The presence of contacts

Definition at line 237 of file Contacts.cpp.

◆ hasLoopConstraints()

bool rigidbody::Contacts::hasLoopConstraints ( ) const

Check if there are loop constraints.

Returns
The presence of loop constraints

Definition at line 245 of file Contacts.cpp.

◆ nbContacts()

size_t rigidbody::Contacts::nbContacts ( ) const

Return the number of contacts.

Returns
The number of contacts

Definition at line 253 of file Contacts.cpp.

◆ nbLoopConstraints()

size_t rigidbody::Contacts::nbLoopConstraints ( ) const

Return the number of loop constraints.

Returns
The number of loop constraints

Definition at line 255 of file Contacts.cpp.

◆ nbRigidContacts()

int rigidbody::Contacts::nbRigidContacts ( ) const

Returns the number of rigid contacts (ignoring the loop constraints).

Returns
The number of rigid contacts (ignoring the loop constraints)

Definition at line 493 of file Contacts.cpp.

◆ projectContactJacobian()

utils::Matrix BIORBD_NAMESPACE::rigidbody::Contacts::projectContactJacobian ( const utils::Matrix & J,
const rigidbody::NodeSegment & contact )
staticprotected

Project a 3D point Jacobian onto active contact axes.

Parameters
JThe full 3xN Jacobian of the contact point
contactThe rigid contact definition (provides active axes)
Returns
The reduced Jacobian containing only active axes

Definition at line 400 of file Contacts.cpp.

◆ rigidContact() [1/2]

utils::Vector3d rigidbody::Contacts::rigidContact ( const GeneralizedCoordinates & Q,
size_t idx,
bool updateKin )

Return the rigidContact position in the global reference.

Parameters
QThe generalized coordinates of the joints
idxThe index of the contact
updateKinWhether the kinematics of the model should be updated from Q
Returns
The rigidContact position in the global reference

Definition at line 305 of file Contacts.cpp.

◆ rigidContact() [2/2]

const rigidbody::NodeSegment & rigidbody::Contacts::rigidContact ( size_t idx) const

Returns the rigid contact idx as declared in the model.

Parameters
idxThe index of the contact
Returns
All the rigid contacts as declared in the model

Definition at line 487 of file Contacts.cpp.

◆ rigidContactAcceleration()

utils::Vector3d rigidbody::Contacts::rigidContactAcceleration ( const rigidbody::GeneralizedCoordinates & Q,
const rigidbody::GeneralizedVelocity & Qdot,
const rigidbody::GeneralizedAcceleration & dQdot,
size_t idx,
bool updateKin = true )

Return the acceleration of the chosen contact.

Parameters
QThe generalized coordinates
QdotThe generalized velocities
dQdotThe generalized accelerations
idxThe index of the contact
updateKinIf the model should be updated
Returns
The acceleration of the chosen contact

Definition at line 366 of file Contacts.cpp.

◆ rigidContactJacobian() [1/2]

utils::Matrix rigidbody::Contacts::rigidContactJacobian ( const rigidbody::GeneralizedCoordinates & Q,
size_t idx,
bool updateKin = true )

Compute the Jacobian of a single rigid contact.

Parameters
QThe generalized coordinates
idxIndex of the rigid contact
updateKinIf true, update kinematics before computation
Returns
The Jacobian of the selected contact (projected onto active axes)

Definition at line 434 of file Contacts.cpp.

◆ rigidContactJacobian() [2/2]

utils::Matrix rigidbody::Contacts::rigidContactJacobian ( rigidbody::Joints & updatedModel,
const rigidbody::GeneralizedCoordinates & Q,
size_t idx )

Compute the Jacobian of a single rigid contact.

Parameters
updatedModelThe kinematic model with updated state
QThe generalized coordinates
idxIndex of the rigid contact
Returns
The Jacobian of the selected contact (projected onto active axes)

Definition at line 422 of file Contacts.cpp.

◆ rigidContacts() [1/2]

const std::vector< rigidbody::NodeSegment > & rigidbody::Contacts::rigidContacts ( ) const

Returns all the rigid contacts as declared in the model.

Returns
All the rigid contacts as declared in the model

Definition at line 482 of file Contacts.cpp.

◆ rigidContacts() [2/2]

std::vector< utils::Vector3d > rigidbody::Contacts::rigidContacts ( const GeneralizedCoordinates & Q,
bool updateKin )

Return all the rigidContacts position in the global reference.

Parameters
QThe generalized coordinates of the joints
updateKinWhether the kinematics of the model should be updated from Q
Returns
All the rigidContacts positions in the global reference

Definition at line 317 of file Contacts.cpp.

◆ rigidContactsAcceleration()

std::vector< utils::Vector3d > rigidbody::Contacts::rigidContactsAcceleration ( const rigidbody::GeneralizedCoordinates & Q,
const rigidbody::GeneralizedVelocity & Qdot,
const rigidbody::GeneralizedAcceleration & dQdot,
bool updateKin = true )

Return the acceleration of all the contacts.

Parameters
QThe generalized coordinates
QdotThe generalized velocities
dQdotThe generalized accelerations
updateKinIf the model should be updated
Returns
The acceleration of all the contacts

Definition at line 381 of file Contacts.cpp.

◆ rigidContactsJacobian() [1/2]

std::vector< utils::Matrix > rigidbody::Contacts::rigidContactsJacobian ( const rigidbody::GeneralizedCoordinates & Q,
bool updateKin = true )

Compute the Jacobians of all rigid contacts.

Parameters
QThe generalized coordinates
updateKinIf true, update kinematics before computation
Returns
Vector of Jacobians for all rigid contacts (projected onto active axes)

Definition at line 450 of file Contacts.cpp.

◆ rigidContactsJacobian() [2/2]

std::vector< utils::Matrix > rigidbody::Contacts::rigidContactsJacobian ( rigidbody::Joints & updatedModel,
const rigidbody::GeneralizedCoordinates & Q )

Compute the Jacobians of all rigid contacts.

Parameters
updatedModelThe kinematic model with updated state
QThe generalized coordinates
Returns
Vector of Jacobians for all rigid contacts (projected onto active axes)

Definition at line 465 of file Contacts.cpp.

◆ rigidContactsVelocity()

std::vector< utils::Vector3d > rigidbody::Contacts::rigidContactsVelocity ( const rigidbody::GeneralizedCoordinates & Q,
const rigidbody::GeneralizedVelocity & Qdot,
bool updateKin = true )

Return the velocities of all the contacts.

Parameters
QThe generalized coordinates
QdotThe generalized velocities
updateKinIf the model should be updated
Returns
The velocities of all the contacts

Definition at line 349 of file Contacts.cpp.

◆ rigidContactVelocity()

utils::Vector3d rigidbody::Contacts::rigidContactVelocity ( const rigidbody::GeneralizedCoordinates & Q,
const rigidbody::GeneralizedVelocity & Qdot,
size_t idx,
bool updateKin = true )

Return the velocity of the chosen contact.

Parameters
QThe generalized coordinates
QdotThe generalized velocities
idxThe index of the contact
updateKinIf the model should be updated
Returns
The velocity of the chosen contact

Definition at line 336 of file Contacts.cpp.

◆ segmentRigidContactIdx()

std::vector< size_t > rigidbody::Contacts::segmentRigidContactIdx ( int segment_idx) const

Return the index of rigid contacts for a specified segment index.

Parameters
segment_idxThe index of the segment
Returns
the index of rigid contacts for the specified segment idx

Definition at line 510 of file Contacts.cpp.

◆ swapAxes()

utils::String rigidbody::Contacts::swapAxes ( const utils::String & axesToSwap) const
protected

Swap the status of the axes provided, that is adding x, y or z if it is not there and remove them otherwise. This effectively transform an allowed axes set to a axes to remove set, or vice versa.

Parameters
axesToSwapa vector of up to three values (being "x", "y" or "z")
Returns
The swapped axes

Definition at line 525 of file Contacts.cpp.

Member Data Documentation

◆ m_isBinded

std::shared_ptr<bool> BIORBD_NAMESPACE::rigidbody::Contacts::m_isBinded
protected

If the model is ready.

Definition at line 391 of file Contacts.h.

◆ m_nbLoopConstraint

std::shared_ptr<size_t> BIORBD_NAMESPACE::rigidbody::Contacts::m_nbLoopConstraint
protected

Number of constraints.

Definition at line 395 of file Contacts.h.

◆ m_nbreConstraint

std::shared_ptr<size_t> BIORBD_NAMESPACE::rigidbody::Contacts::m_nbreConstraint
protected

Number of constraints.

Definition at line 390 of file Contacts.h.

◆ m_rigidContacts

std::shared_ptr<std::vector<rigidbody::NodeSegment> > BIORBD_NAMESPACE::rigidbody::Contacts::m_rigidContacts
protected

The rigid contacts declared in the model (copy of RBDL information)

Definition at line 393 of file Contacts.h.


The documentation for this class was generated from the following files: