Robotran C Documentation
Functions
mbs_dirdyn.c File Reference
#include "mbs_dirdyn.h"
#include <stdlib.h>
#include <stdio.h>
#include "integrator.h"
#include "mbs_project_interface.h"
#include "user_realtime_visu.h"
#include "string.h"
#include "realtime.h"
#include "set_output.h"
#include "MBSfun.h"
#include "mbs_check.h"
#include "mbs_errors_names.h"
#include "mbs_trigo.h"
#include "mbs_message.h"

Functions

MbsDirdynmbs_new_dirdyn (MbsData *mbs_data)
 Create a new direct dynamic structure. More...
 
MbsDirdynmbs_new_dirdyn_aux (MbsData *mbs_data, MbsAux *mbs_aux)
 Create MbsDirdyn strucure and fill it with auxiliary structure. More...
 
int check_user_dirdyn_options (MbsDirdyn *dd, MbsData *mbs_data)
 check that the dirdyn options performed by the user are correct More...
 
void mbs_delete_dirdyn (MbsDirdyn *dirdyn, MbsData *mbs_data)
 Free memory of the direct dynamic structure The options (MbsDirdynOptions) and MbsAux structures are also freed. More...
 
int mbs_run_dirdyn (MbsDirdyn *dd, MbsData *mbs_data)
 Run the direct dynamic simulation. More...
 
int mbs_dirdyn_save (MbsDirdyn *dd, MbsData *mbs_data, double t)
 
int mbs_dirdyn_init (MbsDirdyn *dd, MbsData *mbs_data)
 Run the startup operations of the run_dirdyn function. More...
 
int mbs_dirdyn_loop (MbsDirdyn *dd, MbsData *mbs_data)
 Time loop of the run_dirdyn function: More...
 
int mbs_dirdyn_finish (MbsDirdyn *dd, MbsData *mbs_data)
 Run the finalization operations of the run_dirdyn function. More...
 
int mbs_dirdyn_write_buffers (MbsDirdyn *dd)
 Compute the derivatives of the system (1st derivatives to be given to the ODE integrator) More...
 
int mbs_fct_dirdyn (double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *dd)
 direct dynamics derivative computation More...
 
int save_realtime_update (MbsDirdyn *dd, MbsData *mbs_data)
 update the real-time and saving modules if requested More...
 

Detailed Description

This file implements the functions of the dirdyn module in C.

Creation date: 19/11/2014

Author
Nicolas Docquier (based on the work of other from CEREM: nvdn, av, ...)

(c) Universite catholique de Louvain

Function Documentation

◆ check_user_dirdyn_options()

int check_user_dirdyn_options ( MbsDirdyn dd,
MbsData mbs_data 
)

check that the dirdyn options performed by the user are correct

Parameters
[in]dddirect dynamics module
[in]mbs_dataRobotran main structure
Returns
Error status, <0 in case of failure.

◆ mbs_delete_dirdyn()

void mbs_delete_dirdyn ( MbsDirdyn dirdyn,
MbsData mbs_data 
)

Free memory of the direct dynamic structure The options (MbsDirdynOptions) and MbsAux structures are also freed.

◆ mbs_dirdyn_finish()

int mbs_dirdyn_finish ( MbsDirdyn dirdyn,
MbsData mbs_data 
)

Run the finalization operations of the run_dirdyn function.

Returns
Error status, <0 in case of failure.

◆ mbs_dirdyn_init()

int mbs_dirdyn_init ( MbsDirdyn dirdyn,
MbsData mbs_data 
)

Run the startup operations of the run_dirdyn function.

◆ mbs_dirdyn_loop()

int mbs_dirdyn_loop ( MbsDirdyn dirdyn,
MbsData mbs_data 
)

Time loop of the run_dirdyn function:

The sequence of one iteration is:

  • call the time integrator
  • call the discrete state functions
  • call the storing function
Parameters
[in,out]dirdynthe MbsDirdyn to be run
[in,out]mbs_datathe MbsData structure of the model for which the direct dynamic is computed
Returns
Error status, <0 in case of failure.

◆ mbs_dirdyn_save()

int mbs_dirdyn_save ( MbsDirdyn dd,
MbsData mbs_data,
double  t 
)

◆ mbs_dirdyn_write_buffers()

int mbs_dirdyn_write_buffers ( MbsDirdyn dd)

Compute the derivatives of the system (1st derivatives to be given to the ODE integrator)

t the integration variable (time in the case of MBS time integration) y the state vector for which the derivative must be computed dydt the state derivative vector in which the derivative must be returned s the MbsData of the system mbs_aux the local data structure Write the content of buffer associated to the given MbsDirdyn to disk. This is usefull for writing simulation results at the end of the simulation. This sepcific function is written to be able to ask for writing buffer from python.

dd the MbsDirdyn struct for which the buffers must be written

Returns
error (0 if no error)

◆ mbs_fct_dirdyn()

int mbs_fct_dirdyn ( double  t,
double  y[],
double  dydt[],
MbsData s,
MbsDirdyn dd 
)

direct dynamics derivative computation

Parameters
[in]tcurrent simulation time [s]
[in]ystate vector of size n
[out]dydtderivative
[in,out]sRobotran main structure
[in,out]dddirect dynamic main module structure
Returns
Error status, <0 in case of failure.

◆ mbs_new_dirdyn()

MbsDirdyn* mbs_new_dirdyn ( MbsData mbs_data)

Create a new direct dynamic structure.

This function also initialize the options structures and the MbsAux for storing computational info during simulation.

Fields are allocated to default value.

Parameters
mbs_datathe data structure of the model for which the time integration will be computed.
Returns
An allocated MbsDirdyn structure.

◆ mbs_new_dirdyn_aux()

MbsDirdyn* mbs_new_dirdyn_aux ( MbsData mbs_data,
MbsAux *  mbs_aux 
)

Create MbsDirdyn strucure and fill it with auxiliary structure.

This function also initialize the options structures. A pointer to the given MbsAux structure is kept by the returned structure.

The field of MbsDirdyn are set to default values.

mbs_data the data structure of the model for which the time integration will be computed mbs_aux the MbsAux structure related to the model for which the time integration will be computed.

Returns
An allocated MbsDirdyn structure.

◆ mbs_run_dirdyn()

int mbs_run_dirdyn ( MbsDirdyn dirdyn,
MbsData mbs_data 
)

Run the direct dynamic simulation.

The MbsData structure associated to dirdyn is modified

Parameters
[in,out]dirdynthe MbsDirdyn to be run
[in,out]mbs_datathe MbsData structure of the model for which the direct dynamic is computed
Returns
Error status, <0 in case of failure.

◆ save_realtime_update()

int save_realtime_update ( MbsDirdyn dd,
MbsData mbs_data 
)

update the real-time and saving modules if requested

Parameters
[in]dddirect dynamics module
[in]mbs_dataRobotran main structure
Returns
Error status, <0 in case of failure.