Index: /trunk/lib/FlairMeta/src/SimuX4.cpp
===================================================================
--- /trunk/lib/FlairMeta/src/SimuX4.cpp	(revision 244)
+++ /trunk/lib/FlairMeta/src/SimuX4.cpp	(revision 245)
@@ -24,4 +24,5 @@
 #include <SimuUs.h>
 #include <SimuCamera.h>
+#include <SimuPressureSensor.h>
 #include <BatteryMonitor.h>
 #include <SimuGps.h>
@@ -67,4 +68,9 @@
   if(useGps=="true") {
     SetGps(new SimuGps("gps", (NmeaGps::NMEAFlags_t)(NmeaGps::GGA | NmeaGps::VTG), 0,0, 40));
+  }
+  
+  string usePressureSensor=FindArgument(options,"use_pressure_sensor=",false);
+  if(usePressureSensor=="true") {
+    SetPressureSensor(new SimuPressureSensor("pressuresensor", 0,0, 10));
   } 
 }
@@ -78,4 +84,5 @@
   //((SimuCamera *)GetHorizontalCamera())->Start();
   if(GetGps()) ((SimuGps *)GetGps())->Start();
+  if(GetPressureSensor()) ((SimuPressureSensor *)GetPressureSensor())->Start();
 }
 
Index: /trunk/lib/FlairMeta/src/SimuX8.cpp
===================================================================
--- /trunk/lib/FlairMeta/src/SimuX8.cpp	(revision 244)
+++ /trunk/lib/FlairMeta/src/SimuX8.cpp	(revision 245)
@@ -24,4 +24,5 @@
 #include <SimuUs.h>
 #include <SimuCamera.h>
+#include <SimuPressureSensor.h>
 #include <BatteryMonitor.h>
 #include <SimuGps.h>
@@ -68,4 +69,9 @@
     SetGps(new SimuGps("gps", (NmeaGps::NMEAFlags_t)(NmeaGps::GGA | NmeaGps::VTG), 0,0, 40));
   } 
+  
+  string usePressureSensor=FindArgument(options,"use_pressure_sensor=",false);
+  if(usePressureSensor=="true") {
+    SetPressureSensor(new SimuPressureSensor("pressuresensor", 0,0, 10));
+  } 
 }
 
@@ -78,4 +84,5 @@
   ((SimuCamera *)GetHorizontalCamera())->Start();
   if(GetGps()) ((SimuGps *)GetGps())->Start();
+  if(GetPressureSensor()) ((SimuPressureSensor *)GetPressureSensor())->Start();
 }
 
