Klamp't  0.9.0
PyController.h
1 #ifndef CONTROL_PY_CONTROLLER_H
2 #define CONTROL_PY_CONTROLLER_H
3 
4 #include "Controller.h"
5 
6 #if HAVE_PYTHON
7 #include "Python.h"
8 #else
9 typedef void PyObject;
10 #endif //HAVE_PYTHON
11 
12 namespace Klampt {
13 
40 {
41  public:
42  PyController(RobotModel& robot);
43  ~PyController();
44  bool Load(const string& moduleName);
45  void Unload();
46 
47  virtual const char* Type() const { return "PyController"; }
48  virtual void Update(Real dt);
49  virtual void Reset();
50  virtual bool ReadState(File& f);
51  virtual bool WriteState(File& f) const;
52 
53  virtual map<string,string> Settings() const;
54  virtual bool GetSetting(const string& name,string& str) const;
55  virtual bool SetSetting(const string& name,const string& str);
56 
57  virtual vector<string> Commands() const;
58  virtual bool SendCommand(const string& name,const string& str);
59 
60  string moduleName;
61  PyObject *module, *updateFunc, *resetFunc, *getStateFunc, *setStateFunc, *getSettingsFunc, *setSettingsFunc;
62  vector<string> commandFuncNames;
63  vector<PyObject*> commandFuncs;
64 };
65 
66 } //namespace Klampt
67 
68 #endif
A base class for a robot controller. The base class does nothing.
Definition: Controller.h:29
The main robot type used in RobotSim.
Definition: Robot.h:83
Definition: ContactDistance.h:6
A controller that interfaces with a python module.
Definition: PyController.h:39