diff --git a/pps_ws/src/d_fall_pps/CMakeLists.txt b/pps_ws/src/d_fall_pps/CMakeLists.txt
index 57c8f45edccdada6024ffb027208231893ba465e..f5d041d1ff847574a198b95820886186f0796250 100755
--- a/pps_ws/src/d_fall_pps/CMakeLists.txt
+++ b/pps_ws/src/d_fall_pps/CMakeLists.txt
@@ -55,23 +55,29 @@ find_package(Qt5Gui REQUIRED)
 find_package(Qt5Svg REQUIRED)
 
 
-# GUI -- Add src and includes
+
+# GUI -- Add src, includes, and resources
 set(MY_GUI_LIB_PATH_SRC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/src)
 set(MY_GUI_LIB_PATH_INC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/include)
-
-# GUI -- Resource file
 set(MY_RESOURCE_FILE_QRC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc)
 
 
 
-# StudentGUI -- Add src and includes
+# StudentGUI -- Add src, includes, and resources
 set(STUDENT_GUI_LIB_PATH_SRC ${PROJECT_SOURCE_DIR}/GUI_Qt/studentGUI/src)
 set(STUDENT_GUI_LIB_PATH_INC ${PROJECT_SOURCE_DIR}/GUI_Qt/studentGUI/include)
-
-# StudentGUI -- Resource file
 set(STUDENT_RESOURCE_FILE_QRC ${PROJECT_SOURCE_DIR}/GUI_Qt/studentGUI/studentgui.qrc)
 
 
+
+# Flying Agent GUI -- Add src, includes, forms, and resources
+set(FLYING_AGENT_GUI_LIB_PATH_SRC ${PROJECT_SOURCE_DIR}/GUI_Qt/flyingAgentGUI/src)
+set(FLYING_AGENT_GUI_LIB_PATH_INC ${PROJECT_SOURCE_DIR}/GUI_Qt/flyingAgentGUI/include)
+set(FLYING_AGENT_GUI_LIB_PATH_FORMS ${PROJECT_SOURCE_DIR}/GUI_Qt/flyingAgentGUI/forms)
+set(FLYING_AGENT_GUI_RESOURCE_FILE_QRC ${PROJECT_SOURCE_DIR}/GUI_Qt/flyingAgentGUI/flyingagentgui.qrc)
+
+
+
 # #set the default path for built executables to the "bin" directory
 # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 # #set the default path for built libraries to the "lib" directory
