Commit 36a77bcf authored by Sebastien Timmermans's avatar Sebastien Timmermans 🎹
Browse files

[dd] add a check on user time options

parent 8edfed23
......@@ -140,6 +140,39 @@ MbsDirdyn* mbs_new_dirdyn_aux(MbsData* mbs_data, MbsAux* mbs_aux)
return dirdyn;
}
int check_user_dirdyn_options(MbsDirdyn* dd, MbsData* mbs_data)
{
int i;
int err = 0;
// errors generated
if (dd->options->t0 > dd->options->tf)
{
err = _MBS_ERR_INIT;
mbs_msg("\t >Dirdyn> options error: t0 (%f) > tf (%f).\n", dd->options->t0, dd->options->tf);
mbs_msg("[%d] in check_user_dirdyn_options !! \n", err);
return err;
}
if (dd->options->dt0 <= 0.0)
{
err = _MBS_ERR_INIT;
mbs_msg("\t >Dirdyn> options error: dt0 (%f) is not strictly positive.\n", dd->options->dt0);
mbs_msg("[%d] in check_user_dirdyn_options !! \n", err);
return err;
}
if (dd->options->t0 == dd->options->tf)
{
err = _MBS_ERR_INIT;
mbs_msg("\t >Dirdyn> options error: t0 (%f) == tf (%f).\n", dd->options->t0, dd->options->tf);
mbs_msg("\t >Dirdyn> if you need one evaluation of the derivative function, see the oneshot option in dirdyn. \n");
mbs_msg("[%d] in check_user_dirdyn_options !! \n", err);
return err;
}
return err;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_delete_dirdyn(MbsDirdyn* dirdyn, MbsData* mbs_data)
......@@ -394,6 +427,14 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
}
user_dirdyn_init(mbs_data, dd);
// Checking time options
err = check_user_dirdyn_options(dd, mbs_data);
if (err < 0) {
mbs_msg("\t >Dirdyn> Incoherence detected during module initialization! \n");
mbs_msg("[%d] in mbs_dirdyn_init !! \n", err);
return err;
}
/* TODO : Move in initialize_integrator when 2nd order integrator will be implemented */
// Simulation state initialization
for (i = 1; i <= mbs_data->nqu; i++)
......@@ -1032,3 +1073,4 @@ int save_realtime_update(MbsDirdyn* dd, MbsData* mbs_data)
return 0;
}
......@@ -174,4 +174,14 @@ int mbs_fct_dirdyn(double t, double y[], double dydt[], MbsData *s, MbsDirdyn *d
*/
int save_realtime_update(MbsDirdyn* dd, MbsData* mbs_data);
/*! \brief check that the dirdyn options performed by the user are correct
*
* \param[in] dd direct dynamics module
* \param[in] mbs_data Robotran main structure
*
* \return Error status, <0 in case of failure.
*/
int check_user_dirdyn_options(MbsDirdyn* dd, MbsData* mbs_data);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment