Index: trunk/demos/Skeletons/CustomReferenceAngles/CMakeLists.txt
===================================================================
--- trunk/demos/Skeletons/CustomReferenceAngles/CMakeLists.txt	(revision 43)
+++ trunk/demos/Skeletons/CustomReferenceAngles/CMakeLists.txt	(revision 43)
@@ -0,0 +1,34 @@
+PROJECT(CustomReferenceAngles)
+cmake_minimum_required(VERSION 2.8)
+
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+SET(FLAIR_USE_FILTER TRUE)
+SET(FLAIR_USE_SENSOR_ACTUATOR TRUE)
+SET(FLAIR_USE_META TRUE)
+SET(FLAIR_USE_VRPN TRUE)
+
+include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/GlobalCmakeFlair.cmake)
+include(${FLAIR_USE_FILE})
+
+SET(SRC_FILES
+	${CMAKE_SOURCE_DIR}/src/main.cpp
+	${CMAKE_SOURCE_DIR}/src/MyApp.cpp
+)
+
+INCLUDE_DIRECTORIES(
+	${FLAIR_INCLUDE_DIR}
+)
+
+#real time executable
+ADD_EXECUTABLE(${PROJECT_NAME}_rt
+	${SRC_FILES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}_rt ${FLAIR_LIBRARIES_RT})
+
+#non real time executable
+ADD_EXECUTABLE(${PROJECT_NAME}_nrt
+	${SRC_FILES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}_nrt ${FLAIR_LIBRARIES_NRT})
Index: trunk/demos/Skeletons/CustomReferenceAngles/README
===================================================================
--- trunk/demos/Skeletons/CustomReferenceAngles/README	(revision 43)
+++ trunk/demos/Skeletons/CustomReferenceAngles/README	(revision 43)
@@ -0,0 +1,8 @@
+CustomReferenceAngles
+
+This is a minimal skeleton to use the UavStateMachine class.
+It shows how to set custom reference angles, and use the default control laws.
+
+The custom reference angle mode is activated by clicking on the "start CustomReferenceAngles" button on ground station, or with R1 button on the Dualshock 3.
+The custom reference angle mode is deactivated by clicking on the "stop CustomReferenceAngles" button on ground station, or with X button on the Dualshock 3.
+
Index: trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.cpp
===================================================================
--- trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.cpp	(revision 43)
+++ trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.cpp	(revision 43)
@@ -0,0 +1,108 @@
+//  created:    2015/10/27
+//  filename:   MyApp.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    skeleton to use UavStateMachine with custom reference angles only
+//
+//
+/*********************************************************************/
+
+//include files, add yours
+#include "MyApp.h"
+#include <GridLayout.h>
+#include <PushButton.h>
+#include <MetaDualShock3.h>
+#include <FrameworkManager.h>
+#include <AhrsData.h>
+#include <Ahrs.h>
+#include <Uav.h>
+
+//namespaces, add others if necessary (filter, sensor, actuator)
+using namespace std;
+using namespace flair::core;
+using namespace flair::gui;
+using namespace flair::meta;
+using namespace flair::sensor;
+
+MyApp::MyApp(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default) {
+    start_CustomAngles=new PushButton(GetButtonsLayout()->NewRow(),"start CustomReferenceAngles");
+    stop_CustomAngles=new PushButton(GetButtonsLayout()->NewRow(),"stop CustomReferenceAngles");
+
+    customReferenceOrientation= new AhrsData(this,"reference");
+    uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow);
+    AddDataToControlLawLog(customReferenceOrientation);
+}
+
+MyApp::~MyApp() {
+}
+
+//this method is called by UavStateMachine::Run (main loop) when OrientationMode is Custom
+AhrsData *MyApp::GetReferenceOrientation(void) {
+    //compute the reference angles (for example depending on a position error)
+    //reference angular speed is set to 0
+
+    Euler refAngles;
+    //refAngles.roll=;
+    //refAngles.pitch=;
+    //refAngles.yaw=;
+
+    customReferenceOrientation->SetQuaternionAndAngularRates(refAngles.ToQuaternion(),Vector3D(0,0,0));
+
+    return customReferenceOrientation;
+}
+
+void MyApp::SignalEvent(Event_t event) {
+    UavStateMachine::SignalEvent(event);
+    switch(event) {
+    case Event_t::TakingOff:
+        //always take off in default mode
+        behaviourMode=BehaviourMode_t::Default;
+        break;
+    case Event_t::EnteringFailSafeMode:
+        //return to default mode
+        Thread::Info("CustomReferenceAngles: stop\n");
+        behaviourMode=BehaviourMode_t::Default;
+        break;
+    }
+}
+
+void MyApp::ExtraCheckPushButton(void) {
+    if(start_CustomAngles->Clicked() && (behaviourMode!=BehaviourMode_t::CustomReferenceAngles)) {
+        StartCustomAngles();
+    }
+
+    if(stop_CustomAngles->Clicked() && (behaviourMode==BehaviourMode_t::CustomReferenceAngles)) {
+        StopCustomAngles();
+    }
+}
+
+void MyApp::ExtraCheckJoystick(void) {
+    //R1
+    if(GetJoystick()->IsButtonPressed(9) && (behaviourMode!=BehaviourMode_t::CustomReferenceAngles)) {
+        StartCustomAngles();
+    }
+
+    //stop is not managed here, it is done in UavStateMachine with cross button
+    //pushing cross button will enter fail safe mode and signal the EnteringFailSafeMode event
+}
+
+void MyApp::StartCustomAngles(void) {
+    //ask UavStateMachine to enter in custom orientation mode
+    if (SetOrientationMode(OrientationMode_t::Custom)) {
+        Thread::Info("CustomReferenceAngles: start\n");
+    } else {
+        Thread::Warn("CustomReferenceAngles: could not start\n");
+        return;
+    }
+
+    behaviourMode=BehaviourMode_t::CustomReferenceAngles;
+}
+
+void MyApp::StopCustomAngles(void) {
+    //just ask to enter fail safe mode
+    EnterFailSafeMode();
+}
Index: trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.h
===================================================================
--- trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.h	(revision 43)
+++ trunk/demos/Skeletons/CustomReferenceAngles/src/MyApp.h	(revision 43)
@@ -0,0 +1,55 @@
+//  created:    2015/10/27
+//  filename:   MyApp.h
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    skeleton to use UavStateMachine with custom reference angles only
+//
+//
+/*********************************************************************/
+
+#ifndef MYAPP_H
+#define MYAPP_H
+
+#include <UavStateMachine.h>
+
+namespace flair {
+    namespace core {
+        class AhrsData;
+    }
+    namespace gui {
+        class PushButton;
+    }
+    namespace sensor {
+        class TargetController;
+    }
+}
+
+class MyApp : public flair::meta::UavStateMachine {
+    public:
+        MyApp(flair::meta::Uav* uav,flair::sensor::TargetController *controller);
+        ~MyApp();
+
+    private:
+        enum class BehaviourMode_t {
+            Default,
+            CustomReferenceAngles
+        };
+
+        BehaviourMode_t behaviourMode;
+
+        void StartCustomAngles(void);
+        void StopCustomAngles(void);
+        void ExtraCheckPushButton(void);
+        void ExtraCheckJoystick(void);
+        flair::core::AhrsData *GetReferenceOrientation(void);
+        void SignalEvent(Event_t event);
+
+        flair::gui::PushButton *start_CustomAngles,*stop_CustomAngles;
+        flair::core::AhrsData *customReferenceOrientation;
+};
+
+#endif // MYAPP_H
Index: trunk/demos/Skeletons/CustomReferenceAngles/src/main.cpp
===================================================================
--- trunk/demos/Skeletons/CustomReferenceAngles/src/main.cpp	(revision 43)
+++ trunk/demos/Skeletons/CustomReferenceAngles/src/main.cpp	(revision 43)
@@ -0,0 +1,96 @@
+//  created:    2015/10/27
+//  filename:   main.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    exemple de code uav
+//
+//
+/*********************************************************************/
+
+#include "MyApp.h"
+#include <UavFactory.h>
+#include <FrameworkManager.h>
+#include <TargetEthController.h>
+#include <stdio.h>
+#include <tclap/CmdLine.h>
+
+using namespace TCLAP;
+using namespace std;
+using namespace flair::core;
+using namespace flair::meta;
+using namespace flair::sensor;
+
+string uav_type;
+string log_path;
+int port;
+int ds3port;
+string xml_file;
+string name;
+string address;
+
+void parseOptions(int argc, char** argv);
+
+int main(int argc, char* argv[]) {
+    parseOptions(argc,argv);
+
+    FrameworkManager *manager;
+    manager= new FrameworkManager(name);
+    manager->SetupConnection(address,port);
+    manager->SetupUserInterface(xml_file);
+    manager->SetupLogger(log_path);
+
+    Uav* drone=CreateUav(manager,name,uav_type);
+    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
+    MyApp* app=new MyApp(drone,controller);
+
+    app->Start();
+    app->Join();
+
+    delete manager;
+}
+
+void parseOptions(int argc, char** argv) {
+	try {
+
+        CmdLine cmd("Command description message", ' ', "0.1");
+
+        ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
+        cmd.add( nameArg );
+
+        ValueArg<string> typeArg("t","type","uav type: ardrone2, hds_x4, hds_x8, hds_xufo, x4_simu, x8_simu or x4_simux (with x the number of the simulated uav)",true,"hds_x4","string");
+        cmd.add( typeArg );
+
+        ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
+        cmd.add( xmlArg );
+
+        ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
+        cmd.add( logsArg );
+
+        ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
+        cmd.add( portArg );
+
+        ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
+        cmd.add( addressArg );
+
+        ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
+        cmd.add( ds3portArg );
+
+        cmd.parse( argc, argv );
+
+        // Get the value parsed by each arg.
+        log_path = logsArg.getValue();
+        port=portArg.getValue();
+        ds3port=ds3portArg.getValue();
+        xml_file = xmlArg.getValue();
+        name=nameArg.getValue();
+        uav_type=typeArg.getValue();
+        address=addressArg.getValue();
+
+	} catch (ArgException &e) { // catch any exceptions
+        cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
+	}
+}
Index: trunk/demos/Skeletons/CustomTorques/CMakeLists.txt
===================================================================
--- trunk/demos/Skeletons/CustomTorques/CMakeLists.txt	(revision 43)
+++ trunk/demos/Skeletons/CustomTorques/CMakeLists.txt	(revision 43)
@@ -0,0 +1,34 @@
+PROJECT(CustomTorques)
+cmake_minimum_required(VERSION 2.8)
+
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+SET(FLAIR_USE_FILTER TRUE)
+SET(FLAIR_USE_SENSOR_ACTUATOR TRUE)
+SET(FLAIR_USE_META TRUE)
+SET(FLAIR_USE_VRPN TRUE)
+
+include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/GlobalCmakeFlair.cmake)
+include(${FLAIR_USE_FILE})
+
+SET(SRC_FILES
+	${CMAKE_SOURCE_DIR}/src/main.cpp
+	${CMAKE_SOURCE_DIR}/src/MyApp.cpp
+)
+
+INCLUDE_DIRECTORIES(
+	${FLAIR_INCLUDE_DIR}
+)
+
+#real time executable
+ADD_EXECUTABLE(${PROJECT_NAME}_rt
+	${SRC_FILES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}_rt ${FLAIR_LIBRARIES_RT})
+
+#non real time executable
+ADD_EXECUTABLE(${PROJECT_NAME}_nrt
+	${SRC_FILES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}_nrt ${FLAIR_LIBRARIES_NRT})
Index: trunk/demos/Skeletons/CustomTorques/README
===================================================================
--- trunk/demos/Skeletons/CustomTorques/README	(revision 43)
+++ trunk/demos/Skeletons/CustomTorques/README	(revision 43)
@@ -0,0 +1,8 @@
+CustomTorques
+
+This is a minimal skeleton to use the UavStateMachine class.
+It shows how to set custom torques, to use our own control laws.
+
+The custom torque mode is activated by clicking on the "start CustomTorques" button on ground station, or with R1 button on the Dualshock 3.
+The custom torque mode is deactivated by clicking on the "stop CustomTorques" button on ground station, or with X button on the Dualshock 3.
+
Index: trunk/demos/Skeletons/CustomTorques/src/MyApp.cpp
===================================================================
--- trunk/demos/Skeletons/CustomTorques/src/MyApp.cpp	(revision 43)
+++ trunk/demos/Skeletons/CustomTorques/src/MyApp.cpp	(revision 43)
@@ -0,0 +1,95 @@
+//  created:    2015/10/29
+//  filename:   Uav.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    skeleton to use UavStateMachine with custom torques only
+//
+//
+/*********************************************************************/
+
+//include files, add yours
+#include "MyApp.h"
+#include <GridLayout.h>
+#include <PushButton.h>
+#include <MetaDualShock3.h>
+#include <FrameworkManager.h>
+
+//namespaces, add others if necessary (filter, sensor, actuator)
+using namespace std;
+using namespace flair::core;
+using namespace flair::gui;
+using namespace flair::meta;
+using namespace flair::sensor;
+
+MyApp::MyApp(Uav* uav,TargetController *controller): UavStateMachine(uav,controller), behaviourMode(BehaviourMode_t::Default) {
+    start_CustomTorques=new PushButton(GetButtonsLayout()->NewRow(),"start CustomTorques");
+    stop_CustomTorques=new PushButton(GetButtonsLayout()->NewRow(),"stop CustomTorques");
+}
+
+MyApp::~MyApp() {
+}
+
+//this method is called by UavStateMachine::Run (main loop) when TorqueMode is Custom
+void MyApp::ComputeCustomTorques(Euler &torques) {
+    //compute the torques, with your own control laws
+
+    //torques.roll=;
+    //torques.pitch=;
+    //torques.yaw=;
+}
+
+void MyApp::SignalEvent(Event_t event) {
+    UavStateMachine::SignalEvent(event);
+    switch(event) {
+    case Event_t::TakingOff:
+        //always take off in default mode
+        behaviourMode=BehaviourMode_t::Default;
+        break;
+    case Event_t::EnteringFailSafeMode:
+        //return to default mode
+        Thread::Info("CustomTorques: stop\n");
+        behaviourMode=BehaviourMode_t::Default;
+        break;
+    }
+}
+
+void MyApp::ExtraCheckPushButton(void) {
+    if(start_CustomTorques->Clicked() && (behaviourMode!=BehaviourMode_t::CustomTorques)) {
+        StartCustomTorques();
+    }
+
+    if(stop_CustomTorques->Clicked() && (behaviourMode==BehaviourMode_t::CustomTorques)) {
+        StopCustomTorques();
+    }
+}
+
+void MyApp::ExtraCheckJoystick(void) {
+    //R1
+    if(GetJoystick()->IsButtonPressed(9) && (behaviourMode!=BehaviourMode_t::CustomTorques)) {
+        StartCustomTorques();
+    }
+
+    //stop is not managed here, it is done in UavStateMachine with cross button
+    //pushing cross button will enter fail safe mode and signal the EnteringFailSafeMode event
+}
+
+void MyApp::StartCustomTorques(void) {
+    //ask UavStateMachine to enter in custom torques
+    if (SetTorqueMode(TorqueMode_t::Custom)) {
+        Thread::Info("CustomTorques: start\n");
+    } else {
+        Thread::Warn("CustomTorques: could not start\n");
+        return;
+    }
+
+    behaviourMode=BehaviourMode_t::CustomTorques;
+}
+
+void MyApp::StopCustomTorques(void) {
+    //just ask to enter fail safe mode
+    EnterFailSafeMode();
+}
Index: trunk/demos/Skeletons/CustomTorques/src/MyApp.h
===================================================================
--- trunk/demos/Skeletons/CustomTorques/src/MyApp.h	(revision 43)
+++ trunk/demos/Skeletons/CustomTorques/src/MyApp.h	(revision 43)
@@ -0,0 +1,51 @@
+//  created:    2015/10/29
+//  filename:   MyApp.h
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    skeleton to use UavStateMachine with custom torques only
+//
+//
+/*********************************************************************/
+
+#ifndef MYAPP_H
+#define MYAPP_H
+
+#include <UavStateMachine.h>
+
+namespace framework {
+    namespace gui {
+        class PushButton;
+    }
+    namespace sensor {
+        class TargetController;
+    }
+}
+
+class MyApp : public flair::meta::UavStateMachine {
+    public:
+        MyApp(flair::meta::Uav* uav,flair::sensor::TargetController *controller);
+        ~MyApp();
+
+    private:
+        enum class BehaviourMode_t {
+            Default,
+            CustomTorques
+        };
+
+        BehaviourMode_t behaviourMode;
+
+        void ComputeCustomTorques(flair::core::Euler &torques);
+        void StartCustomTorques(void);
+        void StopCustomTorques(void);
+        void ExtraCheckPushButton(void);
+        void ExtraCheckJoystick(void);
+        void SignalEvent(Event_t event);
+
+        flair::gui::PushButton *start_CustomTorques,*stop_CustomTorques;
+};
+
+#endif // MYAPP_H
Index: trunk/demos/Skeletons/CustomTorques/src/main.cpp
===================================================================
--- trunk/demos/Skeletons/CustomTorques/src/main.cpp	(revision 43)
+++ trunk/demos/Skeletons/CustomTorques/src/main.cpp	(revision 43)
@@ -0,0 +1,97 @@
+//  created:    2015/10/27
+//  filename:   main.cpp
+//
+//  author:     Guillaume Sanahuja
+//              Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+//  version:    $Id: $
+//
+//  purpose:    exemple de code uav
+//
+//
+/*********************************************************************/
+
+#include "MyApp.h"
+#include <UavFactory.h>
+#include <FrameworkManager.h>
+#include <TargetEthController.h>
+#include <stdio.h>
+#include <tclap/CmdLine.h>
+
+using namespace TCLAP;
+using namespace std;
+using namespace flair::core;
+using namespace flair::meta;
+using namespace flair::sensor;
+
+string uav_type;
+string log_path;
+int port;
+int ds3port;
+string xml_file;
+string name;
+string address;
+
+void parseOptions(int argc, char** argv);
+
+
+int main(int argc, char* argv[]) {
+    parseOptions(argc,argv);
+
+    FrameworkManager *manager;
+    manager= new FrameworkManager(name);
+    manager->SetupConnection(address,port);
+    manager->SetupUserInterface(xml_file);
+    manager->SetupLogger(log_path);
+
+    Uav* drone=CreateUav(manager,name,uav_type);
+    TargetEthController *controller=new TargetEthController(manager,"Dualshock3",ds3port);
+    MyApp* app=new MyApp(drone,controller);
+
+    app->Start();
+    app->Join();
+
+    delete manager;
+}
+
+void parseOptions(int argc, char** argv) {
+	try {
+
+        CmdLine cmd("Command description message", ' ', "0.1");
+
+        ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
+        cmd.add( nameArg );
+
+        ValueArg<string> typeArg("t","type","uav type: ardrone2, hds_x4, hds_x8, hds_xufo, x4_simu, x8_simu or x4_simux (with x the number of the simulated uav)",true,"hds_x4","string");
+        cmd.add( typeArg );
+
+        ValueArg<string> xmlArg("x","xml","fichier xml",true,"./reglages.xml","string");
+        cmd.add( xmlArg );
+
+        ValueArg<string> logsArg("l","logs","repertoire des logs",true,"/media/ram","string");
+        cmd.add( logsArg );
+
+        ValueArg<int> portArg("p","port","port pour station sol",true,9000,"int");
+        cmd.add( portArg );
+
+        ValueArg<string> addressArg("a","address","addresse station sol",true,"127.0.0.1","string");
+        cmd.add( addressArg );
+
+        ValueArg<int> ds3portArg("d","ds3_port","port pour ds3",false,20000,"int");
+        cmd.add( ds3portArg );
+
+        cmd.parse( argc, argv );
+
+        // Get the value parsed by each arg.
+        log_path = logsArg.getValue();
+        port=portArg.getValue();
+        ds3port=ds3portArg.getValue();
+        xml_file = xmlArg.getValue();
+        name=nameArg.getValue();
+        uav_type=typeArg.getValue();
+        address=addressArg.getValue();
+
+	} catch (ArgException &e) { // catch any exceptions
+        cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
+	}
+}
