]> rtime.felk.cvut.cz Git - hubacji1/simple-stage.git/blobdiff - ctrl/gobackward.cc
Add gobackward ctrl
[hubacji1/simple-stage.git] / ctrl / gobackward.cc
diff --git a/ctrl/gobackward.cc b/ctrl/gobackward.cc
new file mode 100644 (file)
index 0000000..9a8b2a1
--- /dev/null
@@ -0,0 +1,21 @@
+#include "stage.hh"
+using namespace Stg;
+
+class ControlledRobot {
+private:
+       ModelPosition *pos = nullptr;
+public:
+       ControlledRobot(Model *m) : pos(dynamic_cast<ModelPosition *>(m))
+       {
+               assert(this->pos != nullptr);
+               this->pos->Subscribe();
+       }
+       ModelPosition *get_pos() const { return this->pos; }
+};
+
+extern "C" int Init(Model *model, CtrlArgs *)
+{
+       auto r = new ControlledRobot(model);
+       r->get_pos()->SetXSpeed(-3.0);
+       return 0;
+}