Robotran C Documentation
Functions
mbs_load_json.c File Reference
#include "mbs_load_json.h"
#include "mbs_binder_private.h"
#include "mbs_message.h"
#include "mbs_errors_names.h"
#include "mbs_data.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "useful_functions.h"

Functions

int count_json_elements (JsonNode *node)
 Counts the number of element in the Json array. More...
 
JsonNodeload_and_create_json (const char *mbs_json_filename, int *err)
 
int mbs_info_init_and_binderJSON (MbsInfos *mbs_infos, const char *mbs_json_name, int mission)
 
int mbs_info_json_binder (MbsInfos *mbs_infos, JsonNode *root_node, int mission)
 Read or update the information from root node to all MbsInfo. More...
 
int mbs_info_base_json_binder (MbsInfoBase *mbs_info_base, JsonNode *base_node, int mission)
 Binders /////////////////////////////. More...
 
int mbs_json_parent (JsonNode *node, MbsInfoRefPoint **point_parent, char **joint_parent, int mission, const char *key)
 
int mbs_info_body_json_binder (MbsInfoBody *mbs_info_body, JsonNode *bdy_node, int mission)
 Read or update the information from body node to its MbsInfo. More...
 
int mbs_info_bodies_json_binder (MbsInfos *mbs_infos, JsonNode *bdies_node, int mission)
 
int mbs_info_tree_json_binder (MbsInfos *mbs_infos, JsonNode *tree_node, int mission)
 Read or update the information from tree node to all MbsInfos. More...
 
int mbs_info_ref_point_json_binder (MbsInfoRefPoint *mbs_info_ref_point, JsonNode *node, int mission)
 
int mbs_info_coordinates_json_binder (double *coordinates_pointer, JsonNode *node, int mission)
 
int mbs_info_ball_json_binder (MbsInfoBall *ball_info, JsonNode *ball_node, int mission)
 Read or update a ball json node with the infos. More...
 
int mbs_info_rod_json_binder (MbsInfoRod *rod_info, JsonNode *rod_node, int mission)
 Read or update a rod json node with the infos. More...
 
int mbs_info_solid_json_binder (MbsInfoSolid *solid_info, JsonNode *solid_node, int mission)
 Read or update a solid cut json node with the infos. More...
 
int mbs_info_cuts_json_binder (MbsInfoCuts *cuts_info, JsonNode *cuts_node, int mission)
 Read or update the cuts list json node with the infos. More...
 
int mbs_info_point_list_json_binder (MbsInfoPoint ***point_list, JsonNode *node, int mission, char *body_name, int *n_point)
 Link between points array value and all "points" key of a Json object node. More...
 
int mbs_info_point_json_binder (MbsInfoPoint *mbs_info_point, JsonNode *node, int mission)
 
int mbs_info_parameter_json_binder (MbsInfoParameter *param_info, JsonNode *param_node, int mission)
 Read or update a user model parameter json node with the infos. More...
 
int mbs_info_user_model_json_binder (MbsInfoUserModel *um_info, JsonNode *um_node, int mission)
 Read or update a user model json node with the infos. More...
 
int mbs_info_user_models_json_binder (MbsInfoUserModels *ums_info, JsonNode *ums_node, int mission)
 Read or update the user models list json node with the infos. More...
 
int mbs_info_user_IO_json_binder (MbsInfoUserIO *mbs_info_user_IO, JsonNode *node, int mission)
 
int mbs_info_user_IOs_json_binder (MbsInfoUserIOs *mbs_info_user_IOs, JsonNode *node, int mission)
 
int mbs_info_links_json_binder (MbsInfoLinks *links_info, JsonNode *links_node, int mission)
 Read or update a links list json node with the infos. More...
 
int mbs_info_link_json_binder (MbsInfoLink *link_info, JsonNode *link_node, int mission)
 Read or update a link (point to point or 3D) json node with the infos. More...
 
int mbs_info_links3d_json_binder (MbsInfoLinks *mbs_info_links, JsonNode *node, int mission)
 
int mbs_info_sensor_json_binder (MbsInfoSensor *sensor_info, JsonNode *sensor_node, int mission)
 Read or update a sensor json node with the infos. More...
 
int mbs_info_sensors_json_binder (MbsInfos *mbs_info, JsonNode *sensors_node, int mission)
 Read or update a sensors list json node with the infos. More...
 
int mbs_info_extforce_json_binder (MbsInfoExtforce *force_info, JsonNode *force_node, int mission)
 Read or update a external force json node with the infos. More...
 
int mbs_info_extforces_json_binder (MbsInfos *mbs_info, JsonNode *forces_node, int mission)
 Read or update a external forces list json node with the infos. More...
 
