plugin.cc
Go to the documentation of this file.
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 
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:
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" {
74 }
createSotExternalInterface_t
dynamicgraph::sot::AbstractSotExternalInterface * createSotExternalInterface_t()
Definition: abstract-sot-external-interface.hh:71
abstract-sot-external-interface.hh
Plugin::sotController_
AbstractSotExternalInterface * sotController_
Definition: plugin.cc:27
Plugin::~Plugin
~Plugin()
Definition: plugin.cc:31
debug.hh
plugin.hh
Plugin::Plugin
Plugin()
Definition: plugin.cc:30
Plugin
Definition: plugin.cc:25
dynamicgraph::sot::AbstractSotExternalInterface
Definition: abstract-sot-external-interface.hh:41
dynamicgraph::sot
Plugin::Initialization
void Initialization(std::string &dynamicLibraryName)
Definition: plugin.cc:33
PluginAbstract
Definition: plugin.hh:4
createPlugin
PluginAbstract * createPlugin()
Definition: plugin.cc:73


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31