Robotran C Documentation
Macros | Functions
mbs_loader.c File Reference
#include "mbs_loader.h"
#include "mbs_binder_public.h"
#include "mbs_binder_private.h"
#include "mbs_load_libraries.h"
#include "mbs_xml_binder_private.h"
#include "useful_functions.h"
#include "mbs_path.h"
#include "mbs_message.h"
#include "mbs_check.h"
#include "mbs_errors_names.h"
#include "mbs_define.h"
#include "mbs_project_interface.h"
#include <errno.h>
#include <string.h>

Macros

#define MSG_ERR   ">> LOAD>> "
 
#define MSG_PRE   " >> "
 

Functions

MbsDatambs_load (const char *mbs_filename)
 Load the data from the given multibody file. More...
 
MbsDatambs_load_with_loader (const char *mbs_filename, MbsLoader *mbs_loader)
 Load the data from the given multibody file using the provided MbsLoader. More...
 
MbsDatambs_load_with_config_name (const char *mbs_filename, const char *config_name)
 Load the data from the given multibody file and configuration filename. More...
 
MbsDatambs_load_with_config_filepath (const char *mbs_filename, const char *config_filepath)
 Load the data from the given multibody file and configuration filename. More...
 
MbsDatambs_load_with_exec (const char *mbs_filename, const char *exe_filepath)
 Load the multibody file using executable filepath to find project path. More...
 
MbsDatambs_load_from_path (const char *mbs_filename, const char *prj_path)
 Load the multibody file considering the provided project path. More...
 
void mbs_print_full_loader (const char *mbs_filename, const char *prj_path, const char *exe_path, const char *config_path, const char *config_name, const char *symbolicLib_name, const char *symbolicLib_path, const char *userfctLib_name, const char *userfctLib_path, int load_symb_user, int verbose, MbsLoader *loader)
 
MbsDatambs_full_loader (const char *mbs_filename, const char *prj_path, const char *exe_filepath, const char *config_path, const char *config_name, const char *symbolicLib_name, const char *symbolicLib_path, const char *userfctLib_name, const char *userfctLib_path, int load_symb_user, int verbose, MbsLoader *loader)
 Fully configurable loading function. More...
 
MbsDatambs_loader_load (const char *mbs_filepath, MbsLoader *mbs_loader)
 Load the data with the specified loader. More...
 
MbsLoadOptionsmbs_new_load_options ()
 Create a new structure with options for the loading. More...
 
int mbs_print_load_options (MbsLoadOptions *opts, const char *indentation)
 Print the provided loader options. More...
 
void mbs_delete_load_options (MbsLoadOptions *opts)
 Free the memory associated to the given MbsLoadOptions. More...
 
MbsLoadermbs_new_loader ()
 Create a new structure loader used for the loading with options. More...
 
int mbs_print_loader (MbsLoader *loader, const char *indentation)
 Print the provided loader. More...
 
void mbs_delete_loader (MbsLoader *loader)
 Free the memory associated to the given MbsLoader. More...
 
void mbs_set_symb_fun_null (MbsData *s)
 Set the pointer to project symbolic functions to NULL. More...
 
void mbs_set_user_fun_null (MbsData *s)
 Set the pointer to project user functions to NULL. More...
 
MbsDpmbs_new_dp (MbsData *mbs_data)
 Allocate and initialize a MbsDp structure in MbsData::mbs_dp. More...
 
void mbs_delete_dp (MbsDp *mbs_dp)
 free a MbsDp structure. More...
 
int mbs_set_user_IO (UserIoInfo *ioInfo, double val)
 
UserIoInfombs_new_user_IO_info ()
 Allocate an empty UserIoInfo structure. More...
 
UserIoInfombs_create_user_IO_info (MbsInfos *mbs_infos, MbsData *s)
 Fill the user io information for the MbsData structure. More...
 
void mbs_delete_user_IO_info (UserIoInfo *ioInfo)
 
int * MDS_translate_q (int *q_mds, int nq, int nj)
 return a (nj sized) vector (starting at index 1) of integer which is a copy of the provided (nq sized) vector (starting at index 0) with all value incremented by 1. If nj is greater than nq, the unused value are set to 0. More...
 
MbsDatambs_info_to_data (MbsLoader *mbs_loader, MbsData *s)
 Retrieve a MbsData structure from the given MbsInfos. More...
 
MbsDatambs_new_data ()
 Allocate an MbsData structure with default field values (NULL, 0). More...
 
void mbs_delete_data (MbsData *s)
 Free the memory used by the given MbsData structure. More...
 

Macro Definition Documentation

◆ MSG_ERR

#define MSG_ERR   ">> LOAD>> "

◆ MSG_PRE

#define MSG_PRE   " >> "

Function Documentation

◆ mbs_create_user_IO_info()

UserIoInfo* mbs_create_user_IO_info ( MbsInfos mbs_infos,
MbsData s 
)

Fill the user io information for the MbsData structure.

Set errno to 0 at starting, set it if an error is encoutered.

Parameters
[in]mbs_infos
[in]s
Returns
NULL in case of error. The pointer to the structure otherwhise.

