#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "mbs_data.h"
#include "mbs_1D_array.h"
#include "mbs_matrix.h"
Go to the source code of this file.
Macros | |
#define | MIN(a, b) (((a)<(b))?(a):(b)) |
#define | MAX(a, b) (((a)>(b))?(a):(b)) |
#define | DBL_MAX 1.7976931348623158e+308 |
Functions | |
void * | mbs_free (void *__ptr) |
Free the pointor ptr and set it to NULL. More... | |
void | mbs_log (char *msg,...) |
Function for logging messages in a file called "log" where the program is executed. More... | |
double | pow_int (double basis, int expo) |
compute efficiently pow with an integer exponent More... | |
int | expo_ten_inf (double nb) |
get log with base 10 More... | |
double | sign (double a) |
sign function More... | |
char * | get_time_machine () |
returns the current time as a String More... | |
char * | get_char_vec (int l_v) |
create (with memory allocation) a vector (length l_v) of char More... | |
char ** | get_char_tab (int nb_r, int nb_c) |
create (with memory allocation) a [nb_r times nb_c] matrix of chars WARNING: only the first dimension (nb_r) is allocated, pointing to NULL ! More... | |
void | free_char_vec (char *vec) |
release memory for a vector of char More... | |
char * | get_char_cpy (const char *fmt,...) |
Copy the provided formatted string into a newly allocated memory. More... | |
int | set_char_cpy (char **dest, const char *fmt,...) |
Set a copy the provided formatted string into a newly allocated memory. More... | |
int | set_um_string (char **um_str, const char *new_txt) |
Redirect the memory of the string user model to a newly allocated char array. More... | |
void | free_char_tab (char **mat) |
release memory for a matrix of chars More... | |
char * | str_replace_char (char *orig, const char old_char, const char *new_str, int free_orig) |
Create a copy of a string with a specific char replaced by a string. More... | |
double *** | get_d3Darray_1 (int x, int y, int z) |
create (with memory allocation) a [x times y times z] 3D array of doubles, starting at index 1 More... | |
double *** | get_d3Darray_0 (int nb_r, int nb_c, int z) |
create (with memory allocation) a [x times y times z] 3D array of doubles, starting at index 0 More... | |
void | free_d3Darray_0 (double ***array3D) |
release memory for a 3D array of doubles, starting at index 1 More... | |
void | free_d3Darray_1 (double ***array3D) |
void | mbs_print_data (MbsData *mbs_data) |
void | mbs_copy_data (MbsData *s, MbsData *s_copy) |
Copy all fields between two MBSdata structures. More... | |
void | mbs_reset_joints_kine (MbsData *s) |
Reset joints kinematics (q, qd, qdd) of a MbsData structure to initial values. More... | |
void | mbs_reset_data (MbsData *s) |
Reset all fields of a MbsData structure to initial values. More... | |
int | mbs_write_data (MbsData *mbs, char *filename, char *function_name) |
Write a source with a function allocating and setting a MbsData copy of the provided. More... | |
int | mbs_compare_data (MbsData *s1, MbsData *s2, int accelred) |
Compare two MbsData. More... | |
int | mbs_strcmp (const char *__s1, const char *__s2) |
Compare two char with strcmp. More... | |
int | mbs_stricmp (const char *__s1, const char *__s2) |
Compare two char with _stricmp (convert strings to lower case, ignoring case sensitive). More... | |
#define DBL_MAX 1.7976931348623158e+308 |
#define MAX | ( | a, | |
b | |||
) | (((a)>(b))?(a):(b)) |
#define MIN | ( | a, | |
b | |||
) | (((a)<(b))?(a):(b)) |
int expo_ten_inf | ( | double | nb | ) |
get log with base 10
[in] | nb | number to compute the log |
void free_char_tab | ( | char ** | mat | ) |
release memory for a matrix of chars
[in] | mat | matrix of chars |
void free_char_vec | ( | char * | vec | ) |
release memory for a vector of char
[in] | vec | vector of chars |
void free_d3Darray_0 | ( | double *** | array3D | ) |
release memory for a 3D array of doubles, starting at index 1
release memory for a 3D array of doubles, starting at index 0
[in,out] | array3D | 3D array of doubles |
release memory for a 3D array of doubles, starting at index 1
[in,out] | array3D | 3D array of doubles |
void free_d3Darray_1 | ( | double *** | array3D | ) |
char* get_char_cpy | ( | const char * | fmt, |
... | |||
) |
Copy the provided formatted string into a newly allocated memory.
The caller is responsible to release the memory.
fmt | The string to be formated and stored. Providing NULL returns NULL. |
char** get_char_tab | ( | int | nb_r, |
int | nb_c | ||
) |
create (with memory allocation) a [nb_r times nb_c] matrix of chars WARNING: only the first dimension (nb_r) is allocated, pointing to NULL !
[in] | nb_r | = nb of rows |
[in] | nb_c | = nb of columns |
char* get_char_vec | ( | int | l_v | ) |
create (with memory allocation) a vector (length l_v) of char
[in] | l_v | = size of the vector |
double*** get_d3Darray_0 | ( | int | nb_r, |
int | nb_c, | ||
int | z | ||
) |
create (with memory allocation) a [x times y times z] 3D array of doubles, starting at index 0
[in] | nb_r | nb of first dimension |
[in] | nb_c | nb of second dimension |
[in] | z | nb of third dimension |
double*** get_d3Darray_1 | ( | int | x, |
int | y, | ||
int | z | ||
) |
create (with memory allocation) a [x times y times z] 3D array of doubles, starting at index 1
[in] | x | nb of first dimension |
[in] | y | nb of second dimension |
[in] | z | nb of third dimension |
char* get_time_machine | ( | ) |
returns the current time as a String
source: http://en.wikipedia.org/wiki/C_date_and_time_functions
Compare two MbsData.
The following fields are not compared:
Other fields may be ommited.
The user model parameters are not compared.
If using "accelred" activate the flag accelred
(non-null value). Otherwhise deactivate it (null value). The field specifiec to accelered (MbsData::jac_user and MbsData::jdqd_user) are allocated with size MbsData::nqv at file loading. When not using "accelred" this value can be changed without reallocating the fields.
[in] | s1 | The first multibody system. |
[in] | s2 | The second multibody system |
[in] | accelred | Flag to compare specified field for accelred usage (user jacobian and jdqd fields). Should be set to False by default. |
Copy all fields between two MBSdata structures.
WARNING: This function is not updated daily with new functionnalities of MbsData. Use with care.
The function does not modify the followings:
[in] | s | Pointer to the multibody source. |
[out] | s_copy | Pointer to the multibody output. |
void* mbs_free | ( | void * | __ptr | ) |
Free the pointor ptr and set it to NULL.
void mbs_log | ( | char * | msg, |
... | |||
) |
Function for logging messages in a file called "log" where the program is executed.
It is useful for debugging when the printf messages do not appear in the console (for instance in Simulink).
void mbs_print_data | ( | MbsData * | mbs_data | ) |
void mbs_reset_data | ( | MbsData * | s | ) |
void mbs_reset_joints_kine | ( | MbsData * | s | ) |
int mbs_strcmp | ( | const char * | __s1, |
const char * | __s2 | ||
) |
Compare two char with strcmp.
[in] | __s1 | The first char to compare. |
[in] | __s2 | The second char to compare. |
int mbs_stricmp | ( | const char * | __s1, |
const char * | __s2 | ||
) |
Compare two char with _stricmp (convert strings to lower case, ignoring case sensitive).
[in] | __s1 | The first char to compare. |
[in] | __s2 | The second char to compare. |
int mbs_write_data | ( | MbsData * | mbs, |
char * | filename, | ||
char * | function_name | ||
) |
Write a source with a function allocating and setting a MbsData copy of the provided.
[in] | mbs | The MbsData structure to be set in the function. |
[in] | filename | The name of the source file to be created. |
[in] | function_name | The name of the function creating the new MbsData. NULL can be provided, in such a case the name will be "get_mbs_data". |
double pow_int | ( | double | basis, |
int | expo | ||
) |
compute efficiently pow with an integer exponent
[in] | a | = basis (double) |
[in] | b | = exponent (integer) |
int set_char_cpy | ( | char ** | dest, |
const char * | fmt, | ||
... | |||
) |
Set a copy the provided formatted string into a newly allocated memory.
If the destination adress is not NULL, it is FREED to avoid memory leaks. Ensure to only provide dynamic allocated memory adress or NULL.
The caller is responsible to release the memory.
[in,out] | dest | Destination where the copy must be set. |
[in] | fmt | The string to be formated and stored. Providing NULL sets NULL. |
int set_um_string | ( | char ** | um_str, |
const char * | new_txt | ||
) |
Redirect the memory of the string user model to a newly allocated char array.
The memory of the existing user model is freed.
A copy of the new string to set in the user model is created.
This function can be used to any pointer to char*, even if it has been created for string user model.
um_str | Pointer to the pointer of the string to be replaced, cannot be NULL. |
new_txt | The new text to be set in the newly allocated memory pointed by um_str. |
double sign | ( | double | a | ) |
sign function
[in] | a | input |
char* str_replace_char | ( | char * | orig, |
const char | old_char, | ||
const char * | new_str, | ||
int | free_orig | ||
) |
Create a copy of a string with a specific char replaced by a string.
If the char is not present in the input string, a copy is returned.
Only 1-byte characters from UTF-8 can be replaced from the string (globally excludes accentuated letters).
[in,out] | orig | Pointer to the original string. |
[in] | old_char | Character (unique) to be replaced from the original string. |
[in] | new_str | Pointer to the characters to be inserted instead of the old_char. A NULL pointer removes the old_char . |
[in] | free_str | Flag to free the original_str on replacement success. This allow to call the function as ‘txt = str_replace(txt, ’\t', " ", 1);` without memory leak. |