Commit d68e00e4 authored by Paul Beuchat's avatar Paul Beuchat
Browse files

Removed coordinator GUI due to decision to change coordinator architecture

parent 4534dc5b
......@@ -42,10 +42,6 @@ set(MY_GUI_LIB_PATH_INC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/include)
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)
# CoorindatorGUI -- Add src and includes
set(COORDINATOR_GUI_LIB_PATH_SRC ${PROJECT_SOURCE_DIR}/GUI_Qt/coordinatorGUI/src)
set(COORDINATOR_GUI_LIB_PATH_INC ${PROJECT_SOURCE_DIR}/GUI_Qt/coordinatorGUI/include)
# GUI -- Resource file
set(MY_RESOURCE_FILE_QRC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc)
......@@ -89,17 +85,6 @@ 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})
# CoordinatorGUI -- Special Qt sources that need to be wrapped before being compiled
set(SRC_HDRS_QOBJECT_COORDINATOR_GUI
${COORDINATOR_GUI_LIB_PATH_INC}/MainWindow.h
${COORDINATOR_GUI_LIB_PATH_INC}/rosNodeThread.h
)
# CoordinatorGUI -- wrap UI file and QOBJECT files
qt5_wrap_ui(UIS_HDRS_COORDINATOR_GUI ${COORDINATOR_GUI_LIB_PATH_SRC}/MainWindow.ui)
qt5_wrap_cpp(SRC_MOC_HDRS_COORDINATOR_GUI ${SRC_HDRS_QOBJECT_COORDINATOR_GUI})
## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
......@@ -217,7 +202,6 @@ 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 ${COORDINATOR_GUI_LIB_PATH_INC} # CoordinatorGUI -- include headers from GUI in package
LIBRARIES
CATKIN_DEPENDS roscpp rospy std_msgs rosbag roslib
DEPENDS
......@@ -233,7 +217,6 @@ 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
${COORDINATOR_GUI_LIB_PATH_INC} # CoordinatorGUI -- include directory inside GUI folder
${catkin_INCLUDE_DIRS}
include
include/nodes
......@@ -291,12 +274,6 @@ set(MY_CPP_SOURCES_STUDENT_GUI # compilation of sources
${STUDENT_GUI_LIB_PATH_SRC}/rosNodeThread.cpp
)
# CoordinatorGUI -- Add sources here
set(MY_CPP_SOURCES_COORDINATOR_GUI # compilation of sources
${COORDINATOR_GUI_LIB_PATH_SRC}/MainWindow.cpp
${COORDINATOR_GUI_LIB_PATH_SRC}/main.cpp
${COORDINATOR_GUI_LIB_PATH_SRC}/rosNodeThread.cpp
)
# GUI -- Add executables here
......@@ -307,9 +284,6 @@ qt5_use_modules(my_GUI Widgets)
add_executable(student_GUI ${MY_CPP_SOURCES_STUDENT_GUI} ${UIS_HDRS_STUDENT_GUI} ${SRC_MOC_HDRS_STUDENT_GUI})
qt5_use_modules(student_GUI Widgets)
# CoordinatorGUI -- Add executables here
add_executable(coordinator_GUI ${MY_CPP_SOURCES_COORDINATOR_GUI} ${UIS_HDRS_COORDINATOR_GUI} ${SRC_MOC_HDRS_COORDINATOR_GUI})
qt5_use_modules(coordinator_GUI Widgets)
......@@ -328,9 +302,6 @@ add_dependencies(my_GUI d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGE
# StudentGUI-- dependencies
add_dependencies(student_GUI d_fall_pps_generate_messages_cpp ${catkin_EXPORTED_TARGETS})
# CoordinatorGUI-- dependencies
add_dependencies(coordinator_GUI 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
......@@ -372,10 +343,6 @@ target_link_libraries(my_GUI ${catkin_LIBRARIES})
target_link_libraries(student_GUI Qt5::Widgets) # GUI -- let my_GUI have acesss to Qt stuff
target_link_libraries(student_GUI ${catkin_LIBRARIES})
# CoordinatorGUI -- link libraries
target_link_libraries(coordinator_GUI Qt5::Widgets) # GUI -- let coordinator_GUI have acesss to Qt stuff
target_link_libraries(coordinator_GUI ${catkin_LIBRARIES})
#############
## Install ##
......
#-------------------------------------------------
#
# Project created by QtCreator 2017-08-21T11:01:25
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = studentGUI
TEMPLATE = app
INCLUDEPATH += $$PWD/include
CONFIG += c++11
SOURCES += \
src/main.cpp \
src/MainWindow.cpp
HEADERS += \
include/MainWindow.h \
FORMS += \
src/MainWindow.ui
// Copyright (C) 2017, ETH Zurich, D-ITET, Paul Beuchat, 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:
// Main window of the Student's GUI
//
// ----------------------------------------------------------------------------------
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <std_msgs/Int32.h>
#include <std_msgs/Float32.h>
#include "rosNodeThread.h"
#include "d_fall_pps/CrazyflieContext.h"
#include "d_fall_pps/CrazyflieData.h"
#include "d_fall_pps/Setpoint.h"
// Types of controllers being used:
#define SAFE_CONTROLLER 0
#define CUSTOM_CONTROLLER 1
// Commands for CrazyRadio
#define CMD_RECONNECT 0
#define CMD_DISCONNECT 1
// CrazyRadio states:
#define CONNECTED 0
#define CONNECTING 1
#define DISCONNECTED 2
// The constants that "command" changes in the
// operation state of this agent. These "commands"
// are sent from this GUI node to the "PPSClient"
// node where the command is enacted
#define CMD_USE_SAFE_CONTROLLER 1
#define CMD_USE_CUSTOM_CONTROLLER 2
#define CMD_CRAZYFLY_TAKE_OFF 3
#define CMD_CRAZYFLY_LAND 4
#define CMD_CRAZYFLY_MOTORS_OFF 5
// Flying States
#define STATE_MOTORS_OFF 1
#define STATE_TAKE_OFF 2
#define STATE_FLYING 3
#define STATE_LAND 4
// Battery states
#define BATTERY_STATE_NORMAL 0
#define BATTERY_STATE_LOW 1
// For which controller parameters to load
#define LOAD_YAML_SAFE_CONTROLLER_AGENT 1
#define LOAD_YAML_CUSTOM_CONTROLLER_AGENT 2
#define LOAD_YAML_SAFE_CONTROLLER_COORDINATOR 3
#define LOAD_YAML_CUSTOM_CONTROLLER_COORDINATOR 4
// Universal constants
#define PI 3.141592653589
#define RAD2DEG 180.0/PI
#define DEG2RAD PI/180.0
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(int argc, char **argv, QWidget *parent = 0);
~MainWindow();
private slots:
void updateNewViconData(const ptrToMessage& p_msg);
void on_RF_Connect_button_clicked();
void on_take_off_button_clicked();
void on_land_button_clicked();
void on_motors_OFF_button_clicked();
void on_set_setpoint_button_clicked();
void on_set_setpoint_button_2_clicked();
void on_RF_disconnect_button_clicked();
void on_load_custom_yaml_button_clicked();
void on_load_safe_yaml_button_clicked();
void on_en_custom_controller_clicked();
void on_en_safe_controller_clicked();
void on_customButton_1_clicked();
void on_customButton_2_clicked();
void on_customButton_3_clicked();
private:
Ui::MainWindow *ui;
rosNodeThread* m_rosNodeThread;
int m_radio_status;
float m_battery_voltage;
int m_battery_level;
std::string m_ros_namespace;
ros::Timer m_timer_yaml_file_for_safe_controller;
ros::Timer m_timer_yaml_file_for_custom_controlller;
int m_student_id;
CrazyflieContext m_context;
Setpoint m_safe_setpoint;
Setpoint m_custom_setpoint;
int m_battery_state;
ros::Publisher crazyRadioCommandPublisher;
ros::Subscriber crazyRadioStatusSubscriber;
ros::Publisher PPSClientCommandPublisher;
ros::Subscriber CFBatterySubscriber;
ros::Subscriber flyingStateSubscriber;
ros::Subscriber batteryStateSubscriber;
ros::Publisher controllerSetpointPublisher;
ros::Subscriber safeSetpointSubscriber;
ros::Publisher customSetpointPublisher;
ros::Subscriber customSetpointSubscriber;
ros::Publisher PPSClientStudentCustomButtonPublisher;
ros::Subscriber DBChangedSubscriber;
// > For publishing a message that requests the
// YAML parameters to be re-loaded from file
// > The message contents specify which controller
// the parameters should be re-loaded for
ros::Publisher requestLoadControllerYamlPublisher;
// Subscriber for locking the load the controller YAML
// parameters when the Coordintor GUI requests a load
ros::Subscriber requestLoadControllerYaml_from_my_GUI_Subscriber;
ros::Subscriber controllerUsedSubscriber;
ros::ServiceClient centralManager;
// callbacks
void crazyRadioStatusCallback(const std_msgs::Int32& msg);
void CFBatteryCallback(const std_msgs::Float32& msg);
void flyingStateChangedCallback(const std_msgs::Int32& msg);
void safeSetpointCallback(const Setpoint& newSetpoint);
void customSetpointCallback(const Setpoint& newSetpoint);
void DBChangedCallback(const std_msgs::Int32& msg);
void customYamlFileTimerCallback(const ros::TimerEvent&);
void safeYamlFileTimerCallback(const ros::TimerEvent&);
void requestLoadControllerYaml_from_my_GUI_Callback(const std_msgs::Int32& msg);
void controllerUsedChangedCallback(const std_msgs::Int32& msg);
void batteryStateChangedCallback(const std_msgs::Int32& msg);
float fromVoltageToPercent(float voltage);
void updateBatteryVoltage(float battery_voltage);
void setCrazyRadioStatus(int radio_status);
void loadCrazyflieContext();
void coordinatesToLocal(CrazyflieData& cf);
void initialize_custom_setpoint();
void disableGUI();
void enableGUI();
void highlightSafeControllerTab();
void highlightCustomControllerTab();
bool setpointInsideBox(Setpoint setpoint, CrazyflieContext context);
Setpoint correctSetpointBox(Setpoint setpoint, CrazyflieContext context);
const std::vector<float> m_cutoff_voltages {3.1966, 3.2711, 3.3061, 3.3229, 3.3423, 3.3592, 3.3694, 3.385, 3.4006, 3.4044, 3.4228, 3.4228, 3.4301, 3.4445, 3.4531, 3.4677, 3.4705, 3.4712, 3.4756, 3.483, 3.4944, 3.5008, 3.5008, 3.5084, 3.511, 3.5122, 3.5243, 3.5329, 3.5412, 3.5529, 3.5609, 3.5625, 3.5638, 3.5848, 3.6016, 3.6089, 3.6223, 3.628, 3.6299, 3.6436, 3.6649, 3.6878, 3.6983, 3.7171, 3.7231, 3.7464, 3.7664, 3.7938, 3.8008, 3.816, 3.8313, 3.8482, 3.866, 3.8857, 3.8984, 3.9159, 3.9302, 3.9691, 3.997, 4.14 };
};
#endif // MAINWINDOW_H
// 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:
// Takes care of creating a ros node thread.
//
// ----------------------------------------------------------------------------------
#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
// 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:
// Main program of the Student's GUI
//
// ----------------------------------------------------------------------------------
#include "MainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w(argc, argv);
w.show();
return a.exec();
}
// 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:
// Takes care of creating a ros node thread.
//
// ----------------------------------------------------------------------------------
#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); // student_GUI is the name of this node
if (!ros::master::check())
{
ROS_ERROR("Master not found, please check teacher computer is running and try again");
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::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();
// ROS_INFO("RUNNING");
// sim_velocity.publish(cmd_msg);
ros::spinOnce();
loop_rate.sleep();
delete pMutex;
} // do ros things.
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment