From 9ca1f74687a315adf2002e8f5164c529e825659f Mon Sep 17 00:00:00 2001
From: roangel <roangel@student.ethz.ch>
Date: Tue, 29 Aug 2017 16:19:46 +0200
Subject: [PATCH] added units, changed rad to deg

---
 .../GUI_Qt/studentGUI/include/MainWindow.h    |  6 ++
 .../GUI_Qt/studentGUI/src/MainWindow.cpp      | 12 ++--
 .../GUI_Qt/studentGUI/src/MainWindow.ui       | 56 +++++++++++--------
 .../GUI_Qt/studentGUI/studentGUI.pro.user     |  2 +-
 4 files changed, 47 insertions(+), 29 deletions(-)

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 62e1fdc0..e498fb39 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
@@ -36,6 +36,12 @@
 #define STATE_FLYING     3
 #define STATE_LAND       4
 
+
+#define PI 3.141592653589
+
+#define RAD2DEG 180.0/PI
+#define DEG2RAD PI/180.0
+
 namespace Ui {
 class MainWindow;
 }
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 bad2244a..7d2ace65 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
@@ -98,7 +98,7 @@ void MainWindow::setpointCallback(const Setpoint& newSetpoint)
     ui->current_setpoint_x->setText(QString::number(newSetpoint.x));
     ui->current_setpoint_y->setText(QString::number(newSetpoint.y));
     ui->current_setpoint_z->setText(QString::number(newSetpoint.z));
-    ui->current_setpoint_yaw->setText(QString::number(newSetpoint.yaw));
+    ui->current_setpoint_yaw->setText(QString::number(newSetpoint.yaw * RAD2DEG));
 }
 
 void MainWindow::flyingStateChangedCallback(const std_msgs::Int32& msg)
@@ -253,15 +253,15 @@ void MainWindow::updateNewViconData(const ptrToMessage& p_msg) //connected to ne
             ui->current_x->setText(QString::number(local.x, 'f', 3));
             ui->current_y->setText(QString::number(local.y, 'f', 3));
             ui->current_z->setText(QString::number(local.z, 'f', 3));
-            ui->current_yaw->setText(QString::number(local.yaw, 'f', 3));
-            ui->current_pitch->setText(QString::number(local.pitch, 'f', 3));
-            ui->current_roll->setText(QString::number(local.roll, 'f', 3));
+            ui->current_yaw->setText(QString::number(local.yaw * RAD2DEG, 'f', 3));
+            ui->current_pitch->setText(QString::number(local.pitch * RAD2DEG, 'f', 3));
+            ui->current_roll->setText(QString::number(local.roll * RAD2DEG, 'f', 3));
 
             // also update diff
             ui->diff_x->setText(QString::number(m_setpoint.x - local.x, 'f', 3));
             ui->diff_y->setText(QString::number(m_setpoint.y - local.y, 'f', 3));
             ui->diff_z->setText(QString::number(m_setpoint.z - local.z, 'f', 3));
-            ui->diff_yaw->setText(QString::number(m_setpoint.yaw - local.yaw, 'f', 3));
+            ui->diff_yaw->setText(QString::number((m_setpoint.yaw - local.yaw) * RAD2DEG, 'f', 3));
         }
     }
 }
@@ -301,7 +301,7 @@ void MainWindow::on_set_setpoint_button_clicked()
     msg_setpoint.x = (ui->new_setpoint_x->text()).toFloat();
     msg_setpoint.y = (ui->new_setpoint_y->text()).toFloat();
     msg_setpoint.z = (ui->new_setpoint_z->text()).toFloat();
-    msg_setpoint.yaw = (ui->new_setpoint_yaw->text()).toFloat();
+    msg_setpoint.yaw = (ui->new_setpoint_yaw->text()).toFloat() * DEG2RAD;
 
     this->setpointPublisher.publish(msg_setpoint);
 }
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 325c02d1..b36fec5b 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
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>854</width>
-    <height>565</height>
+    <height>569</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -45,7 +45,7 @@
        <item row="1" column="0">
         <widget class="QTabWidget" name="tabWidget">
          <property name="currentIndex">
-          <number>1</number>
+          <number>0</number>
          </property>
          <widget class="QWidget" name="tab_3">
           <attribute name="title">
@@ -89,28 +89,28 @@
               <item row="1" column="0">
                <widget class="QLabel" name="current_x_label">
                 <property name="text">
-                 <string>x =</string>
+                 <string>x [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="3" column="0">
                <widget class="QLabel" name="current_z_label">
                 <property name="text">
-                 <string>z =</string>
+                 <string>z [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="2" column="0">
                <widget class="QLabel" name="current_y_label">
                 <property name="text">
-                 <string>y =</string>
+                 <string>y [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="4" column="0">
                <widget class="QLabel" name="current_yaw_label">
                 <property name="text">
-                 <string>yaw = </string>
+                 <string>yaw [deg] = </string>
                 </property>
                </widget>
               </item>
@@ -124,14 +124,14 @@
               <item row="5" column="0">
                <widget class="QLabel" name="current_pitch_label">
                 <property name="text">
-                 <string>pitch =</string>
+                 <string>pitch [deg] =</string>
                 </property>
                </widget>
               </item>
               <item row="6" column="0">
                <widget class="QLabel" name="current_roll_label">
                 <property name="text">
-                 <string>roll =</string>
+                 <string>roll [deg] =</string>
                 </property>
                </widget>
               </item>
@@ -147,6 +147,9 @@
                 <property name="text">
                  <string>Current</string>
                 </property>
+                <property name="alignment">
+                 <set>Qt::AlignCenter</set>
+                </property>
                </widget>
               </item>
               <item row="1" column="2">
@@ -182,6 +185,9 @@
                 <property name="text">
                  <string>Difference</string>
                 </property>
+                <property name="alignment">
+                 <set>Qt::AlignCenter</set>
+                </property>
                </widget>
               </item>
              </layout>
@@ -219,7 +225,7 @@
               <item row="4" column="0">
                <widget class="QLabel" name="label_11">
                 <property name="text">
-                 <string>yaw =</string>
+                 <string>yaw [deg] =</string>
                 </property>
                </widget>
               </item>
@@ -241,21 +247,21 @@
               <item row="1" column="0">
                <widget class="QLabel" name="label_7">
                 <property name="text">
-                 <string>x =</string>
+                 <string>x [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="3" column="0">
                <widget class="QLabel" name="label_9">
                 <property name="text">
-                 <string>z =</string>
+                 <string>z [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="2" column="0">
                <widget class="QLabel" name="label_8">
                 <property name="text">
-                 <string>y =</string>
+                 <string>y [m] =</string>
                 </property>
                </widget>
               </item>
@@ -364,28 +370,28 @@
               <item row="1" column="0">
                <widget class="QLabel" name="current_x_label_2">
                 <property name="text">
-                 <string>x =</string>
+                 <string>x [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="3" column="0">
                <widget class="QLabel" name="current_z_label_2">
                 <property name="text">
-                 <string>z =</string>
+                 <string>z [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="2" column="0">
                <widget class="QLabel" name="current_y_label_2">
                 <property name="text">
-                 <string>y =</string>
+                 <string>y [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="4" column="0">
                <widget class="QLabel" name="current_yaw_label_2">
                 <property name="text">
-                 <string>yaw = </string>
+                 <string>yaw [deg] = </string>
                 </property>
                </widget>
               </item>
@@ -399,14 +405,14 @@
               <item row="5" column="0">
                <widget class="QLabel" name="current_pitch_label_2">
                 <property name="text">
-                 <string>pitch =</string>
+                 <string>pitch [deg] =</string>
                 </property>
                </widget>
               </item>
               <item row="6" column="0">
                <widget class="QLabel" name="current_roll_label_2">
                 <property name="text">
-                 <string>roll =</string>
+                 <string>roll [deg] =</string>
                 </property>
                </widget>
               </item>
@@ -422,6 +428,9 @@
                 <property name="text">
                  <string>Current</string>
                 </property>
+                <property name="alignment">
+                 <set>Qt::AlignCenter</set>
+                </property>
                </widget>
               </item>
               <item row="1" column="2">
@@ -457,6 +466,9 @@
                 <property name="text">
                  <string>Difference</string>
                 </property>
+                <property name="alignment">
+                 <set>Qt::AlignCenter</set>
+                </property>
                </widget>
               </item>
              </layout>
@@ -494,7 +506,7 @@
               <item row="4" column="0">
                <widget class="QLabel" name="label_14">
                 <property name="text">
-                 <string>yaw =</string>
+                 <string>yaw [deg] =</string>
                 </property>
                </widget>
               </item>
@@ -516,21 +528,21 @@
               <item row="1" column="0">
                <widget class="QLabel" name="label_16">
                 <property name="text">
-                 <string>x =</string>
+                 <string>x [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="3" column="0">
                <widget class="QLabel" name="label_17">
                 <property name="text">
-                 <string>z =</string>
+                 <string>z [m] =</string>
                 </property>
                </widget>
               </item>
               <item row="2" column="0">
                <widget class="QLabel" name="label_18">
                 <property name="text">
-                 <string>y =</string>
+                 <string>y [m] =</string>
                 </property>
                </widget>
               </item>
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 c7c7a569..9e80e58b 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-28T18:07:37. -->
+<!-- Written by QtCreator 4.0.2, 2017-08-29T16:03:13. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-- 
GitLab