Commit 82563021 authored by Timothee Habra's avatar Timothee Habra
Browse files

dynamic loading of symbolic lib in windows

parent a06959c0
......@@ -61,7 +61,7 @@ g = s->g;
// Driven Variables
user_DrivenJoints(s,tsim);
s->user_DrivenJoints(s,tsim);
NRh2 = 1.0;
while((NRh2 > NR_ERR) && (iter++ < MAX_NR_ITER))
......@@ -178,7 +178,7 @@ if(iter > MAX_NR_ITER) return(-1);
// Joint Forces
Qq = user_JointForces(s,tsim);
Qq = s->user_JointForces(s,tsim);
// Link Kinematics: Distance Z , Relative Velocity ZD
......@@ -195,7 +195,7 @@ if(iter > MAX_NR_ITER) return(-1);
// Link Forces
Flnk1 = user_LinkForces(Z1,Zd1,s,tsim,1);
Flnk1 = s->user_LinkForces(Z1,Zd1,s,tsim,1);
// Link Dynamics : Forces projection on body-fixed frames
......
......@@ -31,6 +31,7 @@
#include "MBSdataStructR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
void mbs_cons_hJ(double *h,double **Jac,
MbsData *s, double tsim)
......
......@@ -31,6 +31,7 @@
#include "MBSdataStructR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
void mbs_cons_jdqd(double *Jdqd,
MbsData *s, double tsim)
......
......@@ -31,6 +31,7 @@
#include "MBSdataStructR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
void mbs_dirdyna(double **M,double *c,
MbsData *s, double tsim)
......
......@@ -31,6 +31,7 @@
#include "MBSdataStructR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
void mbs_extforces(double **frc,double **trq,
MbsData *s, double tsim)
......
......@@ -31,6 +31,7 @@
#include "MBSdataStructR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
#include "mbs_sensor.h"
void mbs_gensensor(MbsSensor *sens,
......
......@@ -30,7 +30,8 @@
#include <math.h>
#include "MBSdataStructR7.h"
#include "MBSfunR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
void mbs_invdyna(double *Qq,
MbsData *s, double tsim)
......
......@@ -83,7 +83,7 @@ MbsData *s, double tsim)
// Link Force Computation
Flink1 = user_LinkForces(Z1,Zd1,s,tsim,1);
Flink1 = s->user_LinkForces(Z1,Zd1,s,tsim,1);
// = = Block_0_1_0_2_2_1 = =
......
......@@ -31,6 +31,7 @@
#include "MBSdataStructR7.h"
//#include "MBSfunR7.h"
#include "mbs_project_interface.h"
#include "mbs_sensor.h"
void mbs_sensor(MbsSensor *sens,
......
......@@ -88,10 +88,13 @@ int main(int argc, char const *argv[])
#ifdef UNIX
#include <dlfcn.h> // linux function to dynamically load libraries
#else
#include <windows.h>
#endif
void mbs_get_project_functions(MbsData *mbs_data)
{
#ifdef UNIX
void *lib_handle;
char *error;
......@@ -101,6 +104,15 @@ void mbs_get_project_functions(MbsData *mbs_data)
fprintf(stderr, "%s\n", dlerror());
exit(1);
}
#else
//HINSTANCE hInstLibrary = LoadLibrary(PROJECT_SOURCE_DIR"\\build\\symbolicR\\Debug\\libproject_symbolic.dll");
HINSTANCE hInstLibrary = LoadLibrary("D:\\Projects_Ubuntu\\Robotran-dev\\mbsysc\\MBprojects\\PendulumSpringC\\workR\\build\\symbolicR\\Debug\\project_symbolic.dll");
if(!hInstLibrary)
{
printf("symbolic DLL Failed To Load!\n");
//exit(1);
}
#endif
// user function pointers
mbs_data->user_JointForces = user_JointForces;
......@@ -137,6 +149,7 @@ void mbs_get_project_functions(MbsData *mbs_data)
//mbs_data->mbs_cons_hJ = mbs_cons_hJ;
//mbs_data->mbs_cons_jdqd = mbs_cons_jdqd;
#ifdef UNIX
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");
......@@ -152,4 +165,16 @@ void mbs_get_project_functions(MbsData *mbs_data)
}
// note : no need to call dlclose(), the library will be automatically closed at the end of the execution
#else
mbs_data->mbs_link = (mbs_link_ptr)GetProcAddress(hInstLibrary, "mbs_link");
mbs_data->mbs_link3D = (mbs_link3D_ptr)GetProcAddress(hInstLibrary, "mbs_link3D");
mbs_data->mbs_extforces = (mbs_extforces_ptr)GetProcAddress(hInstLibrary, "mbs_extforces");
mbs_data->mbs_accelred = (mbs_accelred_ptr)GetProcAddress(hInstLibrary, "mbs_accelred");
mbs_data->mbs_dirdyna = (mbs_dirdyna_ptr)GetProcAddress(hInstLibrary, "mbs_dirdyna");
mbs_data->mbs_cons_hJ = (mbs_cons_hJ_ptr)GetProcAddress(hInstLibrary, "mbs_cons_hJ");
mbs_data->mbs_cons_jdqd = (mbs_cons_jdqd_ptr)GetProcAddress(hInstLibrary, "mbs_cons_jdqd");
#endif
}
......@@ -55,32 +55,32 @@ double* user_Link3DForces(double PxF[4], double RxF[4][4],
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/* Symbolic functions *
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "project_symbolic_export.h"
PROJECT_SYMBOLIC_EXPORT void mbs_cons_hJ(double *h,double **Jac,MbsData *s, double tsim);
void mbs_cons_hJ(double *h,double **Jac,MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT void mbs_cons_jdqd(double *Jdqd,MbsData *s, double tsim);
void mbs_cons_jdqd(double *Jdqd,MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT void mbs_link(double **frc,double **trq,double *Flnk,double *Z,double *Zd,MbsData *s, double tsim);
void mbs_link(double **frc,double **trq,double *Flnk,double *Z,double *Zd,MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT void mbs_link3D(double **frc,double **trq, MbsData *s, double tsim);
void mbs_link3D(double **frc,double **trq, MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT void mbs_extforces(double **frc, double **trq, MbsData *s, double tsim);
void mbs_extforces(double **frc, double **trq, MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT int mbs_accelred(MbsData *s, double tsim);
int mbs_accelred(MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT void mbs_gensensor(MbsSensor *sens,
MbsData *s,
int isens);
void mbs_gensensor(MbsSensor *sens,
MbsData *s,
int isens);
PROJECT_SYMBOLIC_EXPORT void mbs_sensor(MbsSensor *sens,
MbsData *s,
int isens);
void mbs_sensor(MbsSensor *sens,
MbsData *s,
int isens);
PROJECT_SYMBOLIC_EXPORT void mbs_invdyna(double *Qq,
MbsData *s, double tsim);
void mbs_invdyna(double *Qq,
MbsData *s, double tsim);
void mbs_dirdyna(double **M,double *c, MbsData *s, double tsim);
PROJECT_SYMBOLIC_EXPORT void mbs_dirdyna(double **M,double *c, MbsData *s, double tsim);
......
#ifndef PROJECT_SYMBOLIC_EXPORT_H
#define PROJECT_SYMBOLIC_EXPORT_H
#ifdef PROJECT_SYMBOLIC_STATIC_DEFINE
# define PROJECT_SYMBOLIC_EXPORT
# define PROJECT_SYMBOLIC_NO_EXPORT
#else
# ifndef PROJECT_SYMBOLIC_EXPORT
# ifdef project_symbolic_EXPORTS
/* We are building this library */
# define PROJECT_SYMBOLIC_EXPORT __declspec(dllexport)
# else
/* We are using this library */
# define PROJECT_SYMBOLIC_EXPORT __declspec(dllimport)
# endif
# endif
# ifndef PROJECT_SYMBOLIC_NO_EXPORT
# define PROJECT_SYMBOLIC_NO_EXPORT
# endif
#endif
#ifndef PROJECT_SYMBOLIC_DEPRECATED
# define PROJECT_SYMBOLIC_DEPRECATED __declspec(deprecated)
# define PROJECT_SYMBOLIC_DEPRECATED_EXPORT PROJECT_SYMBOLIC_EXPORT __declspec(deprecated)
# define PROJECT_SYMBOLIC_DEPRECATED_NO_EXPORT PROJECT_SYMBOLIC_NO_EXPORT __declspec(deprecated)
#endif
#define DEFINE_NO_DEPRECATED 0
#if DEFINE_NO_DEPRECATED
# define PROJECT_SYMBOLIC_NO_DEPRECATED
#endif
#endif
......@@ -12,6 +12,7 @@
#include "mbs_data.h"
#include "mbs_project_interface.h"
void mbs_link3D(double **frc,double **trq, MbsData *s, double tsim)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment