Index: trunk/lib/FlairMeta/src/SimuUgv.cpp
===================================================================
--- trunk/lib/FlairMeta/src/SimuUgv.cpp	(revision 377)
+++ trunk/lib/FlairMeta/src/SimuUgv.cpp	(revision 377)
@@ -0,0 +1,49 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2020/12/16
+//  filename:   SimuUgv.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    Class defining a simulation ugv
+//
+//
+/*********************************************************************/
+#ifdef CORE2_64
+
+#include "SimuUgv.h"
+#include <SimulatedUgvControls.h>
+
+using std::string;
+using namespace flair::core;
+using namespace flair::actuator;
+
+namespace flair {
+namespace meta {
+
+SimuUgv::SimuUgv(string name, uint32_t simu_id)
+    : Ugv(name) {
+
+
+  SetUgvControls(new SimulatedUgvControls("controls", simu_id,0));
+  
+  
+}
+
+SimuUgv::~SimuUgv() {}
+
+void SimuUgv::StartSensors(void) {
+ 
+}
+
+
+
+} // end namespace meta
+} // end namespace flair
+
+#endif
Index: trunk/lib/FlairMeta/src/SimuUgv.h
===================================================================
--- trunk/lib/FlairMeta/src/SimuUgv.h	(revision 377)
+++ trunk/lib/FlairMeta/src/SimuUgv.h	(revision 377)
@@ -0,0 +1,39 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file SimuUgv.h
+ * \brief Class defining a simulation x4 uav
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2020/12/16
+ * \version 4.0
+ */
+
+#ifndef SIMUUGV_H
+#define SIMUUGV_H
+
+#include "Ugv.h"
+
+namespace flair {
+namespace meta {
+  
+/*! \class SimuUgv
+*
+* \brief Class defining a simulation ugv
+*/
+class SimuUgv : public Ugv {
+  public:
+    // simu_id: 0 if simulating only one ugv
+    //>0 otherwise
+    SimuUgv(std::string name, uint32_t simu_id = 0);
+    ~SimuUgv();
+    void StartSensors(void);
+    virtual std::string GetType(void) const{return "ugv_simu";}
+
+  private:
+   
+};
+} // end namespace meta
+} // end namespace flair
+#endif // SIMUUGV_H
Index: trunk/lib/FlairMeta/src/Uav.cpp
===================================================================
--- trunk/lib/FlairMeta/src/Uav.cpp	(revision 376)
+++ trunk/lib/FlairMeta/src/Uav.cpp	(revision 377)
@@ -21,5 +21,4 @@
 #include <GridLayout.h>
 #include <DataPlot1D.h>
-#include <VrpnClient.h>
 #include <Ahrs.h>
 #include <Imu.h>
@@ -31,5 +30,5 @@
 #include <Matrix.h>
 #include "MetaUsRangeFinder.h"
-#include "MetaVrpnObject.h"
+
 
 using std::string;
Index: trunk/lib/FlairMeta/src/Uav.h
===================================================================
--- trunk/lib/FlairMeta/src/Uav.h	(revision 376)
+++ trunk/lib/FlairMeta/src/Uav.h	(revision 377)
@@ -11,9 +11,8 @@
  */
 
-#ifndef HDSUAV_H
-#define HDSUAV_H
+#ifndef UAV_H
+#define UAV_H
 
 #include <Object.h>
-#include <UsRangeFinder.h>
 
 namespace flair {
@@ -103,3 +102,3 @@
 } // end namespace meta
 } // end namespace flair
-#endif // HDSUAV_H
+#endif // UAV_H
Index: trunk/lib/FlairMeta/src/Ugv.cpp
===================================================================
--- trunk/lib/FlairMeta/src/Ugv.cpp	(revision 377)
+++ trunk/lib/FlairMeta/src/Ugv.cpp	(revision 377)
@@ -0,0 +1,64 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2020/12/16
+//  filename:   Ugv.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    Base class to construct sensors/actuators depending on Ugv type
+//
+//
+/*********************************************************************/
+
+#include "Ugv.h"
+#include <FrameworkManager.h>
+#include <UgvControls.h>
+
+
+using std::string;
+using namespace flair::core;
+using namespace flair::actuator;
+
+namespace {
+  flair::meta::Ugv *UgvSingleton = NULL;
+}
+
+namespace flair {
+namespace meta {
+
+Ugv *GetUgv(void) { return UgvSingleton; }
+	
+Ugv::Ugv(string name)
+    : Object(getFrameworkManager(), name) {
+	if (UgvSingleton != NULL) {
+    Err("Ugv must be instanced only one time\n");
+    return;
+  }
+
+  UgvSingleton = this;
+  controls=NULL;
+  
+}
+
+Ugv::~Ugv() {}
+
+
+void Ugv::SetUgvControls(const UgvControls *inControls) { 
+  controls = (UgvControls *)inControls;
+}
+
+
+void Ugv::UseDefaultPlot(void) {
+  if(controls) controls->UseDefaultPlot();
+}
+
+
+UgvControls *Ugv::GetUgvControls(void) const { return controls; }
+
+} // end namespace meta
+} // end namespace flair
Index: trunk/lib/FlairMeta/src/Ugv.h
===================================================================
--- trunk/lib/FlairMeta/src/Ugv.h	(revision 377)
+++ trunk/lib/FlairMeta/src/Ugv.h	(revision 377)
@@ -0,0 +1,64 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file Ugv.h
+ * \brief Base class to construct sensors/actuators depending on Ugv type
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2020/12/16
+ * \version 3.4
+ */
+
+#ifndef UGV_H
+#define UGV_H
+
+#include <Object.h>
+
+namespace flair {
+	namespace actuator {
+		class UgvControls;
+	}
+}
+
+namespace flair {
+namespace meta {
+
+/*! \class Ugv
+*
+* \brief Base class to construct sensors/actuators depending on Ugv type.
+* The Object is created with 
+*  the FrameworkManager as parent. FrameworkManager must be created before.
+* Only one instance of this class is allowed by program.
+*/
+class Ugv : public core::Object {
+public:
+
+  Ugv(std::string name);
+  ~Ugv();
+
+  virtual void StartSensors(void)=0;
+  void UseDefaultPlot(void);
+  actuator::UgvControls *GetUgvControls(void) const;
+	virtual std::string GetDefaultVrpnAddress(void) const{return "127.0.0.1:3883";}
+  virtual bool isReadyToGo(void) const { return true;}
+  virtual std::string GetType(void) const=0;
+
+protected:
+  void SetUgvControls(const actuator::UgvControls *controls);
+  
+
+private:
+  actuator::UgvControls *controls;
+};
+
+/*!
+* \brief get Ugv
+*
+* \return the Ugv
+*/
+Ugv *GetUgv(void);
+
+} // end namespace meta
+} // end namespace flair
+#endif // UGV_H
Index: trunk/lib/FlairMeta/src/UgvFactory.cpp
===================================================================
--- trunk/lib/FlairMeta/src/UgvFactory.cpp	(revision 377)
+++ trunk/lib/FlairMeta/src/UgvFactory.cpp	(revision 377)
@@ -0,0 +1,71 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2020/12/16
+//  filename:   UgvFactory.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:   construct a Ugv based on the type name
+//
+//
+/*********************************************************************/
+
+#include "UgvFactory.h"
+#include "FrameworkManager.h"
+#include "SimuUgv.h"
+
+
+using namespace std;
+using namespace flair::core;
+using namespace flair::meta;
+
+namespace { // anonymous
+     vector<flair::meta::Ugv* (*)(string,string,string)> *vectoroffunctions=NULL;
+}
+
+
+Ugv *CreateUgv(string name, string type,string options) {
+
+  Ugv *ugv;
+
+  if(vectoroffunctions!=NULL) {
+    for(int i=0;i<vectoroffunctions->size();i++) {
+      ugv=vectoroffunctions->at(i)(name,type,options);
+      if(ugv!=NULL) {
+        free(vectoroffunctions);
+        vectoroffunctions=NULL;
+        return ugv;
+      }
+    }
+  }
+
+#ifdef CORE2_64
+  if (type.compare(0, 8, "ugv_simu") == 0) {
+    int simu_id = 0;
+    if (type.size() > 8) {
+      simu_id = atoi(type.substr(8, type.size() - 8).c_str());
+    }
+    return new SimuUgv(name, simu_id);
+  }/* else if (type.compare(0, 7, "x8_simu") == 0) {
+    int simu_id = 0;
+    if (type.size() > 7) {
+      simu_id = atoi(type.substr(7, type.size() - 7).c_str());
+    }
+    return new SimuX8(name, simu_id,options, multiplex);
+  }*/ else {
+    getFrameworkManager()->Err("UGV type %s unknown\n", type.c_str());
+    return NULL;
+  }
+#endif
+}
+
+void RegisterUgvCreator(flair::meta::Ugv*(*func)(string,string,string)) {
+  if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Ugv* (*)(string,string,string)>*)malloc(sizeof(vector<flair::meta::Ugv* (*)(string,string,string)>));
+
+  vectoroffunctions->push_back(func);
+}
Index: trunk/lib/FlairMeta/src/UgvFactory.h
===================================================================
--- trunk/lib/FlairMeta/src/UgvFactory.h	(revision 377)
+++ trunk/lib/FlairMeta/src/UgvFactory.h	(revision 377)
@@ -0,0 +1,26 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2020/12/16
+//  filename:   UgvFactory.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:   construct a Ugv based on the type name
+//
+//
+/*********************************************************************/
+
+#ifndef UGVFACTORY
+#define UGVFACTORY
+
+#include <Ugv.h>
+
+flair::meta::Ugv *CreateUgv(std::string name, std::string type,std::string options="");
+
+void RegisterUgvCreator(flair::meta::Ugv*(*func)(std::string,std::string,std::string));
+#endif // UGVFACTORY
Index: trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.cpp	(revision 376)
+++ trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.cpp	(revision 377)
@@ -31,8 +31,8 @@
 namespace actuator {
 
-SimulatedUgvControls::SimulatedUgvControls(const IODevice *parent,string name, uint32_t modelId,uint32_t deviceId)
-    : UgvControls(parent,name) {
+SimulatedUgvControls::SimulatedUgvControls(string name, uint32_t modelId,uint32_t deviceId)
+    : UgvControls(name) {
   
-  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),2 * sizeof(float)+sizeof(Time));
+  shmem = new SharedMem(this, ShMemName(modelId, deviceId),2 * sizeof(float)+sizeof(Time));
   
   buf=(char*)malloc(2 * sizeof(float)+sizeof(Time));
@@ -57,6 +57,6 @@
 void SimulatedUgvControls::SetControls(float speed,float turn) {
   float *values=(float*)buf;
-  buf[0]=speed;
-  buf[1]=turn;
+  values[0]=speed;
+  values[1]=turn;
   Time time=GetTime();
   memcpy(buf+2 * sizeof(float),&time,sizeof(Time));
@@ -67,5 +67,5 @@
   output->GetMutex();
   for (int i = 0; i < 2; i++) {
-    output->SetValueNoMutex(i, 0, buf[i]);
+    output->SetValueNoMutex(i, 0, values[i]);
   }
   output->ReleaseMutex();
Index: trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.h
===================================================================
--- trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.h	(revision 376)
+++ trunk/lib/FlairSensorActuator/src/SimulatedUgvControls.h	(revision 377)
@@ -36,10 +36,9 @@
   * Construct a SimulatedUgvControls.
   *
-  * \param parent parent
   * \param name name
   * \param modelId Model id
   * \param deviceId Imu id of the Model
   */
-  SimulatedUgvControls(const core::IODevice *parent,std::string name,
+  SimulatedUgvControls(std::string name,
           uint32_t modelId,uint32_t deviceId);
 
@@ -50,6 +49,4 @@
   ~SimulatedUgvControls();
 
-private:
- 
   /*!
   * \brief Set controls values
@@ -61,4 +58,6 @@
   */
   void SetControls(float speed,float turn);
+private:
+ 
   
   char *buf;
Index: trunk/lib/FlairSensorActuator/src/UgvControls.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/UgvControls.cpp	(revision 376)
+++ trunk/lib/FlairSensorActuator/src/UgvControls.cpp	(revision 377)
@@ -18,6 +18,10 @@
 #include "UgvControls.h"
 #include <Matrix.h>
+#include <FrameworkManager.h>
+#include <Tab.h>
+#include <DataPlot1D.h>
 
 using namespace flair::core;
+using namespace flair::gui;
 
 using std::string;
@@ -26,6 +30,7 @@
 namespace actuator {
 
-UgvControls::UgvControls(const IODevice *parent, string name)
-    : IODevice(parent, name) {
+UgvControls::UgvControls(string name)
+    : IODevice(getFrameworkManager(), name) {
+  mainTab = new Tab(getFrameworkManager()->GetTabWidget(), name);
   
   MatrixDescriptor *desc = new MatrixDescriptor(2, 1);
@@ -42,5 +47,8 @@
 
 void UgvControls::UseDefaultPlot(void) {
-  
+  DataPlot1D *speedPlot = new DataPlot1D(mainTab->NewRow(), "speed", -1, 1);
+  speedPlot->AddCurve(output->Element(0));
+  DataPlot1D *turnPlot = new DataPlot1D(mainTab->LastRowLastCol(), "turn", -1, 1);
+  turnPlot->AddCurve(output->Element(1));
 }
 
Index: trunk/lib/FlairSensorActuator/src/UgvControls.h
===================================================================
--- trunk/lib/FlairSensorActuator/src/UgvControls.h	(revision 376)
+++ trunk/lib/FlairSensorActuator/src/UgvControls.h	(revision 377)
@@ -18,5 +18,8 @@
 namespace flair {
 namespace core {
-class Matrix;
+  class Matrix;
+}
+namespace gui {
+  class Tab;
 }
 }
@@ -35,10 +38,9 @@
   * \brief Constructor
   *
-  * Construct a UgvControls.
+  * Construct a UgvControls. It will be child of the FrameworkManager.
   *
-  * \param parent parent
   * \param name name
   */
-  UgvControls(const core::IODevice *parent, std::string name);
+  UgvControls(std::string name);
 
   /*!
@@ -63,4 +65,12 @@
   core::Matrix *Output(void) const;
   
+  /*!
+  * \brief Set controls values
+  *
+  * \param speed speed value
+  * \param turn turn value
+  */
+  virtual void SetControls(float speed,float turn)=0;
+  
 protected:
   core::Matrix *output;
@@ -75,14 +85,6 @@
   */
   void UpdateFrom(const core::io_data *data){};
-
-  /*!
-  * \brief Set controls values
-  *
-  * \param speed speed value
-  * \param turn turn value
-  */
-  virtual void SetControls(float speed,float turn)=0;
   
-
+  gui::Tab *mainTab;
 };
 } // end namespace actuator
Index: trunk/lib/FlairSimulator/src/TwoWheelRobot.cpp
===================================================================
--- trunk/lib/FlairSimulator/src/TwoWheelRobot.cpp	(revision 376)
+++ trunk/lib/FlairSimulator/src/TwoWheelRobot.cpp	(revision 377)
@@ -50,4 +50,8 @@
   m = new DoubleSpinBox(setup_tab->NewRow(), "mass (kg):", 0, 20, 0.1,1,0.2);
   size = new DoubleSpinBox(setup_tab->NewRow(), "size (m):", 0, 20, 0.1,1,0.1);
+  t_speed = new DoubleSpinBox(setup_tab->NewRow(), "translational speed (m/s):",
+                              0, 5, 0.1);
+  r_speed = new DoubleSpinBox(setup_tab->NewRow(), "rotational speed (deg/s):",
+                              0, 180, 10);
   
   
@@ -56,4 +60,6 @@
   bodyColorG = new SpinBox(visual_tab->LastRowLastCol(), "arm color (G):", 0, 255, 1,0);
   bodyColorB = new SpinBox(visual_tab->LastRowLastCol(), "arm color (B):", 0, 255, 1,0);
+  
+ 
   
   controls = new SimuUgvControls(this, name, modelId,0);
@@ -155,10 +161,10 @@
 
   controls->GetControls(&speed,&turn,&motorTime);
-	  
+	 
   // compute quaternion from W
   // Quaternion derivative: dQ = 0.5*(  Q*Qw)
   state[0].W.x=0;
   state[0].W.y=0;
-  state[0].W.z=turn;
+  state[0].W.z=turn*r_speed->Value();
   Quaternion dQ = state[-1].Quat.GetDerivative(state[0].W);
 
@@ -167,5 +173,5 @@
   state[0].Quat.Normalize();
 
-  Vector3D<double> dir = Vector3D<double>(speed,0,0);
+  Vector3D<double> dir = Vector3D<double>(speed*t_speed->Value(),0,0);
   dir.Rotate(state[0].Quat);
   state[0].Pos = state[-1].Pos + dT() * dir;
Index: trunk/lib/FlairSimulator/src/TwoWheelRobot.h
===================================================================
--- trunk/lib/FlairSimulator/src/TwoWheelRobot.h	(revision 376)
+++ trunk/lib/FlairSimulator/src/TwoWheelRobot.h	(revision 377)
@@ -64,5 +64,5 @@
 #endif
   gui::SpinBox *bodyColorR,*bodyColorG,*bodyColorB;
-  gui::DoubleSpinBox *size,*m;
+  gui::DoubleSpinBox *size,*m,*t_speed,*r_speed;
   actuator::SimuUgvControls *controls;
 
