sot-loader.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2016,
3  * Olivier Stasse,
4  *
5  * CNRS
6  *
7  */
8 /* -------------------------------------------------------------------------- */
9 /* --- INCLUDES ------------------------------------------------------------- */
10 /* -------------------------------------------------------------------------- */
11 
12 #ifndef _SOT_LOADER_HH_
13 #define _SOT_LOADER_HH_
14 
15 // STL includes
16 #include <map>
17 
18 // Dynamic Graph embeded python interpreter.
20 
21 // Sot Framework includes
23 #include <sot/core/debug.hh>
24 #include <sot/core/device.hh>
25 
26 namespace dynamicgraph {
27 namespace sot {
28 
47 class SotLoader {
48  protected:
51 
54 
58 
61 
64 
66  std::map<std::string, SensorValues> sensors_in_;
67 
69  std::map<std::string, ControlValues> control_values_;
70 
73  std::string device_name_;
74 
75  public:
77  SotLoader();
79  ~SotLoader();
80 
82  int parseOptions(int argc, char *argv[]);
83 
85  bool initialization();
86 
88  void cleanUp();
89 
92 
94  inline void startDG() { dynamic_graph_stopped_ = false; }
95 
97  inline void stopDG() { dynamic_graph_stopped_ = true; }
98 
100  inline void setDynamicLibraryName(std::string &afilename) {
101  sot_dynamic_library_filename_ = afilename;
102  }
103 
105  void runPythonCommand(const std::string &command, std::string &result,
106  std::string &out, std::string &err);
107 
109  inline void runPythonFile(std::string ifilename, std::string &err) {
111  }
112 
114  inline void runPythonFile(std::string ifilename) {
116  }
117 
121  void oneIteration(std::map<std::string, SensorValues> &sensors_in,
122  std::map<std::string, ControlValues> &control_values,
123  const double &period);
124 
126  void loadDeviceInPython(const std::string &device_name);
127 };
128 
129 } /* namespace sot */
130 } /* namespace dynamicgraph */
131 
132 #endif /* _SOT_LOADER_HH_ */
dynamicgraph::sot::SotLoader::embeded_python_interpreter_
python::Interpreter embeded_python_interpreter_
Embeded python interpreter.
Definition: sot-loader.hh:63
dynamicgraph::sot::SotLoader::runPythonFile
void runPythonFile(std::string ifilename, std::string &err)
Run a python script inside the embeded python interpreter.
Definition: sot-loader.hh:109
dynamicgraph::sot::SotLoader::sensors_in_
std::map< std::string, SensorValues > sensors_in_
Map of sensor readings.
Definition: sot-loader.hh:66
dynamicgraph::sot::SotLoader::runPythonCommand
void runPythonCommand(const std::string &command, std::string &result, std::string &out, std::string &err)
Run a python command inside the embeded python interpreter.
Definition: sot-loader.cpp:165
dynamicgraph::python::Interpreter::runPythonFile
void runPythonFile(std::string filename)
dynamicgraph::sot::SotLoader::setDynamicLibraryName
void setDynamicLibraryName(std::string &afilename)
Specify the name of the dynamic library.
Definition: sot-loader.hh:100
dynamicgraph
abstract-sot-external-interface.hh
dynamicgraph::sot::SotLoader::device_name_
std::string device_name_
Device entity created and loaded, so we deregister it as the Pool is not responsible for it's life ti...
Definition: sot-loader.hh:73
interpreter.hh
dynamicgraph::sot::SotLoader::SotLoader
SotLoader()
Default constructor.
Definition: sot-loader.cpp:33
debug.hh
dynamicgraph::sot::SotLoader
This class is loading the control part of the Stack-Of-Tasks.
Definition: sot-loader.hh:47
device.hh
dynamicgraph::python::Interpreter
dynamicgraph::sot::SotLoader::control_values_
std::map< std::string, ControlValues > control_values_
Map of control values.
Definition: sot-loader.hh:69
dynamicgraph::sot::SotLoader::initialization
bool initialization()
Prepare the SoT framework.
Definition: sot-loader.cpp:70
dynamicgraph::sot::SotLoader::parseOptions
int parseOptions(int argc, char *argv[])
Read user input to extract the path of the SoT dynamic library.
Definition: sot-loader.cpp:43
dynamicgraph::sot::SotLoader::~SotLoader
~SotLoader()
Default destructor.
Definition: sot-loader.cpp:41
dynamicgraph::sot::SotLoader::loadDeviceInPython
void loadDeviceInPython(const std::string &device_name)
Load the Device entity in the python global scope.
Definition: sot-loader.cpp:187
dynamicgraph::sot::SotLoader::cleanUp
void cleanUp()
Unload the library which handles the robot device.
Definition: sot-loader.cpp:131
dynamicgraph::sot::SotLoader::dynamic_graph_stopped_
bool dynamic_graph_stopped_
Check if the dynamic graph is running or not.
Definition: sot-loader.hh:50
dynamicgraph::sot::SotLoader::oneIteration
void oneIteration(std::map< std::string, SensorValues > &sensors_in, std::map< std::string, ControlValues > &control_values, const double &period)
Compute one iteration of control. Basically executes fillSensors, the SoT and the readControl.
Definition: sot-loader.cpp:171
dynamicgraph::sot::SotLoader::sot_external_interface_
AbstractSotExternalInterface * sot_external_interface_
The interface between the device and the robot driver.
Definition: sot-loader.hh:53
dynamicgraph::sot::AbstractSotExternalInterface
Definition: abstract-sot-external-interface.hh:41
dynamicgraph::sot::SotLoader::sot_dynamic_library_filename_
std::string sot_dynamic_library_filename_
Name of the dynamic library containing the dgs::AbstractSotExternalInterface object.
Definition: sot-loader.hh:57
err
err
dynamicgraph::sot::SotLoader::isDynamicGraphStopped
bool isDynamicGraphStopped()
Get Status of dg.
Definition: sot-loader.hh:91
dynamicgraph::sot::SotLoader::stopDG
void stopDG()
Get Status of dg.
Definition: sot-loader.hh:97
dynamicgraph::sot::SotLoader::startDG
void startDG()
Get Status of dg.
Definition: sot-loader.hh:94
dynamicgraph::sot::SotLoader::runPythonFile
void runPythonFile(std::string ifilename)
Run a python script inside the embeded python interpreter.
Definition: sot-loader.hh:114
dynamicgraph::sot::SotLoader::sot_dynamic_library_
void * sot_dynamic_library_
Handle on the SoT library.
Definition: sot-loader.hh:60


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