| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/* |
| 2 |
|
|
* Copyright 2011, |
| 3 |
|
|
* Olivier Stasse, |
| 4 |
|
|
* |
| 5 |
|
|
* CNRS |
| 6 |
|
|
* |
| 7 |
|
|
*/ |
| 8 |
|
|
/* -------------------------------------------------------------------------- */ |
| 9 |
|
|
/* --- INCLUDES ------------------------------------------------------------- */ |
| 10 |
|
|
/* -------------------------------------------------------------------------- */ |
| 11 |
|
|
|
| 12 |
|
|
#include <iostream> |
| 13 |
|
|
|
| 14 |
|
|
// POSIX.1-2001 |
| 15 |
|
|
#include <dlfcn.h> |
| 16 |
|
|
|
| 17 |
|
|
#include <sot/core/abstract-sot-external-interface.hh> |
| 18 |
|
|
#include <sot/core/debug.hh> |
| 19 |
|
|
|
| 20 |
|
|
#include "plugin.hh" |
| 21 |
|
|
|
| 22 |
|
|
using namespace std; |
| 23 |
|
|
using namespace dynamicgraph::sot; |
| 24 |
|
|
|
| 25 |
|
|
class Plugin : public PluginAbstract { |
| 26 |
|
|
protected: |
| 27 |
|
|
AbstractSotExternalInterface *sotController_; |
| 28 |
|
|
|
| 29 |
|
|
public: |
| 30 |
|
✗ |
Plugin(){}; |
| 31 |
|
✗ |
~Plugin(){}; |
| 32 |
|
|
|
| 33 |
|
✗ |
void Initialization(std::string &dynamicLibraryName) { |
| 34 |
|
|
// Load the SotRobotBipedController library. |
| 35 |
|
|
void *SotRobotControllerLibrary = |
| 36 |
|
✗ |
dlopen(dynamicLibraryName.c_str(), RTLD_GLOBAL | RTLD_NOW); |
| 37 |
|
✗ |
if (!SotRobotControllerLibrary) { |
| 38 |
|
✗ |
std::cerr << "Cannot load library: " << dlerror() << '\n'; |
| 39 |
|
✗ |
return; |
| 40 |
|
|
} |
| 41 |
|
|
|
| 42 |
|
|
// reset errors |
| 43 |
|
✗ |
dlerror(); |
| 44 |
|
|
|
| 45 |
|
|
// Load the symbols. |
| 46 |
|
|
createSotExternalInterface_t *createRobotController = |
| 47 |
|
✗ |
(createSotExternalInterface_t *)dlsym(SotRobotControllerLibrary, |
| 48 |
|
✗ |
"createSotExternalInterface"); |
| 49 |
|
✗ |
const char *dlsym_error = dlerror(); |
| 50 |
|
✗ |
if (dlsym_error) { |
| 51 |
|
✗ |
std::cerr << "Cannot load symbol create: " << dlsym_error << '\n'; |
| 52 |
|
✗ |
return; |
| 53 |
|
|
} |
| 54 |
|
|
|
| 55 |
|
|
/* |
| 56 |
|
|
destroySotExternalInterface_t * destroyRobotController = |
| 57 |
|
|
(destroySotExternalInterface_t *) dlsym(SotRobotControllerLibrary, |
| 58 |
|
|
"destroySotExternalInterface"); |
| 59 |
|
|
*/ |
| 60 |
|
✗ |
dlsym_error = dlerror(); |
| 61 |
|
✗ |
if (dlsym_error) { |
| 62 |
|
✗ |
std::cerr << "Cannot load symbol create: " << dlsym_error << '\n'; |
| 63 |
|
✗ |
return; |
| 64 |
|
|
} |
| 65 |
|
|
|
| 66 |
|
|
// Create robot-controller |
| 67 |
|
✗ |
sotController_ = createRobotController(); |
| 68 |
|
✗ |
cout << "Went out from Initialization." << endl; |
| 69 |
|
|
} |
| 70 |
|
|
}; |
| 71 |
|
|
|
| 72 |
|
|
extern "C" { |
| 73 |
|
✗ |
PluginAbstract *createPlugin() { return new Plugin; } |
| 74 |
|
|
} |
| 75 |
|
|
|