Index: /trunk/lib/FlairSensorActuator/src/SimuCamera.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuCamera.cpp	(revision 244)
+++ /trunk/lib/FlairSensorActuator/src/SimuCamera.cpp	(revision 245)
@@ -63,8 +63,4 @@
 void SimuCamera::Run(void) {
   Time time;
-//  if (data_rate == NULL) {
-//    Thread::Err("not applicable for simulation part.\n");
-//    return;
-//  }
 
 //  SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
Index: /trunk/lib/FlairSensorActuator/src/SimuGps.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuGps.cpp	(revision 244)
+++ /trunk/lib/FlairSensorActuator/src/SimuGps.cpp	(revision 245)
@@ -82,9 +82,4 @@
   gga.diff_units='M';
 
-  if (dataRate == NULL) {
-    Thread::Err("not applicable for simulation part.\n");
-    return;
-  }
-
   SetPeriodUS((uint32_t)(1000000. / dataRate->Value()));
 
Index: /trunk/lib/FlairSensorActuator/src/SimuImu.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuImu.cpp	(revision 244)
+++ /trunk/lib/FlairSensorActuator/src/SimuImu.cpp	(revision 245)
@@ -62,9 +62,4 @@
   GetDatas(&imuData);
 
-  if (dataRate == NULL) {
-    Thread::Err("not applicable for simulation part.\n");
-    return;
-  }
-
   SetPeriodUS((uint32_t)(1000000. / dataRate->Value()));
 
Index: /trunk/lib/FlairSensorActuator/src/SimuLaser.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuLaser.cpp	(revision 244)
+++ /trunk/lib/FlairSensorActuator/src/SimuLaser.cpp	(revision 245)
@@ -56,9 +56,4 @@
   float z[360];
 
-  if (data_rate == NULL) {
-    Thread::Err("not applicable for simulation part.\n");
-    return;
-  }
-
   SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
 
Index: /trunk/lib/FlairSensorActuator/src/SimuPressureSensor.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuPressureSensor.cpp	(revision 245)
+++ /trunk/lib/FlairSensorActuator/src/SimuPressureSensor.cpp	(revision 245)
@@ -0,0 +1,76 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+//  created:    2018/05/24
+//  filename:   SimuPressureSensor.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    Class for a simulation pressure sensor
+//
+//
+/*********************************************************************/
+#include "SimuPressureSensor.h"
+#include <FrameworkManager.h>
+#include <SpinBox.h>
+#include <GroupBox.h>
+#include <Matrix.h>
+#include <SharedMem.h>
+#include <sstream>
+
+using std::string;
+using std::ostringstream;
+using namespace flair::core;
+using namespace flair::gui;
+
+namespace flair {
+namespace sensor {
+
+SimuPressureSensor::SimuPressureSensor(string name, uint32_t modelId,uint32_t deviceId,
+               uint8_t priority)
+    : Thread(getFrameworkManager(), name, priority), PressureSensor( name) {
+  data_rate =
+      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
+
+  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId), sizeof(float));
+
+  SetIsReady(true);
+}
+
+SimuPressureSensor::~SimuPressureSensor() {
+  SafeStop();
+  Join();
+}
+
+string SimuPressureSensor::ShMemName(uint32_t modelId,uint32_t deviceId) {
+  ostringstream dev_name;
+  dev_name << "simu" <<  modelId << "_pressure_" << deviceId;
+  return dev_name.str().c_str();
+}
+
+void SimuPressureSensor::Run(void) {
+  float p;
+
+  SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
+
+  while (!ToBeStopped()) {
+    WaitPeriod();
+
+    shmem->Read((char *)&p, sizeof(float));
+
+    if (data_rate->ValueChanged() == true) {
+      SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
+    }
+
+    output->SetValue(0, 0, p);
+    output->SetDataTime(GetTime());
+    ProcessUpdate(output);
+  }
+}
+
+} // end namespace sensor
+} // end namespace flair
Index: /trunk/lib/FlairSensorActuator/src/SimuPressureSensor.h
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuPressureSensor.h	(revision 245)
+++ /trunk/lib/FlairSensorActuator/src/SimuPressureSensor.h	(revision 245)
@@ -0,0 +1,86 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file SimuPressureSensor.h
+ * \brief Class for a simulation PressureSensor
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2018/05/24
+ * \version 4.0
+ */
+
+#ifndef SIMUPRESSURESENSOR_H
+#define SIMUPRESSURESENSOR_H
+
+#include <PressureSensor.h>
+#include <Thread.h>
+
+namespace flair {
+namespace core {
+class SharedMem;
+}
+namespace gui {
+class SpinBox;
+}
+}
+
+namespace flair {
+namespace sensor {
+/*! \class SimuPressureSensor
+*
+* \brief Class for a simulation PressureSensor
+*/
+class SimuPressureSensor : public core::Thread, public PressureSensor {
+public:
+  /*!
+  * \brief Constructor
+  *
+  * Construct a SimuPressureSensor.
+	* It will be child of the FrameworkManager.
+  *
+  * \param name name
+  * \param modelId Model id
+  * \param deviceId PressureSensor id of the Model
+  * \param priority priority of the Thread
+  */
+  SimuPressureSensor(std::string name,
+         uint32_t modelId,uint32_t deviceId, uint8_t priority);
+
+  /*!
+  * \brief Destructor
+  *
+  */
+  ~SimuPressureSensor();
+
+protected:
+  /*!
+  * \brief SharedMem to access datas
+  *
+  */
+  core::SharedMem *shmem;
+
+private:
+  /*!
+  * \brief Update using provided datas
+  *
+  * Reimplemented from IODevice.
+  *
+  * \param data data from the parent to process
+  */
+  void UpdateFrom(const core::io_data *data){};
+
+  /*!
+  * \brief Run function
+  *
+  * Reimplemented from Thread.
+  *
+  */
+  void Run(void);
+  
+  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
+  gui::SpinBox *data_rate;
+};
+} // end namespace sensor
+} // end namespace flair
+#endif // SIMUPRESSURESENSOR_H
Index: /trunk/lib/FlairSensorActuator/src/SimuUs.cpp
===================================================================
--- /trunk/lib/FlairSensorActuator/src/SimuUs.cpp	(revision 244)
+++ /trunk/lib/FlairSensorActuator/src/SimuUs.cpp	(revision 245)
@@ -55,10 +55,5 @@
 void SimuUs::Run(void) {
   float z;
-
-  if (data_rate == NULL) {
-    Thread::Err("not applicable for simulation part.\n");
-    return;
-  }
-
+  
   SetPeriodUS((uint32_t)(1000000. / data_rate->Value()));
 
Index: /trunk/lib/FlairSimulator/src/SimuPressureSensor.cpp
===================================================================
--- /trunk/lib/FlairSimulator/src/SimuPressureSensor.cpp	(revision 245)
+++ /trunk/lib/FlairSimulator/src/SimuPressureSensor.cpp	(revision 245)
@@ -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:    2018/05/24
+//  filename:   SimuPressureSensor.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    Class for a simulation pressure sensor
+//
+//
+/*********************************************************************/
+#include "SimuPressureSensor.h"
+#include <SharedMem.h>
+#include <Tab.h>
+#include <DoubleSpinBox.h>
+#include <Matrix.h>
+#include "Model.h"
+#include <sstream>
+#include <math.h>
+
+using std::string;
+using std::ostringstream;
+using namespace flair::core;
+using namespace flair::simulator;
+using namespace flair::gui;
+
+namespace flair {
+namespace sensor {
+
+SimuPressureSensor::SimuPressureSensor(const Model *parent, string name,uint32_t modelId,uint32_t deviceId)
+    : IODevice(parent,name) {
+  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
+  seaPressure = new DoubleSpinBox(setup_tab->NewRow(), "pressure at sea level:","Pa", 0, 200000, 1000,0,101325);
+  
+  shmem = new SharedMem(this, ShMemName(modelId, deviceId), sizeof(float));
+  
+  SetIsReady(true);
+}
+
+SimuPressureSensor::~SimuPressureSensor() {
+}
+
+string SimuPressureSensor::ShMemName(uint32_t modelId,uint32_t deviceId) {
+  ostringstream dev_name;
+  dev_name << "simu" <<  modelId << "_pressure_" << deviceId;
+  return dev_name.str().c_str();
+}
+
+void SimuPressureSensor::UpdateFrom(const io_data *data) {
+  if (data != NULL) {
+    Matrix *input = (Matrix *)data;
+    float z_feet = -input->Value(6, 0)*3.28084;
+    float p = seaPressure->Value() *pow(1 - 6.87535*1e-6*z_feet,5.2561);//from https://www.brisbanehotairballooning.com.au/pressure-and-altitude-conversion/
+    shmem->Write((char *)&p, sizeof(float));
+  }
+}
+
+} // end namespace sensor
+} // end namespace flair
Index: /trunk/lib/FlairSimulator/src/SimuPressureSensor.h
===================================================================
--- /trunk/lib/FlairSimulator/src/SimuPressureSensor.h	(revision 245)
+++ /trunk/lib/FlairSimulator/src/SimuPressureSensor.h	(revision 245)
@@ -0,0 +1,80 @@
+// %flair:license{
+// This file is part of the Flair framework distributed under the
+// CECILL-C License, Version 1.0.
+// %flair:license}
+/*!
+ * \file SimuPressureSensor.h
+ * \brief Class for a simulation PressureSensor
+ * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
+ * \date 2018/05/24
+ * \version 4.0
+ */
+
+#ifndef SIMUPRESSURESENSOR_H
+#define SIMUPRESSURESENSOR_H
+
+#include <IODevice.h>
+
+namespace flair {
+namespace core {
+class SharedMem;
+}
+namespace gui {
+class SpinBox;
+class DoubleSpinBox;
+}
+namespace simulator {
+class Model;
+}
+}
+
+namespace flair {
+namespace sensor {
+/*! \class SimuPressureSensor
+*
+* \brief Class for a simulation PressureSensor
+*/
+class SimuPressureSensor : public core::IODevice {
+public:
+  /*!
+  * \brief Constructor
+  *
+  * Construct a SimuPressureSensor
+  *
+  * \param parent parent
+  * \param name name
+  * \param modelId Model id
+  * \param deviceId PressureSensor id of the Model
+  */
+  SimuPressureSensor(const simulator::Model *parent, std::string name, uint32_t modelId,uint32_t deviceId);
+
+  /*!
+  * \brief Destructor
+  *
+  */
+  ~SimuPressureSensor();
+
+protected:
+  /*!
+  * \brief SharedMem to access datas
+  *
+  */
+  core::SharedMem *shmem;
+
+private:
+  /*!
+  * \brief Update using provided datas
+  *
+  * Reimplemented from IODevice.
+  *
+  * \param data data from the parent to process
+  */
+  void UpdateFrom(const core::io_data *data);
+  
+  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
+  gui::SpinBox *data_rate;
+  gui::DoubleSpinBox *seaPressure;
+};
+} // end namespace sensor
+} // end namespace flair
+#endif // SIMUPRESSURESENSOR_H
Index: /trunk/lib/FlairSimulator/src/SimuUs.h
===================================================================
--- /trunk/lib/FlairSimulator/src/SimuUs.h	(revision 244)
+++ /trunk/lib/FlairSimulator/src/SimuUs.h	(revision 245)
@@ -67,12 +67,4 @@
   */
   void UpdateFrom(const core::io_data *data){};
-
-  /*!
-  * \brief Run function
-  *
-  * Reimplemented from Thread.
-  *
-  */
-  void Run(void);
   
   std::string ShMemName(uint32_t modelId,uint32_t deviceId);
Index: /trunk/lib/FlairSimulator/src/SimuUsGL.cpp
===================================================================
--- /trunk/lib/FlairSimulator/src/SimuUsGL.cpp	(revision 244)
+++ /trunk/lib/FlairSimulator/src/SimuUsGL.cpp	(revision 245)
@@ -55,5 +55,5 @@
     // todo: utiliser le placement de l'us dans le drone et sa portée
     Matrix *input = (Matrix *)data;
-    value = input->Value(9, 0);
+    value = input->Value(6, 0);
     shmem->Write((char *)&value, sizeof(float));
 #ifdef GL
