Commit 8c3979c9 authored by Nicolas Van der Noot's avatar Nicolas Van der Noot

mbsyscopy updated

parent c743bc43
......@@ -29,6 +29,9 @@ function(optionnal_modules_flags)
## -- Addons --##
# MBS-LMGC interaction
option (FLAG_ADDON_MBSLMGC "Including MBS-LMGC Addon" OFF)
## -- Application for generating user files --##
option (FLAG_APP_USERFILES "Application for generating project specific user files" ON)
endfunction()
......
......@@ -179,6 +179,9 @@ void mbs_print_user_models(MDS_gen_strct* gen, char *fileoutC, char *fileoutH)
fprintf(fidH," %s* %s;",gen->user_models->user_model_list[i]->parameter_list[j]->structure_name,gen->user_models->user_model_list[i]->parameter_list[j]->name);
fprintf(fidH," // pointer must be initialized and freed by the user\n");
break;
case 7: // integer
fprintf(fidH," int %s;\n",gen->user_models->user_model_list[i]->parameter_list[j]->name);
break;
}
}
fprintf(fidH," } %s;\n", gen->user_models->user_model_list[i]->name);
......@@ -205,6 +208,7 @@ void mbs_print_user_models(MDS_gen_strct* gen, char *fileoutC, char *fileoutH)
fprintf(fidC,"#include \"mbs_xml_reader.h\"\n");
fprintf(fidC,"#include \"mbs_load_xml.h\"\n");
fprintf(fidC,"#include \"useful_functions.h\"\n");
fprintf(fidC,"#include \"math.h\"\n");
fprintf(fidC,"\n");
fprintf(fidC,"// ============================================================ //\n\n");
fprintf(fidC,"\n");
......@@ -237,6 +241,8 @@ void mbs_print_user_models(MDS_gen_strct* gen, char *fileoutC, char *fileoutH)
fprintf(fidC," um->%s.%s = get_ivec_1(%d);\n",gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name,gen->user_models->user_model_list[i]->parameter_list[j]->n_value);
fprintf(fidC," um->%s.%s[0] = %d;\n",gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name,gen->user_models->user_model_list[i]->parameter_list[j]->n_value);
break;
case 7: //integer
fprintf(fidC," um->%s.%s = 0;\n",gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name);
}
}
fprintf(fidC," \n");
......@@ -274,6 +280,9 @@ void mbs_print_user_models(MDS_gen_strct* gen, char *fileoutC, char *fileoutH)
fprintf(fidC," free(um);\n");
fprintf(fidC,"}\n");
fprintf(fidC,"\n");
// mbs_load_user_model_xml
fprintf(fidC," void mbs_load_user_model_xml(MDS_gen_strct* gen, UserModel* um) \n");
fprintf(fidC,"{\n");
fprintf(fidC,"\n");
......@@ -293,7 +302,7 @@ void mbs_print_user_models(MDS_gen_strct* gen, char *fileoutC, char *fileoutH)
case 2:
fprintf(fidC," for(ind=0; ind<gen->user_models->user_model_list[%d]->parameter_list[%d]->n_value; ind++)\n",i,j);
fprintf(fidC," {\n");
fprintf(fidC," um->%s.%s[ind] = gen->user_models->user_model_list[%d]->parameter_list[%d]->value_list[ind];\n",gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name, i, j);
fprintf(fidC," um->%s.%s[ind+1] = gen->user_models->user_model_list[%d]->parameter_list[%d]->value_list[ind];\n",gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name, i, j);
fprintf(fidC," }\n");
break;
case 3:
......@@ -337,11 +346,81 @@ void mbs_print_user_models(MDS_gen_strct* gen, char *fileoutC, char *fileoutH)
fprintf(fidC," ind_state_value++;\n");
fprintf(fidC," }\n");
break;
case 7: //integer
fprintf(fidC," um->%s.%s = (int)lround(gen->user_models->user_model_list[%d]->parameter_list[%d]->value_list[0]);\n",gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name,i,j);
break;
}
}
fprintf(fidC," \n");
}
fprintf(fidC,"}\n");
// mbs_bind_user_model
fprintf(fidC,"\n");
fprintf(fidC," void mbs_bind_user_model(MDS_gen_strct* gen, UserModel* um) \n");
fprintf(fidC,"{\n");
fprintf(fidC,"\n");
fprintf(fidC,"\n");
for(i=0; i< gen->user_models->n_user_model; i++)
{
for(j=0; j< gen->user_models->user_model_list[i]->n_parameter; j++)
{
switch( gen->user_models->user_model_list[i]->parameter_list[j]->type)
{
case 1:
case 7:
fprintf(fidC," gen->user_models->user_model_list[%d]->parameter_list[%d]->val_ptr = &um->%s.%s;\n", i, j, gen->user_models->user_model_list[i]->name, gen->user_models->user_model_list[i]->parameter_list[j]->name);
break;
case 2:
case 3:
case 4:
case 5:
case 6:
fprintf(fidC," gen->user_models->user_model_list[%d]->parameter_list[%d]->val_ptr = um->%s.%s;\n", i, j, gen->user_models->user_model_list[i]->name , gen->user_models->user_model_list[i]->parameter_list[j]->name);
break;
}
}
fprintf(fidC," \n");
}
fprintf(fidC,"}\n");
// mbs_print_user_model
fprintf(fidC," void mbs_print_user_model(UserModel* um) \n");
fprintf(fidC,"{\n");
fprintf(fidC,"\n");
for(i=0; i< gen->user_models->n_user_model; i++)
{
for(j=0; j< gen->user_models->user_model_list[i]->n_parameter; j++)
{
char* um_name = gen->user_models->user_model_list[i]->name;
char* param_name = gen->user_models->user_model_list[i]->parameter_list[j]->name;
switch( gen->user_models->user_model_list[i]->parameter_list[j]->type)
{
case 1:
fprintf(fidC," printf(\"user_model->%s.%s=%%f\\n\", um->%s.%s);\n", um_name, param_name, um_name, param_name);
break;
case 2:
case 3:
case 4:
case 5:
fprintf(fidC," printf(\"user_model->%s.%s\\n\");\n", um_name, param_name);
break;
case 7: //integer
fprintf(fidC," printf(\"user_model->%s.%s=%%d\\n\", um->%s.%s);\n", um_name, param_name, um_name, param_name);
break;
}
}
fprintf(fidC," \n");
}
fprintf(fidC,"}\n");
// end of file
fprintf(fidC,"\n");
fprintf(fidC,"// ============================================================ //\n \n");
......
......@@ -90,6 +90,7 @@ SET(LIB_MBSYSC_INCLUDE_DIRS "${ROBOTRAN_SOURCE_DIR}/mbs_common/mbs_struct"
)
configure_file(LibRobotranCConfig.cmake.in "${CMAKE_BINARY_DIR}/LibRobotranCConfig.cmake" @ONLY)
configure_file(LibRobotranCConfigVersion.cmake.in "${CMAKE_BINARY_DIR}/LibRobotranCConfigVersion.cmake" @ONLY)
if(hasParent) #compiled by standalone project
SET(LIB_MBSYSC_INCLUDE_DIRS ${LIB_MBSYSC_INCLUDE_DIRS} PARENT_SCOPE )
......
# - Version Config file for the Robotran MBSysC package
# It defines the version of the Robotran MBSysC package and
# checks the compatibility with the user projects
##############################
# Set version
##############################
set(PACKAGE_VERSION 1.9.6)
##############################
# Set compatibility rule
##############################
# compatibility for the "find_package( LibRobotranC X.Y.Z EXACT )"
# set to the exact same version number
if (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
# compatibility for the "find_package( LibRobotranC X.Y.Z )"
# set to any version X.Y.*
if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1)
if("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 9)
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 9)
endif("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1)
\ No newline at end of file
......@@ -68,6 +68,7 @@ void mbs_lmgc_set_nb_mbs(int nb){
mld->resqFile = NULL;
mld->resqdFile = NULL;
mld->resQqFile = NULL;
mld->resImpQcFile = NULL;
mld->animFile = NULL;
mld->nb_nodes = 0;
mld->nodes = NULL;
......@@ -142,6 +143,11 @@ void mbs_lmgc_set_res_file(int iMbs, char* filename){
strcat(f, "_Qq.res");
mbs_lmgc_set_filename(iMbs, &(globalSystem->mbs_lmgc_s[iMbs].resQqFile) ,f);
// set the res file for impulse of joint forces associated to driven joints
strcpy(f, filename);
strcat(f, "_ImpQc.res");
mbs_lmgc_set_filename(iMbs, &(globalSystem->mbs_lmgc_s[iMbs].resImpQcFile) ,f);
free(f);
#ifdef DEBUG_PRINT
printf("Path to results filename for mbs number %d set to %s.\n", iMbs, globalSystem->mbs_lmgc_s[iMbs].resqFile);
......@@ -312,14 +318,17 @@ void mbs_lmgc_initialize(){
mld->vBeg = (double*) malloc(nquc*sizeof(double));
mld->vFree = (double*) malloc(nquc*sizeof(double));
mld->vAux = (double*) malloc(nquc*sizeof(double));
mld->reac = (double*) malloc(nqu*sizeof(double));
mld->rAux = (double*) malloc(nqu*sizeof(double));
mld->reac = (double*) malloc(nquc*sizeof(double));
mld->rAux = (double*) malloc(nquc*sizeof(double));
mld->impQc = (double*) malloc(nbJoint*sizeof(double));
nullifyArray(mld->qm, nqu);
nullifyArray(mld->vFree, nquc);
nullifyArray(mld->vAux, nquc);
nullifyArray(mld->reac, nqu);
nullifyArray(mld->rAux, nqu);
nullifyArray(mld->reac, nquc);
nullifyArray(mld->rAux, nquc);
nullifyArray(mld->impQc, nbJoint);
// init vBeg to the initial value of qd
for (j=0; j<nquc; j++){
......@@ -331,7 +340,7 @@ void mbs_lmgc_initialize(){
* - Generalized velocities (qd);
* - Generalized joints forces/torques (Qq);
*/
mld->bufferNb = 3;
mld->bufferNb = 4;
mld->buffersize = 1; // Arbitrary dimension as number of steps is unknown
// Some value for readability of function call that are always true or false in our simulation
......@@ -346,12 +355,14 @@ void mbs_lmgc_initialize(){
mld->buffers[0] = mbs_new_buffer(mld->resqFile, mld->animFile, md->njoint, mld->buffersize, bufferIDs[0], save_anim, save_visu, 1./(double)framerate); // Coordinate
mld->buffers[1] = mbs_new_buffer(mld->resqdFile, mld->animFile, md->njoint, mld->buffersize, bufferIDs[1], save_anim, save_visu, 1./(double)framerate);// Velocities
mld->buffers[2] = mbs_new_buffer(mld->resQqFile, mld->animFile, md->njoint, mld->buffersize, bufferIDs[3], save_anim, save_visu, 1./(double)framerate);// Forces-torques
mld->buffers[3] = mbs_new_buffer(mld->resImpQcFile, mld->animFile, md->njoint, mld->buffersize, bufferIDs[4], save_anim, save_visu, 1./(double)framerate);// Forces-torques impuls of driven joints
// Array with pointer to fields to be saved
mld->savedArrays = (double**) malloc(mld->bufferNb*sizeof(double*));
mld->savedArrays[0] = md->q+1;
mld->savedArrays[1] = md->qd+1;
mld->savedArrays[2] = md->Qq+1;
mld->savedArrays[3] = mld->impQc;
}
}
......@@ -390,6 +401,7 @@ void mbs_lmgc_finalize(){
free(mld->vAux);
free(mld->reac);
free(mld->rAux);
free(mld->impQc);
mbs_lmgc_free_node_list(mld->nb_nodes, mld->nodes);
......@@ -617,7 +629,9 @@ void mbs_lmgc_nullify_reac(int i_mbs){
printf("mbs_lmgc_nullify_reac(i_mbs=%d) \n", i_mbs);
#endif
nullifyArray(globalSystem->mbs_lmgc_s[i_mbs].reac, globalSystem->mbs_lmgc_s[i_mbs].mbs_data->nqu);
MbsData* md = globalSystem->mbs_lmgc_s[i_mbs].mbs_data;
nullifyArray(globalSystem->mbs_lmgc_s[i_mbs].reac, md->nqu+md->nqc);
}
void mbs_lmgc_nullify_rAux(int i_mbs){
......@@ -626,7 +640,9 @@ void mbs_lmgc_nullify_rAux(int i_mbs){
printf("mbs_lmgc_nullify_rAux(i_mbs=%d) \n", i_mbs);
#endif
nullifyArray(globalSystem->mbs_lmgc_s[i_mbs].rAux, globalSystem->mbs_lmgc_s[i_mbs].mbs_data->nqu);
MbsData* md = globalSystem->mbs_lmgc_s[i_mbs].mbs_data;
nullifyArray(globalSystem->mbs_lmgc_s[i_mbs].rAux, md->nqu+md->nqc);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
......@@ -649,18 +665,22 @@ void mbs_lmgc_nullify_rAux(int i_mbs){
*/
void mbs_lmgc_add_reaction(int i_mbs, int i_node, double* reacNode, double* reacGlob){
int i, j;
int i, j, nquc;
MbsLmgcNode* node = NULL;
MbsLmgcData* mld = NULL;
mld = globalSystem->mbs_lmgc_s+i_mbs;
// get node
node = globalSystem->mbs_lmgc_s[i_mbs].nodes+i_node;
node = mld->nodes+i_node;
#ifdef DEBUG_PRINT
printf("mbs_lmgc_add_reaction(i_mbs=%d, i_node=%d, Generalized independent reaction =[ ", i_mbs, i_node);
#endif
nquc = mld->mbs_data->nqu+mld->mbs_data->nqc;
// compute Jsens^T * reac_node
for(i=0 ; i < globalSystem->mbs_lmgc_s[i_mbs].mbs_data->nqu ; i++)
for(i=0 ; i < nquc ; i++)
{
for(j=0; j<6 ; j++)
{
......@@ -836,7 +856,7 @@ void mbs_lmgc_get_vAux(int i_mbs, int i_node, double* vlocyNode){
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void mbs_lmgc_compute_dof(double h, double theta){
int i,j;
int i,j, k;
#ifdef DEBUG_PRINT
printf("mbs_lmgc_compute_dof(h=%f, theta=%f) \n", h, theta);
......@@ -882,6 +902,18 @@ void mbs_lmgc_compute_dof(double h, double theta){
// Kinematic resolution (velocities)
mbs_close_kin(md, mld->lds);
}
// compute driven force/joint impulse
for(j=0 ; j < md->nqc ; j++){
// Lambda_c = lambda_c * h + reac_c + ...
mld->impQc[md->qc[j+1]-1] = h*md->Qc[md->qc[j+1]] - mld->reac[md->nqu+j];
// Lambda_c = ... + Mcu*vAux
for(k=0 ; k < md->nqu ; k++){
mld->impQc[md->qc[j+1]-1] += mld->lds->Mruc[md->nqu+j+1][k+1]*mld->vAux[k];
}
}
// Update time to the end of step, to be coherent with the current values of joints
md->tsim+=h;
}
......
......@@ -74,6 +74,9 @@ typedef struct MbsLmgcData{
/** Array of auxiliary generalized reaction (for computing W matrix) */
double* rAux;
/** Array of impulse on the driven coordinates */
double* impQc;
/** String defining the file from which to load the mbs data */
char* mbsFile;
......@@ -87,6 +90,9 @@ typedef struct MbsLmgcData{
/** String defining the file in which to save velocity results */
char* resQqFile;
/** String defining the file in which to save impuls of joint/force associated to driven joints */
char* resImpQcFile;
/** String defining the file in which to save animation result */
char* animFile;
......
......@@ -185,6 +185,8 @@ void mbs_load_user_functions(MbsData* mbs_data, const char* mbs_filename, const
mbs_data->fct.user.mbs_delete_user_model = (mbs_delete_user_model_ptr) mbs_load_function(userLibInfo, "mbs_delete_user_model");
mbs_data->fct.user.mbs_delete_user_IO = (mbs_delete_user_IO_ptr) mbs_load_function(userLibInfo, "mbs_delete_user_IO");
mbs_data->fct.user.mbs_load_user_model_xml = (mbs_load_user_model_xml_ptr) mbs_load_function(userLibInfo, "mbs_load_user_model_xml");
mbs_data->fct.user.mbs_bind_user_model = (mbs_bind_user_model_ptr) mbs_load_function(userLibInfo, "mbs_bind_user_model");
mbs_data->fct.user.mbs_print_user_model = (mbs_print_user_model_ptr) mbs_load_function(userLibInfo, "mbs_print_user_model");
#ifdef REAL_TIME
mbs_data->fct.user.user_realtime_options = (user_realtime_options_ptr) mbs_load_function(userLibInfo, "user_realtime_options");
......
......@@ -12,6 +12,7 @@
#ifdef PRJ_FCT_PTR
#define mbs_new_user_model() s->fct.user.mbs_new_user_model()
#define mbs_load_user_model_xml(mgs, um) s->fct.user.mbs_load_user_model_xml(mgs, um)
#define mbs_bind_user_model(mgs, um) s->fct.user.mbs_bind_user_model(mgs, um)
#define mbs_delete_user_model(um) s->fct.user.mbs_delete_user_model(um)
#define mbs_new_user_IO(a) s->fct.user.mbs_new_user_IO(a)
#define mbs_delete_user_IO(uio) s->fct.user.mbs_delete_user_IO(uio)
......@@ -28,6 +29,18 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_name){
MbsData *mbs_data;
mds = MDS_mbs_reader(mbs_filename);
mbs_data = mbs_load_with_MDS(mds, build_name);
free_MDS_gen_strct(mds);
return mbs_data;
}
MbsData* mbs_load_with_MDS(MDS_gen_strct *mds, const char* build_name){
MbsData *mbs_data;
char* mbs_filename = mds->mbsfile;
mbs_data = (MbsData*) malloc(sizeof(MbsData));
......@@ -39,8 +52,6 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_name){
mbs_data = MDS_create_MBSdataStruct(mds, mbs_data);
free_MDS_gen_strct(mds);
mbs_data->mbs_filename = (char*) malloc (1+strlen(mbs_filename));
mbs_data->build_name = (char*) malloc (1+strlen(build_name));
......@@ -50,7 +61,6 @@ MbsData* mbs_load(const char* mbs_filename, const char* build_name){
return mbs_data;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
......@@ -492,6 +502,7 @@ MbsData* MDS_create_MBSdataStruct(MDS_gen_strct* mds_gen_strct, MbsData* s)
{
s->user_model = mbs_new_user_model();
mbs_load_user_model_xml(mds_gen_strct, s->user_model);
mbs_bind_user_model(mds_gen_strct, s->user_model);
}
else
{
......
......@@ -16,6 +16,16 @@ extern "C" {
*/
MbsData* mbs_load(const char* mbs_filename, const char* build_name);
/**
* \brief Load the data from the given MDS_gen_strct.
* The memory of a new MbsData is allocated.
*
* \param mds the MDS_gen_strct containing the date from which to retrieve
* the MbsData structure.
* \param build_name path to the build folder of MBsysC libraries
*/
MbsData* mbs_load_with_MDS(MDS_gen_strct *mds, const char* build_name);
/**
* \brief Free the memory used by the given MbsData structure.
*
......@@ -34,6 +44,11 @@ void mbs_delete_data(MbsData *s);
*/
void mbs_load_user_model_xml(MDS_gen_strct* gen, UserModel* ums);
/**
* \brief Bind the user model data to the MDS_gen_strct memory pointers
*/
void mbs_bind_user_model(MDS_gen_strct* gen, UserModel* ums);
/**
* \brief Retrieve a MbsData structure from the given MDS_gen_strct
*
......
......@@ -964,6 +964,10 @@ MDS_parameter_strct* MDS_parameter_reader(xmlNodePtr node, xmlDocPtr doc)
{
mds_parameter_strct->type = 1;
}
if(!strcmp((const char*)elementValue,"integer"))
{
mds_parameter_strct->type = 7;
}
if(!strcmp((const char*)elementValue,"vector"))
{
mds_parameter_strct->type = 2;
......
......@@ -243,7 +243,7 @@ typedef struct MDS_links_strct
typedef struct MDS_parameter_strct
{
char *name;
int type; // scalar=1 ; vector=2 ; lut1D=3 ; lut2D=4 ; state=5
int type; // scalar=1 ; vector=2 ; lut1D=3 ; lut2D=4 ; state=5 ; structure=6 : integer=7
int n_value;
double *value_list;
......@@ -257,6 +257,9 @@ typedef struct MDS_parameter_strct
/** if user model param is a lut1D or lut2D name */
int flag_PRJPATH;
char* structure_lutfile;
/** pointer to the memory storing the value in the UserModel structure (redundant with MDS_d_data_strct **d_value but simpler) **/
void* val_ptr;
} MDS_parameter_strct;
......
......@@ -28,6 +28,11 @@
#define START_VIEWPOINT 0 ///< default initial viewpoint
JNIEnv* global_jni_env=NULL; ///< global reference to the java virtual machine (can be started only once)
/*! \brief instantiate a java virtual machine so as to access to the 3D animation facilities of MBSysPad
*
* \return JNI environment
......@@ -127,7 +132,13 @@ void start_jni(JNI_in_out *jni_in_out)
jni_in_out = (JNI_in_out*) args;
#endif
env = create_vm();
// start the java virtual machine if it was not already done ...
if(global_jni_env==NULL){
env = create_vm();
global_jni_env = env; // ... and store it to the global reference
}else{ // if jvm alread started, retrieve the global reference
env=global_jni_env;
}
animFrameClass = (*env)->FindClass(env, "be/robotran/test/LiveSimAnimFrameCL");
......
......@@ -1573,6 +1573,15 @@ MbsShape3D* MbsRead::ShapeExtract(xmlNodePtr shape_node, xmlDocPtr doc,
new_shape_3d = NULL;
// hide
cur_node = FirstNode(shape_node->children, "hide");
// current shape is hidden
if (cur_node != NULL)
{
return NULL;
}
// name
cur_node = FirstNode(shape_node->children, "name");
......
......@@ -405,8 +405,9 @@ Screen_sdl* init_screen_sdl(Realtime_option *options)
*
* \param[in,out] screen_sdl SDL main data structure
* \param[in] nb_new_curves number of new curves
* \param[in] y_curves current y values
*/
void new_curves_save(Screen_sdl *screen_sdl, int nb_new_curves)
void new_curves_save(Screen_sdl *screen_sdl, int nb_new_curves, double *y_curves)
{
int i, j;
int cur_nb_curves, buffer_size;
......@@ -418,9 +419,14 @@ void new_curves_save(Screen_sdl *screen_sdl, int nb_new_curves)
{
screen_sdl->y_save[i] = (double*) malloc(buffer_size * sizeof(double));
for(j=0; j<buffer_size; j++)
for(j=0; j<=screen_sdl->min_tsim_index; j++)
{
screen_sdl->y_save[i][j] = 0.0;
screen_sdl->y_save[i][j] = y_curves[i];
}
for(j=screen_sdl->min_tsim_index+1; j<buffer_size; j++)
{
screen_sdl->y_save[i][j] = 0.0;
}
}
......@@ -823,7 +829,7 @@ void update_plot_vectors(Simu_realtime *realtime, double t)
update_scale_signals(screen_sdl, realtime, 0);
}
/*! \brief update 'y_tab' and 't_vec' for plot data durinf the breaks
/*! \brief update 'y_tab' and 't_vec' for plot data during the breaks
*
* \param[in,out] screen_sdl SDL main data structure
*/
......@@ -1326,23 +1332,21 @@ void update_full_vectors(Simu_realtime *realtime, double tsim)
nb_curves = auto_plot->nb;
if (!nb_curves)
// at least one curve to draw
if (nb_curves > 0)
{
screen_sdl->max_tsim = tsim;
return;
screen_sdl->flag_started = 1;
}
if (auto_plot->nb_new_curves > 0)
{
new_curves_save(screen_sdl, auto_plot->nb_new_curves);
new_curves_save(screen_sdl, auto_plot->nb_new_curves, y_curves);
auto_plot->nb_new_curves = 0;
update_sdl_legend(realtime, auto_plot->nb);
}
screen_sdl->flag_started = 1;
min_tsim_index = screen_sdl->min_tsim_index;
buffer_size = screen_sdl->buffer_size;
......@@ -2055,7 +2059,7 @@ void plot_screen_sdl(Simu_realtime *realtime, double tsim, int screen_flag)
if (screen_sdl->auto_plot->nb_new_curves > 0)
{
new_curves_save(screen_sdl, screen_sdl->auto_plot->nb_new_curves);
new_curves_save(screen_sdl, screen_sdl->auto_plot->nb_new_curves, screen_sdl->auto_plot->y_curves);
screen_sdl->auto_plot->nb_new_curves = 0;
......
......@@ -250,7 +250,7 @@ typedef struct Screen_sdl
void wait_key_generic(Simu_realtime *realtime, int cur_t_usec, double tsim);
Screen_sdl* init_screen_sdl(Realtime_option *options);
void new_curves_save(Screen_sdl *screen_sdl, int nb_new_curves);
void new_curves_save(Screen_sdl *screen_sdl, int nb_new_curves, double *y_curves);
TTF_Font* init_font(char *folder, int font_size);
void free_screen_sdl(Screen_sdl *screen_sdl);
......
......@@ -91,6 +91,8 @@ typedef struct{
mbs_delete_user_model_ptr mbs_delete_user_model;
mbs_delete_user_IO_ptr mbs_delete_user_IO;
mbs_load_user_model_xml_ptr mbs_load_user_model_xml;
mbs_bind_user_model_ptr mbs_bind_user_model;
mbs_print_user_model_ptr mbs_print_user_model;
#ifdef REAL_TIME
user_realtime_options_ptr user_realtime_options;
......
......@@ -43,6 +43,8 @@ typedef UserModel* (*mbs_new_user_model_ptr)();
typedef void (*mbs_delete_user_model_ptr)(UserModel* ums);
typedef void (*mbs_delete_user_IO_ptr)(UserIO *uvs);
typedef void (*mbs_load_user_model_xml_ptr)(MDS_gen_strct* gen, UserModel* ums);
typedef void (*mbs_bind_user_model_ptr)(MDS_gen_strct* gen, UserModel* ums);
typedef void (*mbs_print_user_model_ptr)(UserModel* ums);
#ifdef REAL_TIME
......
......@@ -25,6 +25,7 @@ extern "C" {
#endif
UserModel* mbs_new_user_model();
void mbs_delete_user_model(UserModel* ums);
void mbs_print_user_model(UserModel* ums);
#ifdef __cplusplus
}
#endif
......
......@@ -437,7 +437,7 @@ void mbs_anim_write(MbsBuffer* b)
{
if (next_index > 0)
{
print_x = alpha_comp * b->tx[TIME_ID(next_index)+1 + i] + alpha * b->tx[TIME_ID(next_index)+1 + i];
print_x = alpha_comp * b->tx[TIME_ID(next_index-1)+1 + i] + alpha * b->tx[TIME_ID(next_index)+1 + i];
}
else
{
......
......@@ -4,6 +4,13 @@
#ifdef PRJ_FCT_PTR
#define mbs_print_user_model(um) s->fct.user.mbs_print_user_model(um)
#else
#include "mbs_user_interface.h"
#endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Those utility functions should be move elsewhere
// We should use function of useful_functions. h but signature is not the same ... we need to merge that all!
......@@ -86,7 +93,9 @@ void mbs_print_data(MbsData* s){
print_matrix("In ", 9, s->njoint, s->In);
print_matrix("l ", 3, s->njoint, s->l);
mbs_print_user_model(s->user_model);
/*printUserModel(s->usrMod);
printUserIO(s->userIO);*/
}
......
......@@ -174,7 +174,7 @@ flags_clean()
if ( FLAG_SEPARATE_BUILD ) # find MBSysC dynamic libraries
find_path(LibRobotranC_DIR LibRobotranCConfig.cmake "${ROBOTRAN_SOURCE_DIR}/build")
find_package( LibRobotranC REQUIRED )
find_package( LibRobotranC 1.9.6 REQUIRED )
target_link_libraries( ${Executable} ${LIB_MBSYSC_MODULES} ${LIB_MBSYSC_LOAD} ${LIB_MBSYSC_UTILITIES} )
add_definitions(${LIB_MBSYSC_DEFINITIONS})
......
......@@ -91,7 +91,7 @@ endif()
# MBSysC libraries
if ( FLAG_SEPARATE_BUILD ) # find MBSysC dynamic libraries
find_package( LibRobotranC REQUIRED )
find_package( LibRobotranC 1.9.6 REQUIRED )
add_definitions(${LIB_MBSYSC_DEFINITIONS})
target_link_libraries(Project_symbolic ${LIB_MBSYSC_MODULES})
endif()
......@@ -131,7 +131,7 @@ endif()
# MBSysC libraries
if ( FLAG_SEPARATE_BUILD ) # find MBSysC dynamic libraries
find_package( LibRobotranC REQUIRED )
find_package( LibRobotranC 1.9.6 REQUIRED )
add_definitions(${LIB_MBSYSC_DEFINITIONS})
endif()
......
......@@ -174,7 +174,7 @@ flags_clean()
if ( FLAG_SEPARATE_BUILD ) # find MBSysC dynamic libraries
find_path(LibRobotranC_DIR LibRobotranCConfig.cmake "${ROBOTRAN_SOURCE_DIR}/build")
find_package( LibRobotranC REQUIRED )
find_package( LibRobotranC 1.9.6 REQUIRED )
target_link_libraries( ${Executable} ${LIB_MBSYSC_MODULES} ${LIB_MBSYSC_LOAD} ${LIB_MBSYSC_UTILITIES} )