◆ mbs_delete_data()

void mbs_delete_data ( MbsData s)

Free the memory used by the given MbsData structure.

Parameters
sthe structure to be freed.

◆ mbs_delete_dp()

void mbs_delete_dp ( MbsDp mbs_dp)

free a MbsDp structure.

Parameters
[in,out]mbs_dpthe MbsDp instance.
Returns
NULL

◆ mbs_delete_load_options()

void mbs_delete_load_options ( MbsLoadOptions opts)

Free the memory associated to the given MbsLoadOptions.

! For the moment, does not free the char* fields !

Parameters
optsthe MbsLoadOptions to delete

◆ mbs_delete_loader()

void mbs_delete_loader ( MbsLoader loader)

Free the memory associated to the given MbsLoader.

Parameters
optsthe MbsLoader to delete

◆ mbs_delete_user_IO_info()

void mbs_delete_user_IO_info ( UserIoInfo ioInfo)

◆ mbs_full_loader()

MbsData* mbs_full_loader ( const char *  mbs_filename,
const char *  prj_path,
const char *  exe_path,
const char *  config_path,
const char *  config_name,
const char *  symbolicLib_name,
const char *  symbolicLib_path,
const char *  userfctLib_name,
const char *  userfctLib_path,
int  load_symb_user,
int  verbose,
MbsLoader loader 
)

Fully configurable loading function.

This function is for advanced usage, allowing to pass multiple, or partial datas.

Globally this function is called by all simple loading function providing the unique parameter set by the user and setting other to NULL/default values.

All, except prj_path and exe_path, paths will be cleaned. It means they can start with "PRJPATH" to refer the project path. This project path is either:

  • specified in argument prj_path;
  • specified in the options of the argument loader;
  • determined by locating "dataR" or "workR" folder in the argument exe_path;
  • determined by locating "dataR" or "workR" folder from current working directory.

Set pointers to NULL to use default behavior.

Set negative integers values to use default behavior.

A path/name cannot be specified in the provided loader and in the arguments.

Parameters
[in]mbs_filenameThe name of the mbs file to be loaded WITH EXTENSION. Specifying "dataR" folder is no more required (but still accepted).
[in]prj_pathThe project path (contains the dataR folder) or NULL.
[in]exe_pathThe executable filepath or NULL.
[in]config_pathThe path to the directory of the configuration file. If NULL is provided the configuration file is supposed to be next to the mbs file. It cannot be NON-NULL if config_name is NULL.
[in]config_nameThe name of the configuration file WITH EXTENSION or NULL. It must be defined if config_path is specified.
[in]symbolicLib_nameThe base name of the symbolic library to load or NULL. The prefix/suffix/extension related to the operating system will be added automatically.
[in]symbolicLib_pathThe directory containing the symbolic library or NULL.
[in]userfctLib_nameThe base name of the user function library to load or NULL. The prefix/suffix/extension related to the operating system will be added automatically.
[in]userfctLib_pathThe directory containing the user function library or NULL.
[in]load_symb_userAny of the valid enumeration to specify which project function libraries to be loaded (invalid value will result in default behavior).
[in]verboseVerbosity of the loading procedure.
[in,out]loaderThe pointer to a specified loader, or NULL. IT will be completed with the value provided in the other arguments.
Returns
The loaded multibody system or NULL.

◆ mbs_info_to_data()

MbsData* mbs_info_to_data ( MbsLoader mbs_loader,
MbsData s 
)

Retrieve a MbsData structure from the given MbsInfos.

Parameters
[in]mbs_loaderThe loader structure. It contains the MbsInfos structure already filled to be used to fill the MbsData structure and the content of the optional json configuration file.
[in,out]sthe MbsData structure that will be completed according to the MbsInfos structure.
Returns
NULL in case or error or the argument s in case of success.

◆ mbs_load()

MbsData* mbs_load ( const char *  mbs_filename)

Load the data from the given multibody file.

The memory of a new MbsData is allocated.

Use default behavior to determine project path, libraries...

Parameters
[in]mbs_filenamepath to the file to load including filename and extension.
Returns
The loaded multibody system or NULL.

◆ mbs_load_from_path()

MbsData* mbs_load_from_path ( const char *  mbs_filename,
const char *  prj_path 
)

Load the multibody file considering the provided project path.

Parameters
[in]mbs_filenamepath to the file to load including filename and extension.
[in]prj_pathPath to the project folder.
Returns
The loaded multibody system or NULL.

◆ mbs_load_with_config_filepath()

MbsData* mbs_load_with_config_filepath ( const char *  mbs_filename,
const char *  config_filepath 
)

Load the data from the given multibody file and configuration filename.

Parameters
[in]mbs_filenamePath to the file to load including filename and extension.
[in]config_filepathPath and filename of the configuration file to consider (with extension).
Returns
The loaded multibody system or NULL.

◆ mbs_load_with_config_name()

MbsData* mbs_load_with_config_name ( const char *  mbs_filename,
const char *  config_name 
)

Load the data from the given multibody file and configuration filename.

The configuration file must be located next to the multibody file.

