Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
088a8c4a
Commit
088a8c4a
authored
Dec 18, 2020
by
Olivier Lantsoght
🏁
Browse files
Merge branch 'better_errors_child' into 'dev'
Better errors handling See merge request robotran/mbsysc!391
parents
ca1f5f73
9fce2ae8
Changes
109
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
088a8c4a
## Changes for next release
*
To be defined
*
[
C
][
Python
]
error handling is enhanced, with new error names and proper closing of the functions for all modules, except Real-time in dirdyn
*
[C] All user models are printed with the
`mbs_print_data`
function
*
[C] New function
`print_d_vec_0_format`
allowing to set the format of the vector values.
*
[C] New function to compute matrix product between matrices of specified shape:
`doublematrix_product_0`
.
*
[C] LPK functions new error catched with code
`-#16`
; Documentation fixed.
*
[C] Some functions that my be called by users have return status (<0 in case of error):
*
Look Up Table:
`mbs_lut_2D_alloc()`
,
`mbs_lut_res_alloc()`
,
`mbs_lut_res_load_file()`
;
*
Useful functions:
`read_dmat_0()`
*
[Py] User vector outputs are now available in the MbsDirdyn results field.
*
[Py] Using C symbolic library and Python user is possible even with external forces.
*
[Py] Adding missing fields in MbsData.
...
...
MBsysC/mbs_common/mbs_load_xml/mbs_load_libraries.c
View file @
088a8c4a
...
...
@@ -8,6 +8,7 @@
#include "mbs_load_libraries.h"
#include "mbs_path.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
#include "mbs_project_interface.h"
...
...
@@ -177,7 +178,7 @@ int mbs_load_symbolic_functions(MbsData* mbs_data, const char* symbolicLib_path,
mbs_msg
(
">>LOAD>> Error in mbs_load_symbolic_functions, unable to load symbolic library.
\n
"
);
mbs_msg
(
" Library path: %s
\n
"
,
lib_fullpath
);
free
(
lib_fullpath
);
return
-
8
;
return
_MBS_ERR_LOW_FILES
;
}
mbs_data
->
fct
.
symb
.
mbs_link
=
(
mbs_link_ptr
)
mbs_load_function
(
symbLibInfo
,
"mbs_link"
);
...
...
@@ -221,7 +222,7 @@ int mbs_load_user_functions(MbsData* mbs_data, const char* userfctLib_path, cons
mbs_msg
(
">>LOAD>> Error in mbs_load_user_functions, unable to load user library.
\n
"
);
mbs_msg
(
" Library path: %s
\n
"
,
lib_fullpath
);
free
(
lib_fullpath
);
return
-
8
;
return
_MBS_ERR_LOW_FILES
;
}
...
...
MBsysC/mbs_common/mbs_load_xml/mbs_load_xml.c
View file @
088a8c4a
...
...
@@ -4,7 +4,7 @@
#include "mbs_path.h"
#include "mbs_message.h"
#include "mbs_check.h"
#include "mbs_errors_names.h"
#include <string.h>
...
...
@@ -38,6 +38,10 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_path)
loader
=
mbs_new_loader
();
mbs_data
=
mbs_load_with_loader
(
mbs_filename
,
build_path
,
loader
);
mbs_delete_loader
(
loader
);
if
(
mbs_data
==
NULL
)
{
mbs_error_msg
(
"in mbs_load !!
\n
"
);
}
return
mbs_data
;
}
...
...
@@ -61,7 +65,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
mbs_infos
=
mbs_info_reader
(
mbs_filename
);
if
(
!
mbs_infos
){
mbs_msg
(
">>LOAD>> unable to create MbsInfo.
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
-
909
);
mbs_msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
_MBS_ERR_MOD_LOAD
+
_MBS_ERR_LOW_FILES
);
return
NULL
;
}
}
...
...
@@ -83,7 +87,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
{
mbs_msg
(
">>LOAD>> build_path is not defined
\n
"
);
mbs_msg
(
"
\n
>>LOAD>> Check your files names and paths
\n\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
-
910
);
mbs_msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
_MBS_ERR_MOD_LOAD
+
_MBS_ERR_LOW_FILES
);
free
(
symbolicLib_name
);
free
(
symbolicLib_path
);
free
(
userfctLib_name
);
...
...
@@ -154,14 +158,30 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
mbs_data
=
mbs_new_data
();
mbs_data
->
project_path
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
strlen
(
mbs_filename
)
+
100
));
find_project_path
(
mbs_filename
,
mbs_data
->
project_path
);
err
=
find_project_path
(
mbs_filename
,
mbs_data
->
project_path
);
if
(
err
<
0
)
{
free
(
symbolicLib_name
);
free
(
symbolicLib_path
);
free
(
userfctLib_name
);
free
(
userfctLib_path
);
if
(
!
custom_mbs_info
)
{
mbs_delete_infos
(
mbs_infos
);
}
mbs_msg
(
"
\n
>>LOAD>> find_project_path
\n\n
"
);
mbs_msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
_MBS_ERR_MOD_LOAD
+
err
);
mbs_delete_data
(
mbs_data
);
return
NULL
;
}
// if we call project and user function pointer, init them
#ifdef PRJ_FCT_PTR
if
(
opts
->
load_symb_user
!=
LOAD_NONE
)
{
err
=
mbs_load_symbolic_functions
(
mbs_data
,
symbolicLib_path
,
symbolicLib_name
);
if
(
err
<
0
){
mbs_
error_
msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
-
900
+
err
);
mbs_msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
_MBS_ERR_MOD_LOAD
+
err
);
free
(
symbolicLib_name
);
free
(
symbolicLib_path
);
free
(
userfctLib_name
);
...
...
@@ -180,7 +200,7 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
if
(
opts
->
load_symb_user
==
LOAD_ALL
)
{
err
=
mbs_load_user_functions
(
mbs_data
,
userfctLib_path
,
userfctLib_name
);
if
(
err
<
0
){
mbs_
error_
msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
-
900
+
err
);
mbs_msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
_MBS_ERR_MOD_LOAD
+
err
);
free
(
symbolicLib_name
);
free
(
symbolicLib_path
);
free
(
userfctLib_name
);
...
...
@@ -204,6 +224,21 @@ MbsData* mbs_load_with_loader(const char* mbs_filename, const char* build_path,
#endif
mbs_data
=
mbs_info_to_data
(
mbs_infos
,
mbs_data
);
if
(
mbs_data
==
NULL
)
{
free
(
symbolicLib_name
);
free
(
symbolicLib_path
);
free
(
userfctLib_name
);
free
(
userfctLib_path
);
if
(
!
custom_mbs_info
)
{
mbs_delete_infos
(
mbs_infos
);
}
mbs_msg
(
"
\n
>>LOAD>> mbs_info_to_data
\n\n
"
);
mbs_msg
(
"[%d] in mbs_load_with_loader !!
\n
"
,
_MBS_ERR_MOD_LOAD
+
_MBS_ERR_LOW_FILES
);
return
NULL
;
}
mbs_data
->
mbs_filename
=
(
char
*
)
malloc
(
1
+
strlen
(
mbs_filename
));
strcpy
(
mbs_data
->
mbs_filename
,
mbs_filename
);
...
...
@@ -710,8 +745,8 @@ MbsData* mbs_info_to_data(MbsInfos* mbs_infos, MbsData* s)
{
mbs_msg
(
">>LOAD>> Error while fetching user_model number
\n
"
);
mbs_msg
(
"
\n
>>LOAD>> Please Re-generated your user_model Files !!!
\n\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_load_with_loader
\n
"
,
-
900
);
exit
(
1
)
;
mbs_msg
(
"[%d] in mbs_load_with_loader
\n
"
,
_MBS_ERR_MOD_LOAD
);
return
NULL
;
}
free_ivec_1
(
user_model_list_c
);
free_ivec_1
(
user_model_list_mbs
);
...
...
@@ -762,8 +797,8 @@ MbsData* mbs_info_to_data(MbsInfos* mbs_infos, MbsData* s)
{
mbs_msg
(
">>LOAD>> Error while fetching user_IO number
\n
"
);
mbs_msg
(
"
\n
>>LOAD>> Please Re-generated your user_IO Files !!!
\n\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_load_with_loader
\n
"
,
-
900
);
exit
(
1
)
;
mbs_msg
(
"[%d] in mbs_load_with_loader
\n
"
,
_MBS_ERR_MOD_LOAD
);
return
NULL
;
}
if
(
s
->
n_user_IO
)
{
...
...
MBsysC/mbs_common/mbs_load_xml/mbs_xml_binder.c
View file @
088a8c4a
...
...
@@ -2,6 +2,8 @@
#include "mbs_xml_binder_private.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
/////////////////////////////////////////
/// GET functions ///////////////////////
...
...
@@ -1449,9 +1451,8 @@ int mbs_info_mbsDescR7_binder(MbsInfos *mbs_infos, xmlNodePtr node, int mission)
mbs_msg
(
">>LOAD>> Error during xmlParseFile function
\n
"
);
mbs_msg
(
">>LOAD>> MDS_mbs_reader : Empty XML document
\n
"
);
mbs_msg
(
">>LOAD>> Check your files names and paths
\n\n
"
);
mbs_error_msg
(
"[%d] in MDS_mbs_reader !!
\n
"
,
-
909
);
exit
(
1
);
return
0
;
mbs_msg
(
"[%d] in MDS_mbs_reader !!
\n
"
,
_MBS_ERR_LOW_FILES
);
return
_MBS_ERR_LOW_FILES
;
}
cur_node
=
node
->
children
;
...
...
@@ -1747,6 +1748,7 @@ int mbs_info_init_and_binder(MbsInfos *mbs_infos, const char *mbs_xml_name, int
{
xmlDocPtr
doc
;
xmlNodePtr
root
;
int
err
=
0
;
// xml document opening
xmlKeepBlanksDefault
(
0
);
// Ignore les noeuds texte composant la mise en forme
...
...
@@ -1755,22 +1757,29 @@ int mbs_info_init_and_binder(MbsInfos *mbs_infos, const char *mbs_xml_name, int
mbs_msg
(
">>LOAD>> Error during xmlParseFile function
\n
"
);
mbs_msg
(
">>LOAD>> mbs_info_init_and_binder : Invalid XML document
\n
"
);
mbs_msg
(
">>LOAD>> Check your files names and paths
\n\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_info_init_and_binder !!
\n
"
,
-
909
);
return
-
1
;
mbs_msg
(
"[%d] in mbs_info_init_and_binder !!
\n
"
,
_MBS_ERR_LOW_FILES
);
return
_MBS_ERR_LOW_FILES
;
}
// getting the root
root
=
xmlDocGetRootElement
(
doc
);
if
(
root
==
NULL
)
{
xmlFreeDoc
(
doc
);
mbs_msg
(
">>LOAD>> Error during xmlParseFile function
\n
"
);
mbs_msg
(
">>LOAD>> mbs_info_init_and_binder : Empty XML document
\n
"
);
mbs_msg
(
">>LOAD>> Check your files names and paths
\n\n
"
);
mbs_error_msg
(
"[%d] in mbs_info_init_and_binder !!
\n
"
,
-
909
);
return
-
1
;
mbs_msg
(
"[%d] in mbs_info_init_and_binder !!
\n
"
,
_MBS_ERR_LOW_FILES
);
xmlFreeDoc
(
doc
);
xmlCleanupParser
();
return
_MBS_ERR_LOW_FILES
;
}
mbs_info_mbsDescR7_binder
(
mbs_infos
,
root
,
mission
);
err
=
mbs_info_mbsDescR7_binder
(
mbs_infos
,
root
,
mission
);
if
(
err
<
0
)
{
mbs_msg
(
">>LOAD>> Error during mbs_info_mbsDescR7_binder function
\n
"
);
xmlFreeDoc
(
doc
);
xmlCleanupParser
();
return
err
;
}
if
(
mission
==
MBS_INFO_UPDATER
)
{
xmlSaveFormatFile
(
"updated_prject.mbs"
,
doc
,
1
);
...
...
@@ -1810,7 +1819,7 @@ int mbs_info_updater(MbsInfos *mbs_infos, const char *mbs_xml_name)
err
=
mbs_info_init_and_binder
(
mbs_infos
,
mbs_xml_name
,
MBS_INFO_UPDATER
);
if
(
err
<
0
){
mbs_msg
(
">>LOAD>> Error during function mbs_info_updater.
\n
"
);
return
-
1
;
return
err
;
}
return
MBS_INFO_SUCCESS
;
...
...
MBsysC/mbs_common/mbs_module/MBSfun.h
View file @
088a8c4a
...
...
@@ -24,6 +24,15 @@
int
dirdynared
(
MbsAux
*
mbs_aux
,
MbsData
*
s
);
/**
* \brief Compute the required forces ont the actuated joints in a configuration
*
* \param[in,out] mbs_aux the local computation structure, where the result is stored in the variable Mr.
* \param[in,out] s the MbsData of the system, where q(iqv),qd(iqv) and qdd(iqv) are updated.
*
* \return Error status, <0 in case of failure.
*/
int
invdynared
(
MbsAux
*
mbs_aux
,
MbsData
*
s
);
/**
...
...
@@ -31,8 +40,8 @@ int invdynared(MbsAux *mbs_aux, MbsData *s);
* necessary for
* - the state space representation (computation of A) and then the modal analysis.
*
* \p[in,out] mbs_aux the local computation structure, where the result is stored in the variable Mr.
* \p[in,out] s the MbsData of the system, where q(iqv),qd(iqv) and qdd(iqv) are updated.
* \p
aram
[in,out] mbs_aux the local computation structure, where the result is stored in the variable Mr.
* \p
aram
[in,out] s the MbsData of the system, where q(iqv),qd(iqv) and qdd(iqv) are updated.
*/
int
mbs_Mred
(
MbsAux
*
mbs_aux
,
MbsData
*
s
);
...
...
@@ -42,20 +51,24 @@ int mbs_Mred(MbsAux *mbs_aux, MbsData *s);
* - equilibrium (even with non zero acceleration)
* - linearization of MBS: obtention of Gr Kr around a given configuration (*) [not necessarely an equilibrium]
*
* \p[in,out] mbs_aux the local computation structure, where the result Rred is stored.
* \p[in,out] s the MbsData of the system, where q(iqv),qd(iqv) and qdd(iqv) are updated.
* \param[in,out] mbs_aux the local computation structure, where the result Rred is stored.
* \param[in,out] s the MbsData of the system, where q(iqv),qd(iqv) and qdd(iqv) are updated.
*
* \return Error status, <0 in case of failure.
*/
int
mbs_Rred
(
MbsAux
*
mbs_aux
,
MbsData
*
s
);
/**
* \brief Compute the residual force on independant joints and required force in driven joints.
.
* \brief Compute the residual force on independant joints and required force in driven joints.
*
* This function is the computationnal core of Rred and Invdynared computations.
* This function assumes that all independent joints and all driven joints are
* up-to-date (coordinates, velocities and accelerations).
*
* \p[in,out] mbs_aux the local computation structure, where the result Rred and Qc are stored.
* \p[in,out] s the MbsData of the system, where q[qv], qd[qv], qdd[qv] and Qc are updated.
* \param[in,out] mbs_aux the local computation structure, where the result Rred and Qc are stored.
* \param[in,out] s the MbsData of the system, where q[qv], qd[qv], qdd[qv] and Qc are updated.
*
* \return Error status, <0 in case of failure.
*/
int
mbs_Rred_core
(
MbsAux
*
mbs_aux
,
MbsData
*
s
);
...
...
MBsysC/mbs_common/mbs_module/mbs_Rred.c
View file @
088a8c4a
...
...
@@ -8,6 +8,7 @@
//
//
#include "mbs_errors_names.h"
#include "MBSfun.h"
#include "math.h"
#include "nrfct.h"
...
...
@@ -26,6 +27,7 @@ int mbs_Rred(MbsAux *mbs_aux, MbsData *s)
}
err
=
mbs_Rred_core
(
mbs_aux
,
s
);
return
err
;
}
...
...
@@ -115,8 +117,10 @@ int mbs_Rred_core(MbsAux *mbs_aux, MbsData *s) {
{
if
(
isnan
(
mbs_aux
->
Rred
[
i
]))
{
err
=
_MBS_ERR_MID_RRED
+
_MBS_ERR_LOW_NAN
;
mbs_msg
(
"
\t
>RRED> Rred[%d] is Not a number (Nan)
\n
"
,
s
->
qu
[
i
]);
return
-
87
;
return
(
err
)
;
}
}
...
...
@@ -139,11 +143,13 @@ int mbs_Rred_core(MbsAux *mbs_aux, MbsData *s) {
}
}
// compute lambda
ludcmp
(
mbs_aux
->
Jvt
,
s
->
nqv
,
mbs_aux
->
ind_Jvt
,
&
d
);
err
=
ludcmp
(
mbs_aux
->
Jvt
,
s
->
nqv
,
mbs_aux
->
ind_Jvt
,
&
d
);
if
(
err
<
0
)
// Error management
{
err
+=
_MBS_ERR_MID_RRED
;
mbs_msg
(
"
\t
>RRED> Error in Rred during LU decomposition of Jv matrix for lambda computation
\n
"
);
return
(
-
80
+
err
);
return
(
err
);
}
lubksb
(
mbs_aux
->
Jvt
,
s
->
nqv
,
mbs_aux
->
ind_Jvt
,
mbs_aux
->
Jvtlambda
);
...
...
MBsysC/mbs_common/mbs_module/mbs_aux.c
View file @
088a8c4a
...
...
@@ -47,7 +47,7 @@ MbsAux * initMbsAux(MbsData *s)
if
(
nquc
!=
njoint
-
Ncons
)
{
mbs_error_msg
(
"nquc (%d) != njoint-Ncons (%d-%d=%d)"
,
nquc
,
njoint
,
Ncons
,
njoint
-
Ncons
);
exit
(
1
);
exit
(
EXIT_FAILURE
);
}
#endif
...
...
MBsysC/mbs_common/mbs_module/mbs_close_loops.c
View file @
088a8c4a
...
...
@@ -11,6 +11,7 @@
// 01/10/2008 : JFC : Bug n°40
//
#include "mbs_errors_names.h"
#include "MBSfun.h"
#include "nrfct.h"
#include "mbs_project_interface.h"
...
...
@@ -39,18 +40,23 @@ int mbs_close_geo(MbsData *s, MbsAux *mbs_aux)
{
err
=
mbs_step_close_geo
(
s
,
mbs_aux
);
if
(
err
<
0
)
{
err
+=
_MBS_ERR_MID_CLOSE_GEO
;
mbs_msg
(
"
\t
\t
>CLOSE GEO> Error in mbs_close_geo during a NR iteration
\n
"
);
return
-
50
+
err
;
return
err
;
}
}
if
(
iter
>=
mbs_aux
->
MAX_NR_ITER
)
// Error management
{
err
=
_MBS_ERR_MID_CLOSE_GEO
;
mbs_msg
(
"
\t
\t
>CLOSE GEO> Impossible to close the geometry after %d iterations
\n
"
,
iter
);
if
(
mbs_aux
->
close_anim
)
{
mbs_anim_close_geo
(
s
,
mbs_aux
);
}
return
-
50
;
return
err
;
}
return
iter
;
...
...
MBsysC/mbs_common/mbs_module/mbs_dirdyn.c
View file @
088a8c4a
...
...
@@ -23,6 +23,7 @@
#include "set_output.h"
#include "MBSfun.h"
#include "mbs_check.h"
#include "mbs_errors_names.h"
#include "mbs_message.h"
...
...
@@ -161,22 +162,36 @@ int mbs_run_dirdyn(MbsDirdyn* dd, MbsData* mbs_data)
// - - - - - - - - - - - - - -
err
=
mbs_dirdyn_init
(
dd
,
mbs_data
);
if
(
err
<
0
){
return
-
1
;
// Freeing the buffers, without error catching
mbs_dirdyn_finish
(
dd
,
mbs_data
);
mbs_error_msg
(
"[%d] in mbs_run_dirdyn !!
\n
"
,
_MBS_ERR_MOD_DIRDYN
+
err
);
return
_MBS_ERR_MOD_DIRDYN
+
err
;
}
// 2. Run the simulation
// - - - - - - - - - - -
err
=
mbs_dirdyn_loop
(
dd
,
mbs_data
);
if
(
err
<
0
){
return
-
1
;
// Freeing the buffers, without error catching
mbs_dirdyn_finish
(
dd
,
mbs_data
);
mbs_error_msg
(
"[%d] in mbs_run_dirdyn !!
\n
"
,
_MBS_ERR_MOD_DIRDYN
+
err
);
return
_MBS_ERR_MOD_DIRDYN
+
err
;
}
// 3. Finish the simulation
// - - - - - - - - - - - -
mbs_dirdyn_finish
(
dd
,
mbs_data
);
err
=
mbs_dirdyn_finish
(
dd
,
mbs_data
);
if
(
err
<
0
)
{
mbs_error_msg
(
"[%d] in mbs_run_dirdyn !!
\n
"
,
_MBS_ERR_MOD_DIRDYN
+
err
);
return
_MBS_ERR_MOD_DIRDYN
+
err
;
}
if
(
dd
->
options
->
verbose
)
{
mbs_msg
(
"
\n
>>DIRDYN>> Direct dynamics analysis finished.
\n
"
);
}
return
0
;
return
err
;
}
int
mbs_dirdyn_save
(
MbsDirdyn
*
dd
,
MbsData
*
mbs_data
,
double
t
)
{
...
...
@@ -195,9 +210,8 @@ int mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t) {
{
mbs_msg
(
">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****
\n
"
);
mbs_msg
(
">>DIRDYN>> ***** during buffer save *****
\n
"
);
mbs_msg
(
">>DIRDYN>>
\n
"
);
mbs_error_msg
(
"[%d] in mbs_fct_dirdyn !!
\n
"
,
-
400
+
err
);
return
-
400
+
err
;
mbs_msg
(
"[%d] in mbs_dirdyn_save !!
\n
"
,
err
);
return
err
;
}
err
=
mbs_growing_buffer_save
(
dd
->
user_buffer
,
t
);
...
...
@@ -206,9 +220,8 @@ int mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t) {
{
mbs_msg
(
">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****
\n
"
);
mbs_msg
(
">>DIRDYN>> ***** during growing buffer save *****
\n
"
);
mbs_msg
(
">>DIRDYN>>
\n
"
);
mbs_error_msg
(
"[%d] in mbs_fct_dirdyn !!
\n
"
,
-
400
+
err
);
return
-
400
+
err
;
mbs_msg
(
"[%d] in mbs_dirdyn_save !!
\n
"
,
err
);
return
err
;
}
if
(
dd
->
options
->
save_visu
)
...
...
@@ -228,8 +241,8 @@ int mbs_dirdyn_save(MbsDirdyn* dd, MbsData *mbs_data, double t) {
mbs_msg
(
">>DIRDYN>> ***** mbs_dirdyn_save : impossible to save the files *****
\n
"
);
mbs_msg
(
">>DIRDYN>> ***** during growing buffer save *****
\n
"
);
mbs_msg
(
">>DIRDYN>> in the REAL-TIME process
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_
fct_
dirdyn !!
\n
"
,
-
400
+
err
);
exit
(
1
)
;
mbs_msg
(
"[%d] in mbs_dirdyn
_save
!!
\n
"
,
err
);
return
err
;
}
#endif
}
...
...
@@ -255,8 +268,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
err
=
mbs_check_mbs_data_values
(
dd
->
mbs_aux
,
mbs_data
);
if
(
err
<
0
)
{
mbs_msg
(
"
\t
>Dirdyn> Incoherences detected during module initialization! (See message above)
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
-
400
);
return
-
400
;
mbs_msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
err
);
return
err
;
}
// Check the usefulness of dirdyn
...
...
@@ -265,8 +278,9 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
{
mbs_msg
(
"
\t
>Dirdyn> If no independant nor driven joints are present, the direct dynamic process has no reason to be used !
\n
"
);
mbs_msg
(
"
\t
>Dirdyn> Irrelevant process !
\n
"
);
mbs_error_msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
-
410
);
return
-
410
;
err
=
_MBS_ERR_MOD_SPEC_11
;
mbs_msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
err
);
return
err
;
}
else
if
(
mbs_data
->
nqu
==
0
)
{
...
...
@@ -279,9 +293,9 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
// Checking constraints and dependant variable coherence
err
=
mbs_check_nhu_nqv
(
mbs_data
);
if
(
err
<
0
)
{
mbs_msg
(
"
\t
>Dirdyn> Inc
h
oherence detected during module initialization!
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
-
400
);
return
-
400
;
mbs_msg
(
"
\t
>Dirdyn> Incoherence detected during module initialization!
\n
"
);
mbs_msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
err
);
return
err
;
}
// Set the selected integrator
set_integrator
(
dd
);
...
...
@@ -312,16 +326,21 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
if
(
dd
->
options
->
realtime
)
{
mbs_realtime_reset
();
mbs_realtime_init
(
mbs_data
,
dd
->
options
->
t0
,
dd
->
options
->
tf
,
dd
->
options
->
dt0
);
err
=
mbs_realtime_init
(
mbs_data
,
dd
->
options
->
t0
,
dd
->
options
->
tf
,
dd
->
options
->
dt0
);
if
(
err
<
0
)
{
mbs_msg
(
"
\t
>Real-time> error during activation !
\n
"
);
mbs_msg
(
"[%d] in mbs_dirdyn_init, shutting down the process !!
\n
"
,
err
);
return
err
;
}
}
#else
if
(
dd
->
options
->
realtime
)
{
user_dirdyn_finish
(
mbs_data
,
dd
);
err
=
_MBS_ERR_INIT
;
mbs_msg
(
"
\t
>Real-time> To use the real-time features (mbs_dirdyn->options->realtime activated), set the CMake flag 'FLAG_REAL_TIME' to ON !
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
-
410
);
return
-
410
;
mbs_msg
(
"[%d] in mbs_dirdyn_init
, shutting down the process
!!
\n
"
,
err
);
return
err
;
}
#endif
...
...
@@ -502,6 +521,20 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
sprintf
(
f_anim
,
"%s/%s_%s.anim"
,
animpath
,
resfilename
,
fnameSuffix
[
bufId
]);
dd
->
buffers
[
bufId
]
=
mbs_new_buffer
(
f
,
f_anim
,
bufElemNb
[
bufId
],
dd
->
options
->
buffersize
,
bufferIDs
[
bufId
],
dd
->
options
->
save_anim
,
dd
->
options
->
save_visu
,
1
.
/
(
double
)
dd
->
options
->
framerate
);
if
(
dd
->
buffers
[
bufId
]
==
NULL
)
{
free
(
f
);
free
(
f_anim
);
free
(
respath
);
free
(
animpath
);
free
(
fnameSuffix
);
free
(
bufferIDs
);
free
(
bufElemNb
);
mbs_msg
(
"
\t
>Dirdyn> Error during buffer visu initialization num %d!
\n
"
,
i
);
mbs_msg
(
"[%d] in mbs_dirdyn_init !!
\n
"
,
_MBS_ERR_MOD_SPEC_11
);
return
_MBS_ERR_MOD_SPEC_11
;
}
}
if
(
dd
->
options
->
save_visu
)
...
...
@@ -509,18 +542,34 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
#ifdef VISU_3D
if
(
!
dd
->
options
->
realtime
)
{
free
(
f
);
free
(
f_anim
);
free
(
respath
);
free
(
animpath
);
free
(
fnameSuffix
);
free
(
bufferIDs
);
free
(
bufElemNb
);
mbs_msg
(
"
\t
>Real-time> Error: real-time features must be activated to set 'save_visu' to 1 !
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_dirdyn_init
!!
\n
"
,
-
410
);
exit
(
1
)
;
mbs_msg
(
"[%d] in mbs_dirdyn_init
, shutting down the process !!
\n
"
,
_MBS_ERR_INIT
);
return
_MBS_ERR_INIT
;
}
realtime
=
(
Simu_realtime
*
)
mbs_data
->
realtime
;
if
(
!
realtime
->
options
->
flag_visu
)
{
free
(
f
);
free
(
f_anim
);
free
(
respath
);
free
(
animpath
);
free
(
fnameSuffix
);
free
(
bufferIDs
);
free
(
bufElemNb
);
mbs_msg
(
"
\t
>Real-time> Error: flag_visu must be set to 1 to set 'save_value' to 1 !
\n
"
);
mbs_
error_
msg
(
"[%d] in mbs_dirdyn_init
!!
\n
"
,
-
410
);
exit
(
1
)
;
mbs_msg
(
"[%d] in mbs_dirdyn_init
, shutting down the process !!
\n
"
,
_MBS_ERR_INIT
);
return
_MBS_ERR_INIT
;
}
visu
=
realtime
->
ext
->
visu
;
...
...
@@ -532,11 +581,23 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
sprintf
(
f_anim
,
"%s/visu_%d_q.anim"
,
animpath
,
i
);
dd
->
buffer_visu
[
i
]
=
mbs_new_buffer
(
f
,
f_anim
,
visu
->
nb_q
[
i
],
dd
->
options
->
buffersize
,
BUFFER_VISU
,
dd
->
options
->
save_anim
,
dd
->
options
->
save_visu
,
1
.
/
(
double
)
dd
->
options
->
framerate
);
if
(
dd
->
buffer_visu
[
i
]
==
NULL
)
{
free
(
f
);
free
(
f_anim
);
free
(
respath
);
free
(
animpath
);
free
(
fnameSuffix
);
free
(
bufferIDs
);
free
(
bufElemNb
);
mbs_msg
(
"
\t
>Dirdyn> [REAL-TIME] Error during buffer visu initialization num %d!
\n
"
,
i
);
mbs_msg
(
"[%d] in mbs_dirdyn_init, shutting down the process !!
\n
"
,
_MBS_ERR_MOD_SPEC_11
);
return
_MBS_ERR_MOD_SPEC_11
;
}
}
#else
user_dirdyn_finish
(
mbs_data
,
dd
);
free
(
f
);
free
(
f_anim
);
free
(
respath
);
...
...
@@ -546,8 +607,8 @@ int mbs_dirdyn_init(MbsDirdyn* dd, MbsData* mbs_data)
free
(