@@ -80,6 +86,8 @@ set(STUDENT_RESOURCE_FILE_QRC ${PROJECT_SOURCE_DIR}/GUI_Qt/studentGUI/studentgui
 # GUI -- need c++11 for some things
 add_definitions(-std=c++11)
 
+
+
 # GUI -- Special Qt sources that need to be wrapped before being compiled
 # they have the Qt macro QOBJECT inside, the MOC cpp file needs to be done manually
 set(SRC_HDRS_QOBJECT_GUI
@@ -90,32 +98,59 @@ set(SRC_HDRS_QOBJECT_GUI
   ${MY_GUI_LIB_PATH_INC}/rosNodeThread.h
   ${MY_GUI_LIB_PATH_INC}/CFLinker.h
   )
-
 # GUI -- wrap UI file and QOBJECT files
 qt5_wrap_ui(UIS_HDRS_GUI ${MY_GUI_LIB_PATH_SRC}/mainguiwindow.ui)
 qt5_wrap_cpp(SRC_MOC_HDRS_GUI ${SRC_HDRS_QOBJECT_GUI})
-
 # GUI -- wrap resource file qrc->rcc
 qt5_add_resources(MY_RESOURCE_FILE_RCC ${MY_RESOURCE_FILE_QRC})
 
 
 
 # StudentGUI -- Special Qt sources that need to be wrapped before being compiled
-
 set(SRC_HDRS_QOBJECT_STUDENT_GUI
   ${STUDENT_GUI_LIB_PATH_INC}/MainWindow.h
   ${STUDENT_GUI_LIB_PATH_INC}/rosNodeThread.h
   )
-
 # StudentGUI -- wrap UI file and QOBJECT files
 qt5_wrap_ui(UIS_HDRS_STUDENT_GUI ${STUDENT_GUI_LIB_PATH_SRC}/MainWindow.ui)
 qt5_wrap_cpp(SRC_MOC_HDRS_STUDENT_GUI ${SRC_HDRS_QOBJECT_STUDENT_GUI})
-
 # GUI -- wrap resource file qrc->rcc
 qt5_add_resources(STUDENT_RESOURCE_FILE_RCC ${STUDENT_RESOURCE_FILE_QRC})
 
 
 
+# Flying Agent GUI
+# - Special Qt sources that need to be wrapped before being compiled
+#   they have the Qt macro QOBJECT inside, the MOC cpp file needs to
+#   be done manually
+set(SRC_HDRS_QOBJECT_FLYING_AGENT_GUI
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/connectstartstopbar.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/controllertabs.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/coordinator.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/coordinatorrow.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/enablecontrollerloadyamlbar.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/mainwindow.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/rosNodeThread.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/safecontrollertab.h
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}/topbanner.h
+  )
+# Flying Agent GUI -- wrap UI file and QOBJECT files
+qt5_wrap_ui(UIS_HDRS_FLYING_AGENT_GUI
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/connectstartstopbar.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/controllertabs.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/coordinator.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/coordinatorrow.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/enablecontrollerloadyamlbar.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/mainwindow.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/safecontrollertab.ui
+  ${FLYING_AGENT_GUI_LIB_PATH_FORMS}/topbanner.ui
+  )
+qt5_wrap_cpp(SRC_MOC_HDRS_FLYING_AGENT_GUI ${SRC_HDRS_QOBJECT_FLYING_AGENT_GUI})
+# Flying Agent GUI -- wrap resource file qrc->rcc
+qt5_add_resources(FLYING_AGENT_GUI_RESOURCE_FILE_RCC ${MY_RESOURCE_FILE_QRC})
+
+
+
 ## Uncomment this if the package has a setup.py. This macro ensures
 ## modules and global scripts declared therein get installed
 ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
@@ -234,6 +269,7 @@ generate_messages(
 catkin_package(
   INCLUDE_DIRS include ${MY_GUI_LIB_PATH_INC}            # GUI -- include headers from GUI in package
   INCLUDE_DIRS include ${STUDENT_GUI_LIB_PATH_INC}       # StudentGUI -- include headers from GUI in package
+  INCLUDE_DIRS include ${FLYING_AGENT_GUI_LIB_PATH_INC}       # StudentGUI -- include headers from GUI in package
   LIBRARIES
   CATKIN_DEPENDS roscpp rospy std_msgs rosbag roslib
   DEPENDS
@@ -249,6 +285,7 @@ catkin_package(
 include_directories(
   ${MY_GUI_LIB_PATH_INC}            # GUI -- include directory inside GUI folder
   ${STUDENT_GUI_LIB_PATH_INC}       # StudentGUI -- include directory inside GUI folder
+  ${FLYING_AGENT_GUI_LIB_PATH_INC}       # StudentGUI -- include directory inside GUI folder
   ${catkin_INCLUDE_DIRS}
   include
   include/nodes
@@ -304,6 +341,8 @@ set(MY_CPP_SOURCES_GUI              # compilation of sources
     ${MY_GUI_LIB_PATH_SRC}/centerMarker.cpp
     )
 
+
+
 # StudentGUI -- Add sources here
 set(MY_CPP_SOURCES_STUDENT_GUI              # compilation of sources
     ${STUDENT_GUI_LIB_PATH_SRC}/MainWindow.cpp
@@ -313,15 +352,38 @@ set(MY_CPP_SOURCES_STUDENT_GUI              # compilation of sources
 
 
 
+# FLYING AGENT GUI -- Add sources here
+set(MY_CPP_SOURCES_FLYING_AGENT_GUI         # compilation of sources
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/connectstartstopbar.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/controllertabs.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/coordinator.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/coordinatorrow.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/enablecontrollerloadyamlbar.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/main.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/mainwindow.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/rosNodeThread.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/safecontrollertab.cpp
+    ${FLYING_AGENT_GUI_LIB_PATH_SRC}/topbanner.cpp
+    )
+
+
+
 # GUI -- Add executables here
 add_executable(my_GUI ${MY_CPP_SOURCES_GUI} ${UIS_HDRS_GUI} ${SRC_MOC_HDRS_GUI} ${MY_RESOURCE_FILE_RCC})
 qt5_use_modules(my_GUI Widgets)
 
+
+
 # StudentGUI -- Add executables here
 add_executable(student_GUI ${MY_CPP_SOURCES_STUDENT_GUI} ${UIS_HDRS_STUDENT_GUI} ${SRC_MOC_HDRS_STUDENT_GUI} ${STUDENT_RESOURCE_FILE_RCC})
 qt5_use_modules(student_GUI Widgets)
 
 
+# FLYING AGENT GUI -- Add executables here
+add_executable(flyingAgentGUI ${MY_CPP_SOURCES_FLYING_AGENT_GUI} ${UIS_HDRS_FLYING_AGENT_GUI} ${SRC_MOC_HDRS_FLYING_AGENT_GUI} ${FLYING_AGENT_GUI_RESOURCE_FILE_RCC})
+qt5_use_modules(flyingAgentGUI Widgets)
+
+
 
 if(VICON_LIBRARY)
 	add_dependencies(ViconDataPublisher       d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
@@ -337,12 +399,23 @@ add_dependencies(TuningControllerService  d_fall_pps_generate_messages_cpp ${cat
 add_dependencies(CentralManagerService    d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
 add_dependencies(ParameterService         d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
 
+
+
 # GUI-- dependencies
 add_dependencies(my_GUI d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
 
+
+
 # StudentGUI-- dependencies
 add_dependencies(student_GUI d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
 
+
+
+# FLYING AGENT GUI-- dependencies
+add_dependencies(flyingAgentGUI d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
+
+
+
 ## Rename C++ executable without prefix
 ## The above recommended prefix causes long target names, the following renames the
 ## target back to the shorter version for ease of user use
@@ -380,6 +453,7 @@ target_link_libraries(CentralManagerService    ${catkin_LIBRARIES})
 target_link_libraries(ParameterService         ${catkin_LIBRARIES})
 
 
+
 # GUI -- link libraries
 target_link_libraries(my_GUI Qt5::Widgets) # GUI -- let my_GUI have acesss to Qt stuff
 target_link_libraries(my_GUI Qt5::Svg)
@@ -388,11 +462,20 @@ target_link_libraries(my_GUI Qt5::Svg)
 # target_link_libraries(my_GUI my_library)
 target_link_libraries(my_GUI ${catkin_LIBRARIES})
 
+
+
 # StudentGUI -- link libraries
-target_link_libraries(student_GUI Qt5::Widgets) # GUI -- let my_GUI have acesss to Qt stuff
+target_link_libraries(student_GUI Qt5::Widgets) # GUI -- let student_GUI have acesss to Qt stuff
 target_link_libraries(student_GUI ${catkin_LIBRARIES})
 
 
+
+# Flying Agent GUI -- link libraries
+target_link_libraries(flyingAgentGUI Qt5::Widgets) # GUI -- let flyingAgentGUI have acesss to Qt stuff
+target_link_libraries(flyingAgentGUI ${catkin_LIBRARIES})
+
+
+
 #############
 ## Install ##
 #############
diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/coordinatorrow.h b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/coordinatorrow.h
index 85602b0a82ee0c9d1b71494d9605c582c04a4e77..8e5ef66452562e6573b2fd28f71c00492ca8ecf9 100644
--- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/coordinatorrow.h
+++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/coordinatorrow.h
@@ -45,8 +45,11 @@
 #include <ros/network.h>
 #include <ros/package.h>
 
+#include "d_fall_pps/AreaBounds.h"
 #include "d_fall_pps/CrazyflieContext.h"
 #include "d_fall_pps/CMQuery.h"
+
+using namespace d_fall_pps;
 #endif
 
 // TYPES OF CONTROLLER BEING USED
diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/rosNodeThread.h b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/rosNodeThread.h
new file mode 100644
index 0000000000000000000000000000000000000000..8937da754acd40dab242e564ce74ed82ebe08ea0
--- /dev/null
+++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/rosNodeThread.h
@@ -0,0 +1,92 @@
+//    Copyright (C) 2017, ETH Zurich, D-ITET, Angel Romero
+//
+//    This file is part of D-FaLL-System.
+//    
+//    D-FaLL-System is free software: you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation, either version 3 of the License, or
+//    (at your option) any later version.
+//    
+//    D-FaLL-System is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//    GNU General Public License for more details.
+//    
+//    You should have received a copy of the GNU General Public License
+//    along with D-FaLL-System.  If not, see <http://www.gnu.org/licenses/>.
+//    
+//
+//    ----------------------------------------------------------------------------------
+//    DDDD        FFFFF        L     L           SSSS  Y   Y   SSSS  TTTTT  EEEEE  M   M
+//    D   D       F      aaa   L     L          S       Y Y   S        T    E      MM MM
+//    D   D  ---  FFFF  a   a  L     L     ---   SSS     Y     SSS     T    EEE    M M M
+//    D   D       F     a  aa  L     L              S    Y        S    T    E      M   M
+//    DDDD        F      aa a  LLLL  LLLL       SSSS     Y    SSSS     T    EEEEE  M   M
+//
+//
+//    DESCRIPTION:
+//    Creates a thread that runs the ros node.
+//
+//    ----------------------------------------------------------------------------------
+
+
+#ifndef ___ROSNODETHREAD_H___
+#define ___ROSNODETHREAD_H___
+
+#include <QtCore>
+#include <QThread>
+#include <QStringList>
+#include <stdlib.h>
+#include <QMutex>
+#include <iostream>
+#include "assert.h"
+
+#include <ros/ros.h>
+#include <ros/network.h>
+//#include "d_fall_pps/UnlabeledMarker.h"
+//#include "d_fall_pps/CrazyflieData.h"
+//#include "d_fall_pps/ViconData.h"
+
+//using namespace d_fall_pps;
+
+//typedef ViconData::ConstPtr ptrToMessage;
+
+//Q_DECLARE_METATYPE(ptrToMessage)
+
+
+class rosNodeThread : public QObject {
+	Q_OBJECT
+public:
+    explicit rosNodeThread(int argc, char **pArgv, const char * node_name, QObject *parent = 0);
+    virtual ~rosNodeThread();
+
+    bool init();
+
+    // void messageCallback(const ViconData& data);
+    //void messageCallback(const ptrToMessage& p_msg);
+
+    ros::ServiceClient m_read_db_client;
+    ros::ServiceClient m_update_db_client;
+    ros::ServiceClient m_command_db_client;
+
+signals:
+
+    //void newViconData(const ptrToMessage& p_msg);
+
+public slots:
+    void run();
+
+private:
+    int m_Init_argc;
+    char** m_pInit_argv;
+    const char * m_node_name;
+
+    QThread * m_pThread;
+
+    //ViconData m_vicon_data;
+
+    //ros::Subscriber m_vicon_subscriber;
+    // ros::Publisher  sim_velocity;
+};
+#endif
+
diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/coordinatorrow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/coordinatorrow.cpp
index 6eeccdebb8335e94485c5b09f12330d59ac810d2..3710d507dbcb48be5a4146b6e9445cd7d5d94fa7 100644
--- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/coordinatorrow.cpp
+++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/coordinatorrow.cpp
@@ -595,9 +595,9 @@ void CoordinatorRow::loadCrazyflieContext()
     contextCall.request.studentID = my_agentID;
     //ROS_INFO_STREAM("StudentID:" << my_agentID);
 
-    centralManager.waitForExistence(ros::Duration(-1));
+    centralManagerDatabaseService.waitForExistence(ros::Duration(-1));
 
-    if(centralManager.call(contextCall))
+    if(centralManagerDatabaseService.call(contextCall))
     {
         my_context = contextCall.response.crazyflieContext;
         ROS_INFO_STREAM("[Coordinator Row GUI] CrazyflieContext:\n" << my_context);
@@ -710,7 +710,7 @@ void CoordinatorRow::on_enable_flying_button_clicked()
 #ifdef CATKIN_MAKE
     std_msgs::Int32 msg;
     msg.data = CMD_CRAZYFLY_TAKE_OFF;
-    this->PPSClientCommandPublisher.publish(msg);
+    this->flyingStateCommandPublisher.publish(msg);
 #endif
 }
 
@@ -719,7 +719,7 @@ void CoordinatorRow::on_disable_flying_button_clicked()
 #ifdef CATKIN_MAKE
     std_msgs::Int32 msg;
     msg.data = CMD_CRAZYFLY_LAND;
-    this->PPSClientCommandPublisher.publish(msg);
+    this->flyingStateCommandPublisher.publish(msg);
 #endif
 }
 
@@ -728,6 +728,6 @@ void CoordinatorRow::on_motors_off_button_clicked()
 #ifdef CATKIN_MAKE
     std_msgs::Int32 msg;
     msg.data = CMD_CRAZYFLY_MOTORS_OFF;
-    this->PPSClientCommandPublisher.publish(msg);
+    this->flyingStateCommandPublisher.publish(msg);
 #endif
 }
diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/main.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/main.cpp
index 4999c2c0ff6f96b8c2758573aeb11e8f38043779..6128395d912368b49592630919e4ff4ef2401d11 100644
--- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/main.cpp
+++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/main.cpp
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
     QApplication a(argc, argv);
     MainWindow w(argc, argv);
     w.show();
-    a.exec();
+    return a.exec();
     // ----------------------------------------------------------- //
 
 }
diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp
index 4f6e850b2c440d0356051f3827d5dccab96c51ad..edb8a1c85f6f033749dd56a70e5c69ac6f08064f 100644
--- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp
+++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp
@@ -37,7 +37,7 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
     ui(new Ui::MainWindow)
 {
 #ifdef CATKIN_MAKE
-    m_rosNodeThread = new rosNodeThread(argc, argv, "coordinatorGUI");
+    m_rosNodeThread = new rosNodeThread(argc, argv, "flyingAgentGUI");
 #endif
     ui->setupUi(this);
 
diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/rosNodeThread.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/rosNodeThread.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e4623dfff1b5f811c4ce45248a88ce25838ffa0
--- /dev/null
+++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/rosNodeThread.cpp
@@ -0,0 +1,130 @@
+//    Copyright (C) 2017, ETH Zurich, D-ITET, Angel Romero
+//
+//    This file is part of D-FaLL-System.
+//    
+//    D-FaLL-System is free software: you can redistribute it and/or modify
+//    it under the terms of the GNU General Public License as published by
+//    the Free Software Foundation, either version 3 of the License, or
+//    (at your option) any later version.
+//    
+//    D-FaLL-System is distributed in the hope that it will be useful,
+//    but WITHOUT ANY WARRANTY; without even the implied warranty of
+//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//    GNU General Public License for more details.
+//    
+//    You should have received a copy of the GNU General Public License
+//    along with D-FaLL-System.  If not, see <http://www.gnu.org/licenses/>.
+//    
+//
+//    ----------------------------------------------------------------------------------
+//    DDDD        FFFFF        L     L           SSSS  Y   Y   SSSS  TTTTT  EEEEE  M   M
+//    D   D       F      aaa   L     L          S       Y Y   S        T    E      MM MM
+//    D   D  ---  FFFF  a   a  L     L     ---   SSS     Y     SSS     T    EEE    M M M
+//    D   D       F     a  aa  L     L              S    Y        S    T    E      M   M
+//    DDDD        F      aa a  LLLL  LLLL       SSSS     Y    SSSS     T    EEEEE  M   M
+//
+//
+//    DESCRIPTION:
+//    Creates a thread that runs the ros node.
+//
+//    ----------------------------------------------------------------------------------
+
+
+#include "rosNodeThread.h"
+
+#include "d_fall_pps/CMRead.h"
+#include "d_fall_pps/CMUpdate.h"
+#include "d_fall_pps/CMCommand.h"
+
+
+rosNodeThread::rosNodeThread(int argc, char** pArgv, const char * node_name,  QObject* parent)
+    :   QObject(parent),
+        m_Init_argc(argc),
+        m_pInit_argv(pArgv),
+        m_node_name(node_name)
+{
+    /** Constructor for the node thread **/
+}
+
+rosNodeThread::~rosNodeThread()
+{
+    if (ros::isStarted())
+    {
+        ros::shutdown();
+        ros::waitForShutdown();
+    } // end if
+
+    m_pThread->wait();
+} // end destructor
+
+bool rosNodeThread::init()
+{
+    m_pThread = new QThread();
+    this->moveToThread(m_pThread); // QObject method
+
+    connect(m_pThread, SIGNAL(started()), this, SLOT(run()));
+    ros::init(m_Init_argc, m_pInit_argv, m_node_name); // flyingAgentGUI is the name of this node
+
+    if (!ros::master::check())
+    {
+        ROS_ERROR("No master found. Please make sure that there is a master roscore running");
+        return false;           // do not start without ros.
+    }
+
+    ros::start();
+    ros::Time::init();
+    ros::NodeHandle nh("~");
+
+    //m_vicon_subscriber = nh.subscribe("/ViconDataPublisher/ViconData", 100, &rosNodeThread::messageCallback, this);
+
+    // clients for db services:
+    m_read_db_client = nh.serviceClient<CMRead>("/CentralManagerService/Read", false);
+    m_update_db_client = nh.serviceClient<CMUpdate>("/CentralManagerService/Update", false);
+    m_command_db_client = nh.serviceClient<CMCommand>("/CentralManagerService/Command", false);
+
+    m_pThread->start();
+    return true;
+} // set up the thread
+
+//void rosNodeThread::messageCallback(const ptrToMessage& p_msg) // When a message arrives to the topic, this callback is executed
+//{
+//    emit newViconData(p_msg);   //pass the message to other places
+//}
+
+// void rosNodeThread::messageCallback(const ViconData& data) // When a message arrives to the topic, this callback is executed
+// {
+//     QMutex * pMutex = new QMutex();
+//     pMutex->lock();
+//     ROS_INFO_STREAM("ViconData: " << data.x << ", " << data.y << ", " << data.z);
+//     m_vicon_data.x = data.x;
+//     m_vicon_data.y = data.y;
+//     m_vicon_data.z = data.z;
+//     m_vicon_data.yaw = data.yaw;
+//     m_vicon_data.pitch = data.pitch;
+//     m_vicon_data.roll = data.roll;
+//     pMutex->unlock();
+//     delete pMutex;
+//     // Q_EMIT newViconData(m_vicon_data.x, m_vicon_data.y, m_vicon_data.z, m_vicon_data.yaw, m_vicon_data.pitch, m_vicon_data.roll);
+//     emit newViconData(m_vicon_data.x, m_vicon_data.y);
+// }
+
+void rosNodeThread::run()
+{
+    ros::Rate loop_rate(100);
+    QMutex * pMutex;
+    while (ros::ok())
+    {
+        pMutex = new QMutex();
+
+        // geometry_msgs::Twist cmd_msg;
+        pMutex->lock();
+        // cmd_msg.linear.x = m_speed;
+        // cmd_msg.angular.z = m_angle;
+        pMutex->unlock();
+
+        // sim_velocity.publish(cmd_msg);
+        ros::spinOnce();
+        loop_rate.sleep();
+        delete pMutex;
+    } // do ros things.
+}