Parameters
[in]mbs_filenamePath to the file to load including filename and extension.
[in]config_filenameName of the configuration file (with extension).
Returns
The loaded multibody system or NULL.

◆ mbs_load_with_exec()

MbsData* mbs_load_with_exec ( const char *  mbs_filename,
const char *  exe_filepath 
)

Load the multibody file using executable filepath to find project path.

Parameters
[in]mbs_filenamepath to the file to load including filename and extension.
[in]exe_filepathExecutable path used to determine project path.
Returns
The loaded multibody system or NULL.

◆ mbs_load_with_loader()

MbsData* mbs_load_with_loader ( const char *  mbs_filename,
MbsLoader mbs_loader 
)

Load the data from the given multibody file using the provided MbsLoader.

Parameters
[in]mbs_filenamepath to the file to load including filename and extension.
[in,out]mbs_loaderoptions for loading. The non-assigned fields will be filled.
Returns
The loaded multibody system or NULL.

◆ mbs_loader_load()

MbsData* mbs_loader_load ( const char *  mbs_filepath,
MbsLoader mbs_loader 
)

Load the data with the specified loader.

The memory of a new MbsData is allocated.

Parameters
[in]mbs_filepathFull path and file WITH EXTENSION to the multibody file.
[in,out]mbs_loaderoptions for loading.
Returns
A fully loaded MbsData strucutre or NULL ptr in case of failure.

◆ mbs_new_data()

MbsData* mbs_new_data ( )

Allocate an MbsData structure with default field values (NULL, 0).

Returns
the allocated structure.

◆ mbs_new_dp()

MbsDp* mbs_new_dp ( MbsData mbs_data)

Allocate and initialize a MbsDp structure in MbsData::mbs_dp.

Parameters
[in]mbs_datathe MbsData instance.
Returns
A pointer to an allocated and initialize MbsDp structure.

◆ mbs_new_load_options()

MbsLoadOptions* mbs_new_load_options ( )

Create a new structure with options for the loading.

The memory of a new MbsLoadOptions is allocated. The options mainly consist in char variables that can contain name and path for separate libraries.

◆ mbs_new_loader()

MbsLoader* mbs_new_loader ( )

Create a new structure loader used for the loading with options.

The memory of a new MbsLoader and its options is allocated. The memory for the "mds" field is not allocated (left to the user if needed)

◆ mbs_new_user_IO_info()

UserIoInfo* mbs_new_user_IO_info ( )

Allocate an empty UserIoInfo structure.

Set errno in case of error.

Returns
Memory adress of the allocated memory or NULL in case of error.

◆ mbs_print_full_loader()

void mbs_print_full_loader ( const char *  mbs_filename,
const char *  prj_path,
const char *  exe_path,
const char *  config_path,
const char *  config_name,
const char *  symbolicLib_name,
const char *  symbolicLib_path,
const char *  userfctLib_name,
const char *  userfctLib_path,
int  load_symb_user,
int  verbose,
MbsLoader loader 
)

◆ mbs_print_load_options()

int mbs_print_load_options ( MbsLoadOptions opts,
const char *  indentation 
)

Print the provided loader options.

Parameters
[in]optsThe pointer to the options.
[in]indentationThe indentation of all prints, except pointer adress.
Returns
MBS_INFO_WARNING for NULL ptr or MBS_INFO_SUCCESS.

◆ mbs_print_loader()

int mbs_print_loader ( MbsLoader loader,
const char *  indentation 
)

Print the provided loader.

Parameters
[in]loaderThe pointer to the MbsLoader.
[in]indentationThe indentation of all prints, except pointer adress.
Returns
MBS_INFO_WARNING for NULL ptr or MBS_INFO_SUCCESS.

◆ mbs_set_symb_fun_null()

void mbs_set_symb_fun_null ( MbsData s)

Set the pointer to project symbolic functions to NULL.

Parameters
[in,out]fctthe MbsData instance containing the pointer of functions

◆ mbs_set_user_fun_null()

void mbs_set_user_fun_null ( MbsData s)

Set the pointer to project user functions to NULL.

Parameters
[in,out]fctthe MbsData instance containing the pointer of functions

◆ mbs_set_user_IO()

int mbs_set_user_IO ( UserIoInfo ioInfo,
double  val 
)

Set the all user IO values.

Set errno in case of failure.

As it is one-time called function, last of the one called on user IO before being simulation starting, all pointers, sizes (and others stuffs) of the IO are checked.

Parameters
[in,out]ioInfoThe information structure about user IO.
[in]valThe value to be set in all values of all user IO.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ MDS_translate_q()

int* MDS_translate_q ( int *  q_mds,
int  nq,
int  nj 
)

return a (nj sized) vector (starting at index 1) of integer which is a copy of the provided (nq sized) vector (starting at index 0) with all value incremented by 1. If nj is greater than nq, the unused value are set to 0.

Parameters
[in]q_mdsthe original (nq sized) vector of integers, starting at index 0
[in]nqthe size of the q_mds vector
[in]njthe size of the returned (starting at index 1) vector (0 element not taken into account)
Returns
requested vector (element 0 receives nj: the size without this element)