Robotran C Documentation
Macros | Functions
mbs_calc_force.c File Reference

Definition of the functions related to forces in the multibody system. More...

#include <math.h>
#include "mbs_1D_array.h"
#include "mbs_data.h"
#include "mbs_define.h"
#include "mbs_matrix.h"
#include "mbs_project_interface.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
#include "mbs_sensor.h"
#include "useful_functions.h"
#include "MBSfun.h"

Macros

#define MSG_ERR   ">> FORCES>> "
 
#define MSG_PRE   " >> "
 

Functions

int mbs_calc_force (MbsData *s)
 compute the force and torques applied on the multibody system. More...
 
double * get_ball_force (MbsData *mbs_data, MbsSensor *sens, int ancestor, int ball_id, double forces_I[3])
 Express the force component of a ball constraint in the inertial frame. More...
 
double * get_rod_force (MbsData *mbs_data, MbsSensor *sens, int rod_id, int body_1_id, int pt_1_id, int body_2_id, int pt_2_id, double forces_I[3])
 Return the forces components of a rod constraints in inertial frame. More...
 
double * get_link_force (MbsData *mbs_data, MbsSensor *sens, int link_id, int body_1_id, int pt_1_id, int body_2_id, int pt_2_id, double *trsh, double forces_I[3])
 Compute the component of the forces in a link force in the inertial frame. More...
 

Detailed Description

Definition of the functions related to forces in the multibody system.

Author
Nicolas Docquier, Robotran Team

Macro Definition Documentation

◆ MSG_ERR

#define MSG_ERR   ">> FORCES>> "

◆ MSG_PRE

#define MSG_PRE   " >> "

Function Documentation

◆ get_ball_force()

double* get_ball_force ( MbsData mbs_data,
MbsSensor sens,
int  ancestor,
int  ball_id,
double  forces_I[3] 
)

Express the force component of a ball constraint in the inertial frame.

The function needs that the Lagrangre's multipliers in MbsData::lambda are already computed. They are computed during the computation of the system dynamic.

Parameters
[in]mbs_dataPointer to the multibody model structure.
[out]sensPointer to the sensor available for computation. A new sensor is allocated (and freed) if the provided pointer is NULL.
[in]ancestorThe index of the first common ancestor to the two ball extremities. The base index is 0.
[in]ball_idIndex of the ball cut.
[out]forces_IThe array where to fill the forces components in inertial frame. If NULL a new array is allocated and must be freed by the caller.
Returns
The array with the force expressed in inertial frame. This is forces_I except if NULL was provided. NULL is returned in case of error.

◆ get_link_force()

double* get_link_force ( MbsData mbs_data,
MbsSensor sens,
int  link_id,
int  body_1_id,
int  pt_1_id,
int  body_2_id,
int  pt_2_id,
double *  trsh,
double  forces_I[3] 
)

Compute the component of the forces in a link force in the inertial frame.

The function needs that the link force amplitude in MbsData::Fl is already computed. It is computed during the computation of the system dynamic. The sign convention of the link forces are currently:

  • MbsData::Fl[i] > 0: link in traction, trying to get the bodies closer.
  • MbsData::Fl[i] < 0: link in compression, trying to separate the bodies.

The computed force is applied at the point pt_2_id located on the body body_2_id.

The components of the force applied on the other point are simply the opposite of the returned force. It can also be obtained by inversing the bodies and points indices.

Parameters
[in]mbs_dataPointer to the multibody model structure.
[out]sensPointer to the sensor available for computation. A new sensor is allocated (and freed) if the provided pointer is NULL.
[in]link_idThe index of the link.
[in]body_1_idThe index of the body with the first extremity of the link. The base is referenced by index 0.
[in]pt_1_idThe index of the anchor point which is the first extremity of the link force. If the extremity is located on a body origin, the index 0 must be provided.
[in]body_2_idThe index of the body with the second extremity of the link. The base is referenced by index 0. The returned force component are applied on this body.
[in]pt_2_idThe index of the anchor point which is the second extremity of the link force. If the extremity is located on a body origin, the index 0 must be provided. The returned force component are applied on this point.
[in]trshPointer to the minimal link length allowed when computed. A default value of 1e-14 is used if NULL is provided. If the lenght of the rod is lower than this value, NULL is returned.

A pointer to a negative value (ie `trsh[0] < 0) will allow any link length which can lead to division by zero.

Parameters
[out]forces_IThe array where to fill the forces components in inertial frame. It is filled with INFINITY if an error occurs. If NULL a new array is allocated and must be freed by the caller.
Returns
The array with the force expressed in inertial frame. This is forces_I except if NULL was provided. NULL is returned in case of error.

◆ get_rod_force()

double* get_rod_force ( MbsData mbs_data,
MbsSensor sens,
int  rod_id,
int  body_1_id,
int  pt_1_id,
int  body_2_id,
int  pt_2_id,
double  forces_I[3] 
)

Return the forces components of a rod constraints in inertial frame.

The function needs that the Lagrangre's multipliers in MbsData::lambda are already computed. They are computed during the computation of the system dynamic. The sign convention of the Lagrange multiplier assiciate to rod are:

The computed force is applied at the point pt_2_id located on the body body_2_id.

The components of the force applied on the other point are simply the opposite of the returned force. It can also be obtained by inversing the bodies and points indices.

The length of the rod is not required in input as the computation multiply:

  • the rod direction (unit vector) being [dx, dy, dz] / lenght
  • the force in the rod being Lagrange * length then the length vanishes.
Parameters
[in]mbs_dataPointer to the multibody model structure.
[out]sensPointer to the sensor available for computation. A new sensor is allocated (and freed) if the provided pointer is NULL.
[in]rod_idThe index of the rod cut.
[in]body_1_idThe index of the body with the first extremity of the link. The base is referenced by index 0.
[in]pt_1_idThe index of the anchor point which is the first extremity of the link force. If the extremity is located on a body origin, the index 0 must be provided.
[in]body_2_idThe index of the body with the second extremity of the link. The base is referenced by index 0. The returned force component are applied on this body.
[in]pt_2_idThe index of the anchor point which is the second extremity of the link force. If the extremity is located on a body origin, the index 0 must be provided. The returned force component are applied on this point.
[out]forces_IThe array where to fill the forces components in inertial frame. It is filled with INFINITY if an error occurs. If NULL a new array is allocated and must be freed by the caller.
Returns
The array with the force expressed in inertial frame. This is forces_I except if NULL was provided. NULL is returned in case of error.

◆ mbs_calc_force()

int mbs_calc_force ( MbsData s)

compute the force and torques applied on the multibody system.

Set the matrices MbsData::frc and MbsData::trq at zero, then compute the contribution of:

  • Links forces
  • Links 3D forces
  • External forces
  • Joints forces
Parameters
[in,out]sthe MbsData structure.
Returns
MBS_INFO_SUCCESS if everything went well, <0 if an error has occured