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 "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  char* respath;
59 
63  char* animpath;
64 
65  int save_anim;
66 
67  int save_visu;
68 
69  int framerate;
70 
75 
80 
86  char* buffer_format;
87 
88  int realtime;
89 
90  int accelred;
91 
93 
98 
101 
102  int *compute_Qc;
103 
106  /*------------------------------------------*/
107  /* Options related to numerical integration */
108  /*------------------------------------------*/
110  // Various
111  int verbose;
119 
121  // Baumgarte stabilization qdd = qdd - 2*alpha*qd - beta*beta*q
124  double baumgarte_beta;
125 
126  // Options related to waypoints: force integrator to stop at fixed time
129  double delta_t_wp;
130 
131  // Options related to variable time-stepped methods
132  int nmax;
133  double toler;
134  double rtoler;
135  double atoler;
136  double dt_max;
137 
138  // Options related to integrator that need Jacobian computation
139  /*TO BE COMPLETED*/
140  int n_freeze;
142 
143  // Various options
145 
147 
153 typedef void(*initialize_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd,
154  int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *),
155  void (*loop_fct)(MbsData *, MbsDirdyn *),
156  int (*save_realtime_update)(MbsDirdyn* dd, MbsData* mbs_data)
157  );
159 typedef int(*loop_integrator_ptr)(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd);
161 typedef void(*finish_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd);
162 
166 struct MbsDirdyn
167 {
169  MbsAux* mbs_aux;
170 
171  double tsim;
172  double dt;
173 
174  int nState;
175  double *y;
177  double *yout;
182  double *yd;
183 
186 
189 
192 
193  int bufferNb;
194 
195  double** savedArrays;
196 
199 
200  // Part related to numerical integrator
202 
205  void *integrator_struct; // set by initialize_integrator
212 };
213 
224 int mbs_fct_dirdyn(double t, double y[], double dydt[], MbsData *s, MbsDirdyn *dd);
225 
233 int save_realtime_update(MbsDirdyn* dd, MbsData* mbs_data);
234 
235 
236 
237 #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:118
MbsDirdyn::savePeriodCounter
int savePeriodCounter
counter for checking whether results must be saved
Definition: mbs_dirdyn_struct.h:198
MbsDirdynOptions::buffer_format
char * buffer_format
if NULL, "%e" is used. Can be for instance XXX->options->buffer_format = "%4.7f";....
Definition: mbs_dirdyn_struct.h:86
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:175
MbsDirdynOptions::baumgarte_beta
double baumgarte_beta
beta parameter of baumgarte stabilization (>0), default = 0.1 (1/s)
Definition: mbs_dirdyn_struct.h:124
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:174
finish_integrator_ptr
void(* finish_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd)
end of the integration, free the memory
Definition: mbs_dirdyn_struct.h:161
save_realtime_update
int save_realtime_update(MbsDirdyn *dd, MbsData *mbs_data)
update the real-time and saving modules if requested
Definition: mbs_dirdyn.c:1252
MbsDirdynOptions::dt_max
double dt_max
maximal time step [s], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:136
MbsDirdyn::yd
double * yd
Pointers to the derivative vector (dvec_0) of size nState.
Definition: mbs_dirdyn_struct.h:182
MbsDirdynOptions::nmax
int nmax
maximal number of steps [-], default = 1e9
Definition: mbs_dirdyn_struct.h:132
mbs_buffer.h
MbsDirdyn::yout
double * yout
Allocation of a vector (dvec_0) of size nState.
Definition: mbs_dirdyn_struct.h:177
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:102
MbsDirdyn::bufferNb
int bufferNb
Number of buffer required to save the current system topology (ie. coordinates, links....
Definition: mbs_dirdyn_struct.h:193
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:205
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:211
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:171
MbsDirdyn::user_buffer
MbsGrowingBuffer * user_buffer
growing buffer to store user values
Definition: mbs_dirdyn_struct.h:191
MbsBuffer
Definition: mbs_buffer.h:46
MbsDirdynOptions::respath
char * respath
Path in which result file are saved.
Definition: mbs_dirdyn_struct.h:58
MbsDirdynOptions::flag_compute_Qc
int flag_compute_Qc
choose to compute (or not) the Qc for driven variables.
Definition: mbs_dirdyn_struct.h:97
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::flag_symbolic_jacobian
int flag_symbolic_jacobian
1 to use symbolic computation of the jacobian. Only used with implicit integrators....
Definition: mbs_dirdyn_struct.h:141
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:144
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:100
MbsDirdynOptions::baumgarte_alpha
double baumgarte_alpha
alpha parameter of baumgarte stabilization (>0), default = 0.1 (1/s)
Definition: mbs_dirdyn_struct.h:123
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:140
MbsDirdynOptions::framerate
int framerate
number of frame per second for the .anim file, default = 1000
Definition: mbs_dirdyn_struct.h:69
mbs_fct_dirdyn
int mbs_fct_dirdyn(double t, double y[], double dydt[], MbsData *s, MbsDirdyn *dd)
direct dynamics derivative computation
Definition: mbs_dirdyn.c:1169
MbsDirdynOptions::toler
double toler
mixed error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:133
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:188
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
MbsData
Definition: mbs_data.h:246
MbsDirdynOptions::rtoler
double rtoler
relative error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:134
MbsDirdyn::mbs_aux
MbsAux * mbs_aux
Definition: mbs_dirdyn_struct.h:169
MbsDirdynOptions::flag_baumgarte_stabilization
int flag_baumgarte_stabilization
1 if user wants baumgarte stabilization of the independant accelerations
Definition: mbs_dirdyn_struct.h:122
MbsDirdynOptions
Structure defining the option of a direct dynamic.
Definition: mbs_dirdyn_struct.h:38
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:207
MbsDirdynOptions::integrator
int integrator
Set integrator to use, available value: RK4, Dopri5, Rosenbrock, EulerEx, Eulaire,...
Definition: mbs_dirdyn_struct.h:109
MbsDirdynOptions::verbose
int verbose
Verbosity level propagated to other compatible module:
Definition: mbs_dirdyn_struct.h:111
MbsDirdynOptions::delta_t_wp
double delta_t_wp
time interval between two waypoints [s], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:129
MbsDirdynOptions::realtime
int realtime
1 to activate to real-time features, 0 to deactivate them, default = 0
Definition: mbs_dirdyn_struct.h:88
initialize_integrator_ptr
void(* initialize_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), void(*loop_fct)(MbsData *, MbsDirdyn *), int(*save_realtime_update)(MbsDirdyn *dd, MbsData *mbs_data))
These three pointers of functions should be defined for each integrator separately,...
Definition: mbs_dirdyn_struct.h:153
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:128
MbsDirdyn::buffers
MbsBuffer ** buffers
buffer to store generalized coordinates, velocities, acceleration, joint forces...
Definition: mbs_dirdyn_struct.h:185
MbsDirdynOptions::atoler
double atoler
absolute error tolerances [-], default = 1.0e-6
Definition: mbs_dirdyn_struct.h:135
MbsDirdyn
General structure of the direct dynamic module.
Definition: mbs_dirdyn_struct.h:166
MbsDirdynOptions::flag_waypoint
int flag_waypoint
1 to use waypoints, 0 otherwise, default =0
Definition: mbs_dirdyn_struct.h:127
MbsDirdyn::dt
double dt
current integration step size
Definition: mbs_dirdyn_struct.h:172
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: mbs_dirdyn_struct.h:159
MbsDirdyn::loop_integrator
loop_integrator_ptr loop_integrator
pointer to integrator looping function
Definition: mbs_dirdyn_struct.h:209
MbsDirdyn::options
MbsDirdynOptions * options
structure defining the option of a direct dynamic
Definition: mbs_dirdyn_struct.h:168
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:117
mbs_aux.h
MbsDirdynOptions::animpath
char * animpath
Path in which anim file is saved.
Definition: mbs_dirdyn_struct.h:63
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:201
MbsDirdyn::savedArrays
double ** savedArrays
pointer to the array that must be saved to buffers
Definition: mbs_dirdyn_struct.h:195