diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h index b0914b963bdbbedf52f0f1610659e1c6f59b3a22..5c1e56bef1983e3fca9409a4ec6a56ea4a2d6f58 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h @@ -17,6 +17,8 @@ #include "d_fall_pps/CrazyflieDB.h" #include "d_fall_pps/CrazyflieEntry.h" +#include <std_msgs/Int32.h> + using namespace d_fall_pps; #endif @@ -142,6 +144,8 @@ private: std::vector<Marker*> markers_vector; std::vector<crazyFly*> crazyflies_vector; CFLinker* cf_linker; + + ros::Publisher DBChangedPublisher; #endif void updateComboBoxesCFs(); diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp index 875429e9deedd9021f74989fe25a4300b41d023a..eee31a0514571754ddd0d729d7d586245e5ea245 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp @@ -20,6 +20,10 @@ #include "d_fall_pps/CMUpdate.h" #include "d_fall_pps/CMCommand.h" #include "CentralManagerService.h" + +#include <ros/ros.h> +#include <ros/network.h> + #endif #include <string> @@ -191,6 +195,9 @@ void MainGUIWindow::_init() qRegisterMetaType<ptrToMessage>("ptrToMessage"); QObject::connect(_rosNodeThread, SIGNAL(newViconData(const ptrToMessage&)), this, SLOT(updateNewViconData(const ptrToMessage&))); QObject::connect(cf_linker, SIGNAL(updateComboBoxes()), this, SLOT(updateComboBoxes())); + + ros::NodeHandle nodeHandle("~"); + DBChangedPublisher = nodeHandle.advertise<std_msgs::Int32>("DBChanged", 1); #endif } @@ -756,6 +763,11 @@ void MainGUIWindow::on_save_in_DB_button_clicked() // save the database in the file fill_database_file(); + + // Now also publish a ROS message stating that we changed the DB, so the nodes can update it + std_msgs::Int32 msg; + msg.data = 1; + this->DBChangedPublisher.publish(msg); } void MainGUIWindow::clear_database_file() diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h index c43a05a150ef89c7bc217dedcbff520903518394..df0bec3737a765fa6d2f3c8c62ca892d46c45f07 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/include/MainWindow.h @@ -81,6 +81,8 @@ private: ros::Publisher setpointPublisher; ros::Subscriber setpointSubscriber; + ros::Subscriber DBChangedSubscriber; + ros::ServiceClient centralManager; // callbacks @@ -88,6 +90,7 @@ private: void CFBatteryCallback(const std_msgs::Float32& msg); void flyingStateChangedCallback(const std_msgs::Int32& msg); void setpointCallback(const Setpoint& newSetpoint); + void DBChangedCallback(const std_msgs::Int32& msg); float fromVoltageToPercent(float voltage); void updateBatteryVoltage(float battery_voltage); diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp index e0e045e72f3f5149571ce6e53506ad0e3ba29112..62271a73cafc3cc6148f03b3d90dd1fbd83a34dc 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.cpp @@ -39,6 +39,7 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : setpointPublisher = nodeHandle.advertise<Setpoint>("SafeControllerService/Setpoint", 1); setpointSubscriber = nodeHandle.subscribe("SafeControllerService/Setpoint", 1, &MainWindow::setpointCallback, this); + DBChangedSubscriber = nodeHandle.subscribe("my_GUI/DBChanged", 1, &MainWindow::DBChangedCallback, this); // communication with PPS Client, just to make it possible to communicate through terminal also we use PPSClient's name @@ -84,6 +85,11 @@ void MainWindow::enableGUI() ui->groupBox->setEnabled(true); } +void MainWindow::DBChangedCallback(const std_msgs::Int32& msg) +{ + loadCrazyflieContext(); +} + void MainWindow::setpointCallback(const Setpoint& newSetpoint) { m_setpoint = newSetpoint; diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui index c2772eae2672a22b3a12e84078c55c6628903cab..af87d524cfcf3a6ebd9aec2c1021f7134a1bf6f2 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/src/MainWindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>525</width> - <height>424</height> + <width>809</width> + <height>573</height> </rect> </property> <property name="windowTitle"> @@ -15,6 +15,563 @@ </property> <widget class="QWidget" name="centralWidget"> <layout class="QGridLayout" name="gridLayout"> + <item row="3" column="1"> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>1</number> + </property> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Safe Controller</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string/> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="6" column="1"> + <widget class="QLineEdit" name="current_roll"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="current_y"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="current_yaw"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="current_z"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="current_x_label"> + <property name="text"> + <string>x =</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="current_z_label"> + <property name="text"> + <string>z =</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="current_y_label"> + <property name="text"> + <string>y =</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="current_yaw_label"> + <property name="text"> + <string>yaw = </string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="current_x"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="current_pitch_label"> + <property name="text"> + <string>pitch =</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="current_roll_label"> + <property name="text"> + <string>roll =</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="current_pitch"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Current</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="diff_x"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="diff_y"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="diff_z"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLineEdit" name="diff_yaw"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Difference</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string/> + </property> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="2" column="2"> + <widget class="QLineEdit" name="new_setpoint_y"/> + </item> + <item row="4" column="2"> + <widget class="QLineEdit" name="new_setpoint_yaw"/> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="new_setpoint_x"/> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="current_setpoint_y"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="current_setpoint_x"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>yaw =</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_12"> + <property name="font"> + <font> + <pointsize>7</pointsize> + </font> + </property> + <property name="text"> + <string>Current</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>x =</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>z =</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>y =</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="current_setpoint_z"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QPushButton" name="set_setpoint_button"> + <property name="font"> + <font> + <pointsize>7</pointsize> + </font> + </property> + <property name="text"> + <string>Set setpoint</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="current_setpoint_yaw"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="new_setpoint_z"/> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Setpoint:</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_13"> + <property name="font"> + <font> + <pointsize>7</pointsize> + </font> + </property> + <property name="text"> + <string>New</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>Enable Controller</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_4"> + <attribute name="title"> + <string>Custom Controller</string> + </attribute> + <layout class="QGridLayout" name="gridLayout_9"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox_5"> + <property name="title"> + <string/> + </property> + <layout class="QGridLayout" name="gridLayout_7"> + <item row="6" column="1"> + <widget class="QLineEdit" name="current_roll_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="current_y_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="current_yaw_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="current_z_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="current_x_label_2"> + <property name="text"> + <string>x =</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="current_z_label_2"> + <property name="text"> + <string>z =</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="current_y_label_2"> + <property name="text"> + <string>y =</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="current_yaw_label_2"> + <property name="text"> + <string>yaw = </string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="current_x_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="current_pitch_label_2"> + <property name="text"> + <string>pitch =</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="current_roll_label_2"> + <property name="text"> + <string>roll =</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="current_pitch_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Current</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="diff_x_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="diff_y_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="diff_z_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLineEdit" name="diff_yaw_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Difference</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="groupBox_6"> + <property name="title"> + <string/> + </property> + <layout class="QGridLayout" name="gridLayout_8"> + <item row="2" column="2"> + <widget class="QLineEdit" name="new_setpoint_y_2"/> + </item> + <item row="4" column="2"> + <widget class="QLineEdit" name="new_setpoint_yaw_2"/> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="new_setpoint_x_2"/> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="current_setpoint_y_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="current_setpoint_x_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_14"> + <property name="text"> + <string>yaw =</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_15"> + <property name="font"> + <font> + <pointsize>7</pointsize> + </font> + </property> + <property name="text"> + <string>Current</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>x =</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_17"> + <property name="text"> + <string>z =</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_18"> + <property name="text"> + <string>y =</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="current_setpoint_z_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QPushButton" name="set_setpoint_button_2"> + <property name="font"> + <font> + <pointsize>7</pointsize> + </font> + </property> + <property name="text"> + <string>Set setpoint</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="current_setpoint_yaw_2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="new_setpoint_z_2"/> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_19"> + <property name="text"> + <string>Setpoint:</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="label_20"> + <property name="font"> + <font> + <pointsize>7</pointsize> + </font> + </property> + <property name="text"> + <string>New</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="pushButton_2"> + <property name="text"> + <string>Enable Controller</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> <item row="0" column="2"> <widget class="QLabel" name="connected_disconnected_label"> <property name="text"> @@ -28,13 +585,6 @@ <string>StudentID # connected to CF #</string> </property> <layout class="QGridLayout" name="gridLayout_2"> - <item row="3" column="1"> - <widget class="QPushButton" name="take_off_button"> - <property name="text"> - <string>Take Off</string> - </property> - </widget> - </item> <item row="0" column="3"> <widget class="QLabel" name="raw_voltage"> <property name="text"> @@ -42,141 +592,6 @@ </property> </widget> </item> - <item row="4" column="1"> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string/> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="6" column="1"> - <widget class="QLineEdit" name="current_roll"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="current_y"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="current_yaw"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="current_z"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="current_x_label"> - <property name="text"> - <string>x =</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="current_z_label"> - <property name="text"> - <string>z =</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="current_y_label"> - <property name="text"> - <string>y =</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="current_yaw_label"> - <property name="text"> - <string>yaw = </string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="current_x"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="current_pitch_label"> - <property name="text"> - <string>pitch =</string> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="current_roll_label"> - <property name="text"> - <string>roll =</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="current_pitch"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Current</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLineEdit" name="diff_x"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLineEdit" name="diff_y"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QLineEdit" name="diff_z"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QLineEdit" name="diff_yaw"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Difference</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> <item row="2" column="3"> <widget class="QProgressBar" name="battery_bar"> <property name="value"> @@ -184,151 +599,6 @@ </property> </widget> </item> - <item row="2" column="1"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Battery level</string> - </property> - </widget> - </item> - <item row="4" column="3"> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Controller and current set point</string> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="0" column="2"> - <widget class="QPushButton" name="pushButton_4"> - <property name="text"> - <string>Safe</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QLineEdit" name="new_setpoint_y"/> - </item> - <item row="6" column="2"> - <widget class="QLineEdit" name="new_setpoint_yaw"/> - </item> - <item row="3" column="2"> - <widget class="QLineEdit" name="new_setpoint_x"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Controller:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="current_setpoint_x"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="current_setpoint_y"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>yaw =</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="label_12"> - <property name="text"> - <string>Current</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>x =</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_9"> - <property name="text"> - <string>z =</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>y =</string> - </property> - </widget> - </item> - <item row="7" column="2"> - <widget class="QPushButton" name="set_setpoint_button"> - <property name="font"> - <font> - <pointsize>7</pointsize> - </font> - </property> - <property name="text"> - <string>Set setpoint</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLineEdit" name="current_setpoint_z"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Setpoint:</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QLineEdit" name="current_setpoint_yaw"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="5" column="2"> - <widget class="QLineEdit" name="new_setpoint_z"/> - </item> - <item row="2" column="2"> - <widget class="QLabel" name="label_13"> - <property name="text"> - <string>New one</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QPushButton" name="pushButton_3"> - <property name="text"> - <string>Custom</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="3"> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> - </widget> - </item> <item row="0" column="1"> <widget class="QPushButton" name="motors_OFF_button"> <property name="text"> @@ -336,14 +606,33 @@ </property> </widget> </item> - <item row="3" column="3"> - <widget class="QPushButton" name="land_button"> + <item row="2" column="1"> + <widget class="QLabel" name="label"> <property name="text"> - <string>Land</string> + <string>Battery level</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> </item> - <item row="3" column="2"> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="RF_Connect_button"> + <property name="text"> + <string>Connect RF</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string/> + </property> + <layout class="QGridLayout" name="gridLayout_6"> + <item row="1" column="1"> <widget class="QLabel" name="flying_state_label"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -354,18 +643,28 @@ <property name="text"> <string>FlyingState</string> </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="0" colspan="3"> + <widget class="QPushButton" name="land_button"> + <property name="text"> + <string>Land</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="take_off_button"> + <property name="text"> + <string>Take Off</string> + </property> </widget> </item> </layout> </widget> </item> - <item row="0" column="1"> - <widget class="QPushButton" name="RF_Connect_button"> - <property name="text"> - <string>Connect RF</string> - </property> - </widget> - </item> </layout> </widget> <widget class="QMenuBar" name="menuBar"> @@ -373,7 +672,7 @@ <rect> <x>0</x> <y>0</y> - <width>525</width> + <width>809</width> <height>19</height> </rect> </property> diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/studentGUI.pro.user b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/studentGUI.pro.user index 92b0709c8179e53f89685b4192c62cd4f5553dd4..c7c7a5694fa8d188e9252c97af96fabf53df1ab3 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/studentGUI.pro.user +++ b/pps_ws/src/d_fall_pps/GUI_Qt/studentGUI/studentGUI.pro.user @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.0.2, 2017-08-28T12:32:50. --> +<!-- Written by QtCreator 4.0.2, 2017-08-28T18:07:37. --> <qtcreator> <data> <variable>EnvironmentId</variable> diff --git a/pps_ws/src/d_fall_pps/src/PPSClient.cpp b/pps_ws/src/d_fall_pps/src/PPSClient.cpp index d4caacc01ee7c0626024844bfa10c58ee7879680..a135dddadb9f250c417f6253569bdad38a7b6cd3 100755 --- a/pps_ws/src/d_fall_pps/src/PPSClient.cpp +++ b/pps_ws/src/d_fall_pps/src/PPSClient.cpp @@ -423,6 +423,11 @@ void commandCallback(const std_msgs::Int32& commandMsg) { } } +void DBChangedCallback(const std_msgs::Int32& msg) +{ + loadCrazyflieContext(); +} + int main(int argc, char* argv[]) { ros::init(argc, argv, "PPSClient"); @@ -449,6 +454,9 @@ int main(int argc, char* argv[]) // this topic will publish flying state whenever it changes. flyingStatePublisher = nodeHandle.advertise<std_msgs::Int32>("flyingState", 1); + + + // publish first flying state data std_msgs::Int32 flying_state_msg; flying_state_msg.data = flying_state; @@ -458,6 +466,9 @@ int main(int argc, char* argv[]) ros::NodeHandle namespaceNodeHandle = ros::NodeHandle(); safeControllerServiceSetpointPublisher = namespaceNodeHandle.advertise<d_fall_pps::Setpoint>("SafeControllerService/Setpoint", 1); + // subscriber for DBChanged + ros::Subscriber DBChangedSubscriber = namespaceNodeHandle.subscribe("my_GUI/DBChanged", 1, DBChangedCallback); + //start with safe controller flying_state = STATE_MOTORS_OFF; usingSafeController = true;