int mbs_info_joint_json_binder (MbsInfoJoint *joint_info, JsonNode *joint_node, int mission)
 Read or update the information in joints node to MbsInfoBase, MbsInfoJoints. More...
 
int mbs_info_joints_list_json_binder (MbsInfos *mbs_infos, JsonNode *joints_node, int mission)
 
int mbs_body_joint_recursive_linker (MbsInfos *mbs_info, int *ind_body_joint, int mission, int body_index)
 
int mbs_tree_cleaner (MbsInfos *mbs_info, int mission)
 Correct the parents of joints. More...
 
int mbs_info_json_linker (MbsInfos *mbs_info, int mission)
 
int mbs_json_axis (JsonNode *axis_node, int *axis_int, int mission)
 Read or update the information in an axis node with an integer. More...
 
int mbs_json_joint_nature (JsonNode *nature_node, int *nature_int, int mission)
 Read or update the information in an joint nature node with an integer. More...
 
int mbs_json_double (JsonNode *node, double *val_ptr, char *key, int mission)
 Link between double value and the specific key of a Json node or the current node. More...
 
int mbs_json_get_double (JsonNode *node, double *val_ptr)
 Get the node value content a double. More...
 
int mbs_json_set_double (JsonNode *node, double value)
 Set a double into a node. More...
 
int mbs_json_string (JsonNode *node, char **str_ptr, const char *key, int mission, int allow_missing)
 Link between string value and the specific key of a Json node. More...
 
int mbs_json_get_string (JsonNode *node, char **str_ptr)
 Get the node value content a double. More...
 
int mbs_json_set_string (JsonNode *node, const char *string)
 Set a double into a node. More...
 
int mbs_json_array (JsonNode *node, double **tab_ptr, int *size, const char *key, int mission)
 Link between array (1D) value and the specific key of a Json node or the current node. More...
 
int mbs_json_tab (JsonNode *node, double ***tab_ptr, int size_1, int size_2, const char *key, int mission)
 Link between array (2D) value and the specific key of a Json node or the current node. More...
 
int mbs_json_inertia (JsonNode *bdy_node, MbsInfoBody *mbs_info_body, int mission)
 Translate the inertia key of a node from array (3,3) in node to array (6) in info. More...
 
int mbs_json_bool (JsonNode *node, int *val_ptr, char *key, int mission)
 Link between bool value (int) and the specific key of a Json node or the current node. More...
 
int mbs_json_get_bool (JsonNode *node, int *val_ptr)
 Get the node value content a bool as int. More...
 
int mbs_json_set_bool (JsonNode *node, int value)
 Set a bool (int) into a node. More...
 

Function Documentation

◆ count_json_elements()

int count_json_elements ( JsonNode node)

Counts the number of element in the Json array.

Parameters
[in]nodeThe array node, if this is not a JSON_ARRAY then MBS_INFO_FAILURE is returned.
Returns
The number of element (>=0) or MBS_INFO_FAILURE.

◆ load_and_create_json()

JsonNode* load_and_create_json ( const char *  mbs_json_filename,
int *  err 
)

◆ mbs_body_joint_recursive_linker()

int mbs_body_joint_recursive_linker ( MbsInfos mbs_info,
int *  ind_body_joint,
int  mission,
int  body_index 
)

◆ mbs_info_ball_json_binder()

int mbs_info_ball_json_binder ( MbsInfoBall mbs_info_ball,
JsonNode node,
int  mission 
)

Read or update a ball json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
ball_infoThe info of the ball.
ball_nodeThe json node of the ball (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_base_json_binder()

int mbs_info_base_json_binder ( MbsInfoBase mbs_info_base,
JsonNode base_node,
int  mission 
)

Binders /////////////////////////////.

Read or update the information in base node to MbsInfoBase.

◆ mbs_info_bodies_json_binder()

int mbs_info_bodies_json_binder ( MbsInfos mbs_infos,
JsonNode bdies_node,
int  mission 
)

◆ mbs_info_body_json_binder()

int mbs_info_body_json_binder ( MbsInfoBody mbs_info_body,
JsonNode node,
int  mission 
)

Read or update the information from body node to its MbsInfo.

A wanring message is printed if the inertia matrix in Json node is not symmetric.

Parameters
mbs_info_bodyThe MbsInfo structure of the body.
body_nodeThe Json node of the body (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns

◆ mbs_info_coordinates_json_binder()

int mbs_info_coordinates_json_binder ( double *  coordinates_pointer,
JsonNode node,
int  mission 
)

◆ mbs_info_cuts_json_binder()

int mbs_info_cuts_json_binder ( MbsInfoCuts mbs_info_cuts,
JsonNode node,
int  mission 
)

Read or update the cuts list json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
mbs_info_cutsThe Info for the cuts
nodeThe cuts json node (an array).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_extforce_json_binder()

int mbs_info_extforce_json_binder ( MbsInfoExtforce mbs_info_extf,
JsonNode node,
int  mission 
)

Read or update a external force json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
force_infoThe Info for the sensor.
force_nodeThe sensor json node (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_extforces_json_binder()

int mbs_info_extforces_json_binder ( MbsInfos mbs_info,
JsonNode node,
int  mission 
)

Read or update a external forces list json node with the infos.

Parameters
mbs_infoThe Info for the project.
forces_nodeThe sensors json node (a JSON_ARRAY).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_init_and_binderJSON()

int mbs_info_init_and_binderJSON ( MbsInfos mbs_infos,
const char *  mbs_json_name,
int  mission 
)

◆ mbs_info_joint_json_binder()

int mbs_info_joint_json_binder ( MbsInfoJoint mbs_info_joint,
JsonNode node,
int  mission 
)

Read or update the information in joints node to MbsInfoBase, MbsInfoJoints.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
mbs_infosThe MbsInfo structure.
joints_nodeThe Json joints node.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_joints_list_json_binder()

int mbs_info_joints_list_json_binder ( MbsInfos mbs_infos,
JsonNode joints_node,
int  mission 
)

◆ mbs_info_json_binder()

int mbs_info_json_binder ( MbsInfos mbs_infos,
JsonNode node,
int  mission 
)

Read or update the information from root node to all MbsInfo.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
mbs_infosThe MbsInfo structure.
root_nodeThe Json node of the base.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_json_linker()

int mbs_info_json_linker ( MbsInfos mbs_info,
int  mission 
)

◆ mbs_info_link_json_binder()

int mbs_info_link_json_binder ( MbsInfoLink mbs_info_link,
JsonNode node,
int  mission 
)

Read or update a link (point to point or 3D) json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
link_infoThe Info for the link.
link_nodeThe link json node (an object).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_links3d_json_binder()

int mbs_info_links3d_json_binder ( MbsInfoLinks mbs_info_links,
JsonNode node,
int  mission 
)

◆ mbs_info_links_json_binder()

int mbs_info_links_json_binder ( MbsInfoLinks mbs_info_links,
JsonNode node,
int  mission 
)

Read or update a links list json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
link_infoThe Info for the links.
link_nodeThe links json node (an array).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_parameter_json_binder()

int mbs_info_parameter_json_binder ( MbsInfoParameter mbs_info_parameter,
JsonNode node,
int  mission 
)

Read or update a user model parameter json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
param_infoThe Info for the parameter.
param_nodeThe node of parameter (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_point_json_binder()

int mbs_info_point_json_binder ( MbsInfoPoint mbs_info_point,
JsonNode node,
int  mission 
)

◆ mbs_info_point_list_json_binder()

int mbs_info_point_list_json_binder ( MbsInfoPoint ***  point_list,
JsonNode node,
int  mission,
char *  body_name,
int *  n_point 
)

Link between points array value and all "points" key of a Json object node.

Support READER, UPDATER and COUNTER mission.

Parameters
point_listpointer to the point list array, the array (point_list[0] can be NULL for READER and COUNTER missions. In case of READER mission, the array is allocated, a warning is printed if the pointer was not NULL;
nodeThe Json node being a JSON_OBJECT containing a "points" key.
missionThe mission, not-implemented mission print a warning but returns success code.
body_nameThe name of the body.
n_pointThe current size of the point list array. It is set during COUNTER and READER mission. It must matche the JSCON_ARRAY size for UPDATER mision
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.

◆ mbs_info_ref_point_json_binder()

int mbs_info_ref_point_json_binder ( MbsInfoRefPoint mbs_info_ref_point,
JsonNode node,
int  mission 
)

◆ mbs_info_rod_json_binder()

int mbs_info_rod_json_binder ( MbsInfoRod mbs_info_rod,
JsonNode node,
int  mission 
)

Read or update a rod json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
rod_infoThe info of the rod.
rod_nodeThe json node of the rod (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_sensor_json_binder()

int mbs_info_sensor_json_binder ( MbsInfoSensor mbs_info_sensor,
JsonNode node,
int  mission 
)

Read or update a sensor json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
sensor_infoThe Info for the sensor.
sensor_nodeThe sensor json node (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_sensors_json_binder()

int mbs_info_sensors_json_binder ( MbsInfos mbs_info,
JsonNode node,
int  mission 
)

Read or update a sensors list json node with the infos.

Parameters
mbs_infoThe Info for the project.
sensors_nodeThe sensors json node (a JSON_ARRAY).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_solid_json_binder()

int mbs_info_solid_json_binder ( MbsInfoSolid mbs_info_solid,
JsonNode node,
int  mission 
)

Read or update a solid cut json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
solid_infoThe info of the solid cut.
solid_nodeThe json node of the solid cut (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_tree_json_binder()

int mbs_info_tree_json_binder ( MbsInfos mbs_infos,
JsonNode node,
int  mission 
)

Read or update the information from tree node to all MbsInfos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
mbs_infosThe MbsInfo structure.
tree_nodeThe Json node of the tree.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_user_IO_json_binder()

int mbs_info_user_IO_json_binder ( MbsInfoUserIO mbs_info_user_IO,
JsonNode node,
int  mission 
)

◆ mbs_info_user_IOs_json_binder()

int mbs_info_user_IOs_json_binder ( MbsInfoUserIOs mbs_info_user_IOs,
JsonNode node,
int  mission 
)

mbs_strcmp((const char*)cur_node->key, "user_variable"))

◆ mbs_info_user_model_json_binder()

int mbs_info_user_model_json_binder ( MbsInfoUserModel mbs_info_user_model,
JsonNode node,
int  mission 
)

Read or update a user model json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
um_infoThe Info for the user model.
um_nodeThe node of user model (a JSON_OBJECT).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_info_user_models_json_binder()

int mbs_info_user_models_json_binder ( MbsInfoUserModels mbs_info_user_models,
JsonNode node,
int  mission 
)

Read or update the user models list json node with the infos.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Parameters
ums_infoThe Info for the user models.
ums_nodeThe node of users models (a JSON_ARRAY).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_json_array()

int mbs_json_array ( JsonNode node,
double **  tab_ptr,
int *  size,
const char *  key,
int  mission 
)

Link between array (1D) value and the specific key of a Json node or the current node.

Parameters
nodeThe Json node containing the targeted value.
tab_ptrThe memory adress of the pointer to the array (to be read or set). if the pointer (tab_ptr[0]) is NULL and mission is READER a new array is allocated.
sizeThe size of the array pointer by tab_ptr (if tab_ptr[0] is not NULL).
keyThe key of the json node to be used (to be read or set), if NULL the node is the array.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_json_axis()

int mbs_json_axis ( JsonNode axis_node,
int *  axis_int,
int  mission 
)

Read or update the information in an axis node with an integer.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Reading an unknow axis return a MBS_INFO_WARNING (with default value 0). Setting an unknow axis return a MBS_INFO_FAILURE (as no corresponding string is defined).

Parameters
axis_nodeThe Json axis node.
axis_intThe pointer to the integer corresponding to the axis.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_json_bool()

int mbs_json_bool ( JsonNode node,
int *  val_ptr,
char *  key,
int  mission 
)

Link between bool value (int) and the specific key of a Json node or the current node.

Parameters
nodeThe Json node containing the targeted value.
val_ptrThe memory containing the bool as integer (to be read or set)
keyThe key of the json node to be used (to be read or set). If null the node is used as target.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.

◆ mbs_json_double()

int mbs_json_double ( JsonNode node,
double *  val_ptr,
char *  key,
int  mission 
)

Link between double value and the specific key of a Json node or the current node.

Parameters
nodeThe Json node containing the targeted value.
val_ptrThe memory containing the double (to be read or set)
keyThe key of the json node to be used (to be read or set). If null the node is used as target.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.

◆ mbs_json_get_bool()

int mbs_json_get_bool ( JsonNode node,
int *  val_ptr 
)

Get the node value content a bool as int.

The function convert the content of the node to double according to the node type. If the node is a JSON_STRING the following value are accepted:

  • as true: "TRUE", "True", "true"
  • as false: "FALSE", "False", "false" Other value will generate a MBS_INFO_FAILURE.
Parameters
nodeThe node to whose value must be read.
val_ptrThe memory where to set the number.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.

◆ mbs_json_get_double()

int mbs_json_get_double ( JsonNode node,
double *  val_ptr 
)

Get the node value content a double.

The function convert the content of the node to double according to the node type.

Parameters
nodeThe node to whose value must be read.
val_ptrThe memory where to set the number.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.

◆ mbs_json_get_string()

int mbs_json_get_string ( JsonNode node,
char **  str_ptr 
)

Get the node value content a double.

The function convert the content of the node to double according to the node type.

Parameters
nodeThe node to whose value must be read.
str_ptrThe memory adress of the pointer to the string (to be read or set).
Returns
Zero for success, Non-zero value for error.

◆ mbs_json_inertia()

int mbs_json_inertia ( JsonNode bdy_node,
MbsInfoBody mbs_info_body,
int  mission 
)

Translate the inertia key of a node from array (3,3) in node to array (6) in info.

Fore READER mission the upper triangle of the inertia matrix is considered. If the matrix was not symmetric warnings are raised.

Parameters
bdy_nodeThe Json node containing the body.
mbs_info_bodyThe mbs informations body structure. If its intertia pointer is NULL, it will be allocated for READER mission only.
keyThe key of the json node to be used (to be read or set), if NULL the node is the array.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_json_joint_nature()

int mbs_json_joint_nature ( JsonNode nature_node,
int *  nature_int,
int  mission 
)

Read or update the information in an joint nature node with an integer.

Non-implemented missions raise a message and return a MBS_INFO_WARNING.

Reading an unknow joint nature return a MBS_INFO_WARNING (with default value 0). Setting an unknow joint nature return a MBS_INFO_FAILURE (as no corresponding string is defined).

Parameters
nature_nodeThe Json nature node.
nature_intThe pointer to the integer corresponding to the nature.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS, MBS_INFO_WARNING or MBS_INFO_FAILURE

◆ mbs_json_parent()

int mbs_json_parent ( JsonNode node,
MbsInfoRefPoint **  point_parent,
char **  joint_parent,
int  mission,
const char *  key 
)

◆ mbs_json_set_bool()

int mbs_json_set_bool ( JsonNode node,
int  value 
)

Set a bool (int) into a node.

The function only accept JSON_BOOL, JSON_NUMBER and JSON_STRING nodes. The function convert the node to a JSON_BOOL.

Parameters
nodeThe node to whose value must be set.
valueThe value to be set.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_json_set_double()

int mbs_json_set_double ( JsonNode node,
double  value 
)

Set a double into a node.

The function only accept JSON_NUMBER and JSON_STRING nodes. In case of JSON_STRING an attempt is done to convert the node to JSON_NUMBER.

Parameters
nodeThe node to whose value must be set.
valuleThe value to be set.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_json_set_string()

int mbs_json_set_string ( JsonNode node,
const char *  string 
)

Set a double into a node.

The function only accept JSON_NUMBER and JSON_STRING nodes. In case of JSON_STRING an attempt is done to convert the node to JSON_NUMBER.

Parameters
nodeThe node to whose value must be set.
stringThe pointer to the string to be read.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.

◆ mbs_json_string()

int mbs_json_string ( JsonNode node,
char **  str_ptr,
const char *  key,
int  mission,
int  allow_missing 
)

Link between string value and the specific key of a Json node.

Parameters
nodeThe Json node containing the targeted value.
str_ptrThe memory adress of the pointer to the string (to be read or set).
keyThe key of the json node to be used (to be read or set).
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
allow_missingFlag to disable failure (and message) if the key is missing. The return code is MBS_INFO_WARNING.
Returns
MBS_INFO_SUCCESS, MBS_INFO_FAILURE or MBS_INFO_WARNING

◆ mbs_json_tab()

int mbs_json_tab ( JsonNode node,
double ***  tab_ptr,
int  size_1,
int  size_2,
const char *  key,
int  mission 
)

Link between array (2D) value and the specific key of a Json node or the current node.

Parameters
nodeThe Json node containing the targeted value.
tab_ptrThe memory adress of the pointer to pointer to the array (to be read or set). if the pointer (tab_ptr[0]) is NULL and mission is READER a new array is allocated will be allocated but memory is NOT contigous.
size_1The size along first axis of the array pointer by tab_ptr (if tab_ptr[0] is not NULL).
size_2The size along second axis of the array pointer by tab_ptr (if tab_ptr[0] is not NULL).
keyThe key of the json node to be used (to be read or set), if NULL the node is the array.
missionThe mission, implemented are MBS_INFO_READER and MBS_INFO_UPDATER.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE

◆ mbs_tree_cleaner()

int mbs_tree_cleaner ( MbsInfos mbs_info,
int  mission 
)

Correct the parents of joints.

If a joint (called P) is the parent of a body and at the same time the parent of one (or more) joints (called C) the tree is modified. All joints "C" will have as parent the body origin point.

A failure occurs either if at least one of the followong:

  • A body has no parent or if multiples bodies have the same joint parent.
  • A joint is the parent of multiple joint.
Parameters
[in,out]mbs_infoThe multibody system.
[in]missionThe function only do something with the MBS_INFO_READER value.
Returns
MBS_INFO_SUCCESS or MBS_INFO_FAILURE.