Robotran C Documentation
mbs_dirdyn_struct.h
Go to the documentation of this file.
1 
15 #ifndef MBS_DIRDYN_STRUCT_h
16 #define MBS_DIRDYN_STRUCT_h
17 
18 #include "mbs_aux.h"
19 #include "mbs_buffer.h"
20 #include "../mbs_numerics/integrator.h"
21 
22 #define DOPRI5_NB_ALLOC_VEC 8
23 
24 
27 #define DIRDYN_INTEGRATOR_OPTION_DEFAULT_nmax (int) 1e9
28 #define DIRDYN_INTEGRATOR_OPTION_DEFAULT_toler 1.0e-3
29 #define DIRDYN_INTEGRATOR_OPTION_DEFAULT_rtoler 1.0e-3
30 #define DIRDYN_INTEGRATOR_OPTION_DEFAULT_atoler 1.0e-6
31 #define DIRDYN_INTEGRATOR_OPTION_DEFAULT_dt_max 1.0e-3
32 #define DIRDYN_INTEGRATOR_WAYPOINT_TIME_ERROR_max 1.0e-10
33 
34 
38 typedef struct MbsDirdynOptions
39 {
41  double t0;
43  double tf;
45  double dt0;
51  int save2file;
54  char* resfilename;
58  const char* respath;
59 
63  const char* animpath;
64 
65  int save_anim;
66 
67  int save_visu;
68 
69  int framerate;
70 
75 
80 
86  char* buffer_format; // if NULL, "%e" is used
87 
88  int realtime;
89 
90  int accelred;
91 
93 
97 
100 
101  int *compute_Qc;
102 
105  /*------------------------------------------*/
106  /* Options related to numerical integration */
107  /*------------------------------------------*/
109  // Various
110  int verbose;
113 
115  // Baumgarte stabilization qdd = qdd - 2*alpha*qd - beta*beta*q
118  double baumgarte_beta;
119 
120  // Options related to waypoints: force integrator to stop at fixed time
123  double delta_t_wp;
124 
125  // Options related to variable time-stepped methods
126  int nmax;
127  double toler;
128  double rtoler;
129  double atoler;
130  double dt_max;
131 
132  // Options related to integrator that need Jacobian computation
133  /*TO BE COMPLETED*/
134  int n_freeze;
135 
136  // Various options
138 
140 
144 struct MbsDirdyn
145 {
147  MbsAux* mbs_aux;
148 
149  double tsim;
150  double dt;
151 
152  int nState;
153  double *y;
155  double *yout;
160  double *yd;
161 
164 
167 
170 
171  int bufferNb;
172 
173  double** savedArrays;
174 
177 
178  // Part related to numerical integrator
180 
183  void *integrator_struct; // set by initialize_integrator
190 
191 
192 };
193 
194 
195 #endif
MbsDirdynOptions::flag_precise_dynamics
int flag_precise_dynamics
= 1 to call the direct dynamics at the beginning of each time step of integration.
Definition: mbs_dirdyn_struct.h:112
MbsDirdyn::savePeriodCounter
int savePeriodCounter
counter for checking whether results must be saved
Definition: mbs_dirdyn_struct.h:176
MbsDirdynOptions::buffer_format
char * buffer_format
Definition: mbs_dirdyn_struct.h:86
loop_integrator_ptr
int(* loop_integrator_ptr)(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
main loop of integration, in which the integrator is called
Definition: integrator.h:39
MbsDirdynOptions::accelred
int accelred
1 to use accelred, 0 otherwise, default = 0
Definition: mbs_dirdyn_struct.h:90
MbsDirdyn::y
double * y
Pointer to the state vector, this is a dvec_0 of size nState.
Definition: mbs_dirdyn_struct.h:153
MbsDirdynOptions::baumgarte_beta
double baumgarte_beta
beta parameter of baumgarte stabilization (>0), default = 0.1 (1/s)
Definition: mbs_dirdyn_struct.h:118
MbsGrowingBuffer
buffer used to store the user variables to output
Definition: mbs_buffer.h:92
MbsDirdyn::nState
int nState
size of the state vector
Definition: mbs_dirdyn_struct.h:152
MbsDirdynOptions::dt_max
double dt_max
maximal time step [s], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:130
MbsDirdyn::yd
double * yd
Pointers to the derivative vector (dvec_0) of size nState.
Definition: mbs_dirdyn_struct.h:160
MbsDirdynOptions::nmax
int nmax
maximal number of steps [-], default = 1e9
Definition: mbs_dirdyn_struct.h:126
mbs_buffer.h
MbsDirdyn::yout
double * yout
Allocation of a vector (dvec_0) of size nState.
Definition: mbs_dirdyn_struct.h:155
MbsDirdynOptions::compute_Qc
int * compute_Qc
If options-flag_compute_Qc is set to 0, the vector allows to compute only the needed Qc.
Definition: mbs_dirdyn_struct.h:101
initialize_integrator_ptr
void(* initialize_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd)
These three pointers of functions should be defined for each integrator separately,...
Definition: integrator.h:37
MbsDirdyn::bufferNb
int bufferNb
Number of buffer required to save the current system topology (ie. coordinates, links....
Definition: mbs_dirdyn_struct.h:171
MbsDirdynOptions::save2file
int save2file
Determine whether results are written to files on disk (in resultsR folder): 1: results are saved 0: ...
Definition: mbs_dirdyn_struct.h:51
MbsDirdyn::integrator_struct
void * integrator_struct
pointer to store integrator structure
Definition: mbs_dirdyn_struct.h:183
MbsDirdynOptions::saveperiod
int saveperiod
The number of time steps between two buffer records default: 1 (every time step are recorded)
Definition: mbs_dirdyn_struct.h:74
MbsDirdyn::finish_integrator
finish_integrator_ptr finish_integrator
pointer to integrator closing function
Definition: mbs_dirdyn_struct.h:189
MbsDirdynOptions::dt0
double dt0
initial value of the integration step size, default = 0.001
Definition: mbs_dirdyn_struct.h:45
MbsDirdynOptions::resfilename
char * resfilename
The keyword used for determining the name of result files Default: 'dirdyn', or 'oneshot' in case the...
Definition: mbs_dirdyn_struct.h:54
MbsDirdyn::tsim
double tsim
current simulation time
Definition: mbs_dirdyn_struct.h:149
MbsDirdyn::user_buffer
MbsGrowingBuffer * user_buffer
growing buffer to store user values
Definition: mbs_dirdyn_struct.h:169
MbsBuffer
Definition: mbs_buffer.h:46
MbsDirdynOptions::flag_compute_Qc
int flag_compute_Qc
choose to compute (or not) the Qc for driven variables.
Definition: mbs_dirdyn_struct.h:96
MbsDirdynOptions::tf
double tf
final time of the simulation, default = 5.0
Definition: mbs_dirdyn_struct.h:43
MbsDirdynOptions::save_visu
int save_visu
1 to save the visualizazion file (as it appears in 'user_realtime_visu.c'), 0 otherwise (only valid i...
Definition: mbs_dirdyn_struct.h:67
MbsDirdynOptions::show_failed_closure
int show_failed_closure
1 to generate animation of the failed Newton-Raphson procedure, default = 0.
Definition: mbs_dirdyn_struct.h:137
MbsDirdynOptions::buffersize
int buffersize
The number of time step that can be recorded in the buffer.
Definition: mbs_dirdyn_struct.h:85
MbsDirdynOptions::compute_all_uxd
int compute_all_uxd
choose to compute (or not) the user derivative during dirdyn time integration. For dirdyn only....
Definition: mbs_dirdyn_struct.h:99
MbsDirdynOptions::baumgarte_alpha
double baumgarte_alpha
alpha parameter of baumgarte stabilization (>0), default = 0.1 (1/s)
Definition: mbs_dirdyn_struct.h:117
finish_integrator_ptr
void(* finish_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd)
end of the integration, free the memory
Definition: integrator.h:41
MbsDirdynOptions::n_freeze
int n_freeze
number of time step when the jacobian is freezed (computed once at the start of the n_freeze time ste...
Definition: mbs_dirdyn_struct.h:134
MbsDirdynOptions::framerate
int framerate
number of frame per second for the .anim file, default = 1000
Definition: mbs_dirdyn_struct.h:69
MbsDirdynOptions::toler
double toler
mixed error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:127
MbsDirdynOptions::flag_oneshot
int flag_oneshot
1 to compute the derivative function only once (no time integration !), default = 0 The time is the v...
Definition: mbs_dirdyn_struct.h:92
MbsDirdyn::buffer_visu
MbsBuffer ** buffer_visu
buffer used to save the visualization as it appears in 'user_realtime_visu.c'
Definition: mbs_dirdyn_struct.h:166
MbsDirdynOptions::save_anim
int save_anim
1 to save the anim file, 0 otherwise (only valid if 'save2file' is set to 1), default = 1
Definition: mbs_dirdyn_struct.h:65
MbsDirdynOptions::max_save_user
int max_save_user
The maximal number of user variables saved default: 12.
Definition: mbs_dirdyn_struct.h:79
MbsDirdynOptions::rtoler
double rtoler
relative error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:128
MbsDirdyn::mbs_aux
MbsAux * mbs_aux
Definition: mbs_dirdyn_struct.h:147
MbsDirdynOptions::flag_baumgarte_stabilization
int flag_baumgarte_stabilization
1 if user wants baumgarte stabilization of the independant accelerations
Definition: mbs_dirdyn_struct.h:116
MbsDirdynOptions
Structure defining the option of a direct dynamic.
Definition: mbs_dirdyn_struct.h:38
MbsDirdynOptions::respath
const char * respath
Path in which result file are saved.
Definition: mbs_dirdyn_struct.h:58
MbsDirdynOptions::t0
double t0
initial time of the simulation, default = 0.0
Definition: mbs_dirdyn_struct.h:41
MbsDirdyn::initialize_integrator
initialize_integrator_ptr initialize_integrator
pointer to integrator initialize function
Definition: mbs_dirdyn_struct.h:185
MbsDirdynOptions::integrator
int integrator
Set integrator to use, available value: RK4, Dopri5, Rosenbrock, EulerEx, Eulaire,...
Definition: mbs_dirdyn_struct.h:108
MbsDirdynOptions::verbose
int verbose
1 to get print indications related to time adaptive integrator, 0 otherwise, default = 1
Definition: mbs_dirdyn_struct.h:110
MbsDirdynOptions::animpath
const char * animpath
Path in which anim file is saved.
Definition: mbs_dirdyn_struct.h:63
MbsDirdynOptions::delta_t_wp
double delta_t_wp
time interval between two waypoints [s], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:123
MbsDirdynOptions::realtime
int realtime
1 to activate to real-time features, 0 to deactivate them, default = 0
Definition: mbs_dirdyn_struct.h:88
MbsDirdynOptions::flag_solout_wp
int flag_solout_wp
1 to call solout only at required waypoints (only if flag_waypoint activated), default = 0
Definition: mbs_dirdyn_struct.h:122
MbsDirdyn::buffers
MbsBuffer ** buffers
buffer to store generalized coordinates, velocities, acceleration, joint forces...
Definition: mbs_dirdyn_struct.h:163
MbsDirdynOptions::atoler
double atoler
absolute error tolerances [-], default = 1.0e-6
Definition: mbs_dirdyn_struct.h:129
MbsDirdyn
General structure of the direct dynamic module.
Definition: mbs_dirdyn_struct.h:144
MbsDirdynOptions::flag_waypoint
int flag_waypoint
1 to use waypoints, 0 otherwise, default =0
Definition: mbs_dirdyn_struct.h:121
MbsDirdyn::dt
double dt
current integration step size
Definition: mbs_dirdyn_struct.h:150
MbsDirdyn::loop_integrator
loop_integrator_ptr loop_integrator
pointer to integrator looping function
Definition: mbs_dirdyn_struct.h:187
MbsDirdyn::options
MbsDirdynOptions * options
structure defining the option of a direct dynamic
Definition: mbs_dirdyn_struct.h:146
MbsDirdynOptions::flag_stop_stiff
int flag_stop_stiff
1 to stop integration if it become stiff, 0 (default value) otherwise, default = 0
Definition: mbs_dirdyn_struct.h:111
mbs_aux.h
MbsDirdyn::flag_ongoing_jac_computation
int flag_ongoing_jac_computation
flag is ON (=1) when the implicit integrator is currently computing the jacobian, default is 0.
Definition: mbs_dirdyn_struct.h:179
MbsDirdyn::savedArrays
double ** savedArrays
pointer to the array that must be saved to buffers
Definition: mbs_dirdyn_struct.h:173