Commit 9be600a8 authored by Olivier Lantsoght's avatar Olivier Lantsoght
Browse files

Merge dev before to avoid problem after

parents 7d000a6a 78b363c7
......@@ -591,6 +591,24 @@ issue_163:
only:
- release_test
issue_170_User_Model:
image: robotran/ubuntu18-robotran-opengl:v1
stage: test_Issues
allow_failure: false
dependencies:
- MBsysC_realtimeON
script:
- mkdir TestProjects/Issue_170/workR/build
- cd TestProjects/Issue_170/workR/build
- cmake -DFLAG_SEPARATE_BUILD=OFF ..
- make
- ./exe_Issue_170
- cmake -DFLAG_SEPARATE_BUILD=ON .
- make
- ./exe_Issue_170
only:
- release_test
# --------------------------------------------------------------------------
# Generating Doxygen documentation (directly available on Gitlab pages)
......
......@@ -33,6 +33,10 @@ if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-comment -Wno-unused-result ")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-comment -Wextra -Wno-unused-value -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-result -Wno-unused-function -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-comment -Wno-unused-value -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-result -Wno-maybe-uninitialized -Wno-unused-function -Wno-strict-aliasing -Wno-unused-parameter")
if (APPLE)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-unused-const-variable -Wno-uninitialized -Wno-unknown-warning-option")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-unused-const-variable -Wno-uninitialized -Wno-unknown-warning-option")
endif()
endif()
if(CMAKE_BUILD_TYPE) # User specify build type with -DCMAKE_BUILD_TYPE=X
......
......@@ -1023,9 +1023,10 @@ int mbs_info_links_binder(MbsInfoLinks *mbs_info_links, xmlNodePtr node, int mis
int mbs_info_parameter_binder(MbsInfoParameter *mbs_info_parameter, xmlNodePtr node, int mission)
{
int i;
int ind_value = 0;
int ind_value = 0;
xmlNodePtr cur_node = node->children;
xmlChar* elementValue = NULL;
char* elementString = NULL;
if (mission == MBS_INFO_READER)
{
......@@ -1055,7 +1056,7 @@ int mbs_info_parameter_binder(MbsInfoParameter *mbs_info_parameter, xmlNodePtr n
{
mbs_info_parameter->type = 3;
}
else if(!strcmp((const char*)elementValue,"lut3D"))
else if(!strcmp((const char*)elementValue,"lut2D"))
{
mbs_info_parameter->type = 4;
}
......@@ -1063,6 +1064,18 @@ int mbs_info_parameter_binder(MbsInfoParameter *mbs_info_parameter, xmlNodePtr n
{
mbs_info_parameter->type = 5;
}
else if(!strcmp((const char*)elementValue,"structure"))
{
mbs_info_parameter->type = 6;
}
else if(!strcmp((const char*)elementValue,"integer"))
{
mbs_info_parameter->type = 7;
}
else
{
mbs_warning_msg("Unknows user model parameter type: '%s'.\n", elementValue);
}
xmlFree(elementValue);
}
else if(!strcmp((const char*)cur_node->name,"value"))
......@@ -1077,7 +1090,79 @@ int mbs_info_parameter_binder(MbsInfoParameter *mbs_info_parameter, xmlNodePtr n
set_double_xlm_node(cur_node, mbs_info_parameter->value_list[ind_value]);
}
ind_value++;
}
}
else if(!strcmp((const char*)cur_node->name,"lutfile"))
{
if (mission == MBS_INFO_READER)
{
elementString = get_string_xml_node(cur_node);
if (elementString != NULL){
if (strncmp((const char*)elementString, "PRJPATH", 7)){
mbs_info_parameter->structure_lutfile = strdup((char*)elementString);
}
else{
mbs_info_parameter->flag_PRJPATH = 1;
mbs_info_parameter->structure_lutfile = strdup((char*)elementString+7);
}
}
else{
mbs_info_parameter->structure_lutfile = strdup("");
}
free(elementString);
}
else if (mission == MBS_INFO_UPDATER)
{
mbs_warning_msg("Function 'mbs_info_parameter_binder' does not handle the 'updating mission' on lutfile name.\n");
}
}
else if(!strcmp((const char*)cur_node->name,"structure"))
{
if (mission == MBS_INFO_READER)
{
elementString = get_string_xml_node(cur_node);
if (elementString != NULL){
mbs_info_parameter->structure_name = strdup((char*)elementString);
}
else{
mbs_info_parameter->structure_name = strdup("");
}
free(elementString);
}
else if (mission == MBS_INFO_UPDATER)
{
mbs_warning_msg("Function 'mbs_info_parameter_binder' does not handle the 'updating mission' on lutfile name.\n");
}
}
else if(!strcmp((const char*)cur_node->name,"header"))
{
if (mission == MBS_INFO_READER)
{
elementString = get_string_xml_node(cur_node);
if (elementString != NULL){
mbs_info_parameter->structure_header = strdup((char*)elementString);
}
else{
mbs_info_parameter->structure_header = strdup("");
}
free(elementString);
}
else if (mission == MBS_INFO_UPDATER)
{
mbs_warning_msg("Function 'mbs_info_parameter_binder' does not handle the 'updating mission' on lutfile name.\n");
}
}
else if(!strcmp((const char*)cur_node->name,"name") && mission == MBS_INFO_INIT)
{
;
}
else if(!strcmp((const char*)cur_node->name,"type") && mission == MBS_INFO_INIT)
{
;
}
else
{
mbs_warning_msg("Unknow node name in function 'mbs_info_parameter_binder': '%s'\n", (const char*)cur_node->name);
}
}
cur_node = cur_node->next;
}
......
......@@ -29,17 +29,17 @@
#define MAX_NB_BUFFER (3 + 1) // maximal number of buffer 3 for equilibrium, 1 for q (animation)
MbsEquil* mbs_new_equil(MbsData* mbs_data)
MbsEquil* mbs_new_equil(MbsData* s)
{
MbsAux* mbs_aux;
// Initialize the local data struct
mbs_aux = initMbsAux(mbs_data);
mbs_aux = initMbsAux(s);
return mbs_new_equil_aux(mbs_data, mbs_aux);
return mbs_new_equil_aux(s, mbs_aux);
}
MbsEquil* mbs_new_equil_aux(MbsData* mbs_data, MbsAux* mbs_aux)
MbsEquil* mbs_new_equil_aux(MbsData* s, MbsAux* mbs_aux)
{
MbsEquil *equil;
MbsEquilOptions *opts;
......@@ -69,6 +69,8 @@ MbsEquil* mbs_new_equil_aux(MbsData* mbs_data, MbsAux* mbs_aux)
equil->success = 0;
equil->Nux_saved = s->Nux;
// Initialize the options struct with default options
opts = (MbsEquilOptions*)malloc(sizeof(MbsEquilOptions));
opts->method = 1;
......@@ -119,7 +121,7 @@ MbsEquil* mbs_new_equil_aux(MbsData* mbs_data, MbsAux* mbs_aux)
return equil;
}
void mbs_delete_equil(MbsEquil* eq, MbsData* mbs_data)
void mbs_delete_equil(MbsEquil* eq, MbsData* s)
{
if (eq != NULL)
{
......@@ -132,8 +134,8 @@ void mbs_delete_equil(MbsEquil* eq, MbsData* mbs_data)
free_ivec_0(eq->xns);
// 5. Linearization and gradient variables
if (mbs_data->nqu > 0) { free_dmat_0(eq->grad_Rr); }
if (eq->options->compute_uxd==1 && mbs_data->Nux > 0) { free_dmat_0(eq->grad_uxd); }
if (s->nqu > 0) { free_dmat_0(eq->grad_Rr); }
if (eq->options->compute_uxd==1 && s->Nux > 0) { free_dmat_0(eq->grad_uxd); }
if (eq->nxe > 0) { free_dmat_0(eq->grad_fxe); }
free_dmat_0(eq->grad);
if (eq->options->grad_lpk == 1)
......@@ -157,24 +159,24 @@ void mbs_delete_equil(MbsEquil* eq, MbsData* mbs_data)
free(eq->options);
//-------
freeMbsAux(eq->aux, mbs_data);
freeMbsAux(eq->aux, s);
free(eq);
}
}
void mbs_run_equil(MbsEquil* eq, MbsData* mbs_data)
void mbs_run_equil(MbsEquil* eq, MbsData* s)
{
// 1. Initialize the simulation
// - - - - - - - - - - - - - -
mbs_equil_init(eq, mbs_data);
mbs_equil_init(eq, s);
// 2. Run the simulation
// - - - - - - - - - - -
mbs_equil_loop(eq, mbs_data); // another name might be more appropriate ??Q
mbs_equil_loop(eq, s); // another name might be more appropriate ??Q
// 3. Finish the simulation
// - - - - - - - - - - - -
mbs_equil_finish(eq, mbs_data);
mbs_equil_finish(eq, s);
}
int mbs_equil_save(MbsEquil* eq, MbsData *s, int iter)
......
......@@ -41,7 +41,6 @@ int mbs_compute_kalmanDcpt(MbsSS *ss, MbsSS *sskal, double **T, int *nxc_ptr)
double **uj, **sj, **vj,**p, **ujp, **ujt, **bb;
double **abxy, **ujtajn1;
double **aj, **bj;
double **qj, **ptjn1qj;
double **TA;
......@@ -178,4 +177,5 @@ int mbs_compute_kalmanDcpt(MbsSS *ss, MbsSS *sskal, double **T, int *nxc_ptr)
free_dmat_0(TA);
free_ivec_0(k);
return 0;
}
......@@ -23,14 +23,14 @@
#include "mbs_message.h"
#include "mbs_check.h"
MbsModal* mbs_new_modal(MbsData* mbs_data)
MbsModal* mbs_new_modal(MbsData* s)
{
MbsAux* mbs_aux;
// Initialize the local data struct
mbs_aux = initMbsAux(mbs_data);
mbs_aux = initMbsAux(s);
return mbs_new_modal_aux(mbs_data, mbs_aux);
return mbs_new_modal_aux(s, mbs_aux);
}
MbsModal* mbs_new_modal_aux(MbsData* s, MbsAux* mbs_aux)
......@@ -74,6 +74,8 @@ MbsModal* mbs_new_modal_aux(MbsData* s, MbsAux* mbs_aux)
opts->anim_t = 2;
mo->options = opts;
mo->Nux_saved = s->Nux;
return mo;
}
......@@ -108,10 +110,15 @@ void mbs_modal_init(MbsModal *mo, MbsData *s)
mbs_error_msg("[%d] in mbs_modal_init !! \n", -300);
}
// 0.2 Initialize the Lpk and SS structure
if (mo->options->compute_uxd==0 && s->Nux > 0 && mo->options->verbose == 1)
// 0. Initialize the Lpk and SS structure
if (mo->options->compute_uxd==0 && s->Nux > 0)
{
mbs_warning_msg(">>MODAL>> The uxd equations are not computed, check the option 'compute_uxd' \n ");
if (mo->options->verbose)
{
mbs_warning_msg(">>MODAL>> The uxd equations are not used for the modal analysis, check the option 'compute_uxd' \n");
}
mo->Nux_saved = s->Nux;
s->Nux = 0;
}
mo->lpk = mbs_new_lpk(s, MAX(s->nqu, s->Nux), MAX(s->nqu, s->Nux)); // voluntarily oversized (in order to avoid extra lpk structure)
......@@ -573,6 +580,10 @@ void mbs_modal_finish(MbsModal *mo, MbsData *s)
free(respath);
free(animpath);
if (mo->options->compute_uxd == 0 && s->Nux == 0)
{
s->Nux = mo->Nux_saved;
}
if (mo->options->verbose)
{
......
......@@ -87,6 +87,8 @@ typedef struct MbsModal
double *qdd_saved; ///< copy of vector qdd before the modal process.
double *Qq_saved; ///< copy of vector Qq before the modal process.
int Nux_saved; ///< copy of mbs_data Nux
int nx; ///< number of 1st order equations, nx = 2*nqu (+Nux)
double *eval_a; ///< Result of the Eigenvalue problem: real part of the nx eigen values [nx]
......
......@@ -49,8 +49,6 @@ MbsLut1Dvec* mbs_lut_1Dvec_alloc(int nx, int n)
MbsLut2Dvec* mbs_lut_2Dvec_alloc(int nx, int ny, int n)
{
int i, j;
MbsLut2Dvec *newlut;
newlut = (MbsLut2Dvec*)malloc(sizeof(MbsLut2Dvec));
newlut->nx = nx;
......@@ -75,14 +73,10 @@ void mbs_lut_2D_free(MbsLut2D *lut)
{
int i;
free(lut->x);
free(lut->y);
for(i=1;i<=lut->nx;i++)
{
free(lut->z[i]);
}
free(lut->z);
free_dvec_1(lut->x);
free_dvec_1(lut->y);
free_dmat_1(lut->z);
free(lut);
}
......@@ -102,7 +96,6 @@ void mbs_lut_1Dvec_free(MbsLut1Dvec *lut)
void mbs_lut_2Dvec_free(MbsLut2Dvec *lut)
{
int i, j;
free_dvec_0(lut->x);
free_dvec_0(lut->y);
free_d3Darray_0(lut->mat_output);
......@@ -367,7 +360,6 @@ int mbs_lut_2Dvec_interp(MbsLut2Dvec *lut, double x, double y, double *output)
int indx, indy;
int step, min, max;
double alpha, beta, gamma, zeta;
double z;
/* x-search */
min = 0;
......@@ -596,7 +588,7 @@ MbsLut1D* mbs_lut_1D_load_file(char* fileName)
flut = fopen(fileName,"r");
if(flut==0){
mbs_msg("\t>LOOK UP TABLE> Error in mbs_lut_1D_load_file.\n");
mbs_msg("\t> > Impossible to find the file %s.", fileName );
mbs_msg("\t> > Impossible to find the file %s.\n", fileName );
mbs_error_msg("In Look up table loading file, shuting down the process.\n");
}
......@@ -647,12 +639,9 @@ MbsLut2D* mbs_lut_2D_load_file(char* fileName)
lineChk = fgets(line,256, flut); // read the number of elements
sscanf(line,"%d %d",&lut->nx, &lut->ny); // save the number of elements
lut->x=calloc(lut->nx+1,sizeof(double)); // table memory allocation
lut->y=calloc(lut->ny+1,sizeof(double)); // table memory allocation
lut->z=calloc(lut->nx+1,sizeof(double*)); // table memory allocation
lut->x[0] = 0;
lut->y[0] = 0;
lut->x=get_dvec_1(lut->nx); // table memory allocation
lut->y=get_dvec_1(lut->ny); // table memory allocation
lut->z=get_dmat_1(lut->nx, lut->ny); // table memory allocation
// read the y vector
for(j=1;j<=lut->ny;j++){
......@@ -663,7 +652,6 @@ MbsLut2D* mbs_lut_2D_load_file(char* fileName)
// read the x vector and the z matrix
for(i=1;i<=lut->nx;i++){
chk = fscanf(flut,"%lf", &lut->x[i] ); // 1st element = x[i]
lut->z[i] = (double*) calloc(lut->ny+1,sizeof(double));
for(j=1;j<=lut->ny;j++){
chk = fscanf(flut,"%lf", &lut->z[i][j] );
}
......
......@@ -680,7 +680,7 @@ double** get_contdmat_1(int x, int y)
double*** get_d3Darray_0(int x, int y, int z)
{
int i,j,k;
int i,j;
double ***array3D;
array3D = (double***)calloc(x, sizeof(double**));
......
......@@ -447,7 +447,7 @@ double** load_dmat_0(int x, int y, char *name);
* \param[in] mat the matrix to save, starting with index 0
* \param[in] x nb of rows
* \param[in] y nb of columns
* \param[in] name the path an name of the file in which saving the matrix
* \param[in] name the path and name of the file in which saving the matrix
*/
void save_dmat_0(double **mat, int x, int y, char *name);
......@@ -457,7 +457,7 @@ void save_dmat_0(double **mat, int x, int y, char *name);
* \param[in] mat the matrix to save, starting with index 0
* \param[in] x nb of rows
* \param[in] y nb of columns
* \param[in] name the path an name of the file in which saving the matrix
* \param[in] name the path and name of the file in which saving the matrix
* \param[in] format the chosen format.
*/
void save_format_dmat_0(double **mat, int x, int y, char *name, char *format);
......
......@@ -33,5 +33,9 @@ void mbs_delete_user_IO(UserIO *uvs)
free(uvs);
}
void mbs_get_user_IO_size(int *n_in, int *n_out, int *n_user_IO)
{
*n_in = 0;
*n_out = 0;
*n_user_IO = 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<mbsDescR7>
<mbsname>Issue_170</mbsname>
<mbsyspad_version>1.11.2</mbsyspad_version>
<base>
<!--this is the base body-->
<gravity>
<coordinates>
<x>0.1</x>
<y>0.0</y>
<z>0.0</z>
</coordinates>
</gravity>
<graphics>
<x2D>
<position>
<x>100.0</x>
<y>200.0</y>
</position>
</x2D>
<x3D />
</graphics>
</base>
<bodytree>
<!--this is the body tree-->
<body>
<bodyname>Body_0</bodyname>
<parent>
<bodyname>base</bodyname>
<pointname>origin</pointname>
</parent>
<joint>
<jointname>Joint_0</jointname>
<type>T1</type>
<nature>independent</nature>
<graphics>
<x2D>
<position>
<x>202.0</x>
<y>195.0</y>
</position>
</x2D>
<x3D>
<x3D_joint />
<x3D_frame />
</x3D>
</graphics>
</joint>
<mass>10.0</mass>
<graphics>
<x2D>
<position>
<x>-19.0</x>
<y>-44.0</y>
</position>
<name_pos>
<x>0.0</x>
<y>0.0</y>
</name_pos>
<shape>rectangle</shape>
<size>
<x>133.0</x>
<y>80.0</y>
</size>
<control_points>
<control_point>
<x>114.0</x>
<y>-44.0</y>
</control_point>
<control_point>
<x>114.0</x>
<y>36.0</y>
</control_point>
<control_point>
<x>-19.0</x>
<y>36.0</y>
</control_point>
<control_point>
<x>-19.0</x>
<y>-44.0</y>
</control_point>
</control_points>
<angle>0.0</angle>
</x2D>
<x3D>
<x3D_com />
<x3D_points />
<x3D_lines />
</x3D>
</graphics>
</body>
</bodytree>
<user_models>
<!--this is the userModel list-->
<user_model>
<name>lut</name>
<parameter>
<name>one_D</name>
<type>lut1D</type>
<lutfile>PRJPATH/userfctR/Lut1D.txt</lutfile>
</parameter>
<parameter>
<name>two_D</name>
<type>lut2D</type>
<lutfile>PRJPATH/userfctR/Lut2D.txt</lutfile>
</parameter>
</user_model>
<user_model>
<name>nb_values</name>
<parameter>
<name>vector</name>
<type>vector</type>
<value>1.0</value>
<value>1.1</value>
<value>1.2</value>
<value>-2.0</value>
</parameter>
<parameter>
<name>state_1</name>
<type>state</type>
<value>0.0</value>
<value>1.0</value>
<value>7.0</value>
</parameter>
<parameter>
<name>state_2</name>
<type>state</type>
<value>-2.1</value>
<value>2.2</value>
</parameter>
</user_model>
<user_model>
<name>scalar</name>
<parameter>
<name>real</name>
<type>scalar</type>
<value>13.4</value>
</parameter>
<parameter>
<name>integer_from_double</name>
<type>integer</type>
<value>2.35</value>
</parameter>
<parameter>
<name>integer</name>
<type>integer</type>
<value>17.0</value>
</parameter>
</user_model>
<user_model>
<name>structure</name>
<parameter>
<name>lut_res</name>
<type>structure</type>
<structure>MbsLutRes</structure>
<header>lut.h</header>
</parameter>
</user_model>
</user_models>
<x3D>
<background>
<!--This is the background properties-->
<color R="51" G="102" B="204" />
</background>
<shapeScaleFactors>
<!--This is the scale factors-->
<frame>0.2</frame>
<joint>0.3</joint>
<com>0.3</com>
<point>0.3</point>
</shapeScaleFactors>
<opengl>
<lightAndShadowMode>LIGHTS_NO_SPEC_SHADER</lightAndShadowMode>
<glfwSample>4</glfwSample>
</opengl>
<lights>