Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
robotran
mbsysc
Commits
a06959c0
Commit
a06959c0
authored
Nov 04, 2015
by
Timothee Habra
Browse files
load dynamically symbolic function in linux
parent
d169b067
Changes
5
Hide whitespace changes
Inline
Side-by-side
MBprojects/PendulumSpringC/symbolicR/CMakeLists.txt
View file @
a06959c0
...
...
@@ -30,7 +30,7 @@ set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
increment_void_symbolic
(
symbolicR
)
include
(
GenerateExportHeader
)
add_library
(
project_symbolic
${
SOURCE_FILES
}
${
INCLUDE_DIR
}
)
add_library
(
project_symbolic
SHARED
${
SOURCE_FILES
}
${
INCLUDE_DIR
}
)
GENERATE_EXPORT_HEADER
(
project_symbolic
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
...
...
MBprojects/PendulumSpringC/workR/CMakeLists.txt
View file @
a06959c0
...
...
@@ -116,12 +116,11 @@ add_subdirectory( ${PROJECT_SOURCE_DIR}/../userfctR ${CMAKE_CURRENT_BINARY_DIR}/
if
(
NOT FLAG_SEPARATE_SYMBOLIC
)
#increment_src( ${PROJECT_SOURCE_DIR}/../symbolicR )
#increment_void_symbolic( symbolicR )
add_subdirectory
(
${
PROJECT_SOURCE_DIR
}
/../symbolicR
${
CMAKE_CURRENT_BINARY_DIR
}
/symbolicR
)
endif
(
)
#increment_void_symbolic( symbolicR )
# list include directories (to find headers)
init_include
()
...
...
@@ -159,7 +158,7 @@ if ( FLAG_SEPARATE_BUILD ) # find MBSysC dynamic libraries
else
(
)
target_link_libraries
(
${
Executable
}
MBsysC_loadXML MBsysC_module
project_symbolic
)
target_link_libraries
(
${
Executable
}
MBsysC_loadXML MBsysC_module
)
if
(
NOT FLAG_SHARED_LIB
)
...
...
@@ -184,6 +183,10 @@ else ( )
endif
(
)
if
(
UNIX
)
target_link_libraries
(
${
Executable
}
dl
)
endif
(
)
endif
(
)
# separate symbolic files compilation
...
...
MBprojects/PendulumSpringC/workR/src/main.c
View file @
a06959c0
...
...
@@ -86,9 +86,22 @@ int main(int argc, char const *argv[])
return
0
;
}
#ifdef UNIX
#include <dlfcn.h> // linux function to dynamically load libraries
#endif
void
mbs_get_project_functions
(
MbsData
*
mbs_data
)
{
void
*
lib_handle
;
char
*
error
;
lib_handle
=
dlopen
(
PROJECT_SOURCE_DIR
"/build/symbolicR/libproject_symbolic.so"
,
RTLD_LAZY
);
if
(
!
lib_handle
)
{
fprintf
(
stderr
,
"%s
\n
"
,
dlerror
());
exit
(
1
);
}
// user function pointers
mbs_data
->
user_JointForces
=
user_JointForces
;
mbs_data
->
user_init
=
user_init
;
...
...
@@ -98,6 +111,7 @@ void mbs_get_project_functions(MbsData *mbs_data)
mbs_data
->
user_DrivenJoints
=
user_DrivenJoints
;
mbs_data
->
user_cons_hJ
=
user_cons_hJ
;
mbs_data
->
user_cons_jdqd
=
user_cons_jdqd
;
mbs_data
->
user_LinkForces
=
user_LinkForces
;
#ifdef REAL_TIME
mbs_data
->
user_realtime_options
=
user_realtime_options
;
...
...
@@ -115,11 +129,27 @@ void mbs_get_project_functions(MbsData *mbs_data)
#endif
// symbolic function pointers
mbs_data
->
mbs_link
=
mbs_link
;
mbs_data
->
mbs_link3D
=
mbs_link3D
;
mbs_data
->
mbs_extforces
=
mbs_extforces
;
mbs_data
->
mbs_accelred
=
mbs_accelred
;
mbs_data
->
mbs_dirdyna
=
mbs_dirdyna
;
mbs_data
->
mbs_cons_hJ
=
mbs_cons_hJ
;
mbs_data
->
mbs_cons_jdqd
=
mbs_cons_jdqd
;
}
\ No newline at end of file
//mbs_data->mbs_link = mbs_link;
//mbs_data->mbs_link3D = mbs_link3D;
//mbs_data->mbs_extforces = mbs_extforces;
//mbs_data->mbs_accelred = mbs_accelred;
//mbs_data->mbs_dirdyna = mbs_dirdyna;
//mbs_data->mbs_cons_hJ = mbs_cons_hJ;
//mbs_data->mbs_cons_jdqd = mbs_cons_jdqd;
mbs_data
->
mbs_link
=
dlsym
(
lib_handle
,
"mbs_link"
);
mbs_data
->
mbs_link3D
=
dlsym
(
lib_handle
,
"mbs_link3D"
);
mbs_data
->
mbs_extforces
=
dlsym
(
lib_handle
,
"mbs_extforces"
);
mbs_data
->
mbs_accelred
=
dlsym
(
lib_handle
,
"mbs_accelred"
);
mbs_data
->
mbs_dirdyna
=
dlsym
(
lib_handle
,
"mbs_dirdyna"
);
mbs_data
->
mbs_cons_hJ
=
dlsym
(
lib_handle
,
"mbs_cons_hJ"
);
mbs_data
->
mbs_cons_jdqd
=
dlsym
(
lib_handle
,
"mbs_cons_jdqd"
);
if
((
error
=
dlerror
())
!=
NULL
)
{
fprintf
(
stderr
,
"%s
\n
"
,
error
);
exit
(
1
);
}
// note : no need to call dlclose(), the library will be automatically closed at the end of the execution
}
MBsysC/mbs_common/mbs_struct/mbs_data.h
View file @
a06959c0
...
...
@@ -129,6 +129,7 @@ struct MbsData
user_DrivenJoints_ptr
user_DrivenJoints
;
user_cons_hJ_ptr
user_cons_hJ
;
user_cons_jdqd_ptr
user_cons_jdqd
;
user_LinkForces_ptr
user_LinkForces
;
#ifdef REAL_TIME
user_realtime_options_ptr
user_realtime_options
;
...
...
MBsysC/mbs_common/mbs_struct/mbs_project_fct_ptr.h
View file @
a06959c0
...
...
@@ -19,6 +19,8 @@ typedef void (*user_Derivative_ptr)(MbsData *s);
typedef
void
(
*
user_DrivenJoints_ptr
)(
MbsData
*
s
,
double
tsim
);
typedef
void
(
*
user_cons_hJ_ptr
)(
double
*
h
,
double
**
Jac
,
MbsData
*
s
,
double
tsim
);
typedef
void
(
*
user_cons_jdqd_ptr
)(
double
*
jdqd
,
MbsData
*
s
,
double
tsim
);
typedef
double
(
*
user_LinkForces_ptr
)(
double
Z
,
double
Zd
,
MbsData
*
mbs_data
,
double
tsim
,
int
ilnk
);
#ifdef REAL_TIME
typedef
struct
Realtime_option
Realtime_option
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment