From 064ccf54a2f3eec8eb9e1119a43ff372f8915c27 Mon Sep 17 00:00:00 2001
From: roangel <roangel@student.ethz.ch>
Date: Fri, 1 Sep 2017 09:25:45 +0200
Subject: [PATCH] Added link to use custom controller and safe controller. Need
 to see what happens if we change yaml file name on the run

---
 .../GUI_Qt/studentGUI/include/MainWindow.h    |  6 ++++++
 .../GUI_Qt/studentGUI/src/MainWindow.cpp      | 19 +++++++++++++++++++
 .../GUI_Qt/studentGUI/src/MainWindow.ui       | 15 +++++++++++----
 .../GUI_Qt/studentGUI/studentGUI.pro.user     |  2 +-
 .../src/d_fall_pps/crazyradio/CrazyRadio.py   |  1 -
 pps_ws/src/d_fall_pps/src/PPSClient.cpp       | 10 +++++++---
 6 files changed, 44 insertions(+), 9 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 e498fb39..3a4895d9 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
@@ -68,6 +68,12 @@ private slots:
 
     void on_pushButton_3_clicked();
 
+    void on_load_yaml_button_clicked();
+
+    void on_en_custom_controller_clicked();
+
+    void on_en_safe_controller_clicked();
+
 private:
     Ui::MainWindow *ui;
 
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 7d2ace65..b7637420 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
@@ -313,3 +313,22 @@ void MainWindow::on_pushButton_3_clicked()
     this->crazyRadioCommandPublisher.publish(msg);
     ROS_INFO("command disconnect published");
 }
+
+void MainWindow::on_load_yaml_button_clicked()
+{
+    
+}
+
+void MainWindow::on_en_custom_controller_clicked()
+{
+    std_msgs::Int32 msg;
+    msg.data = CMD_USE_CUSTOM_CONTROLLER;
+    this->PPSClientCommandPublisher.publish(msg);
+}
+
+void MainWindow::on_en_safe_controller_clicked()
+{
+    std_msgs::Int32 msg;
+    msg.data = CMD_USE_SAFE_CONTROLLER;
+    this->PPSClientCommandPublisher.publish(msg);
+}
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 b36fec5b..e0f50cd1 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
@@ -320,9 +320,9 @@
             </widget>
            </item>
            <item row="1" column="1">
-            <widget class="QPushButton" name="pushButton">
+            <widget class="QPushButton" name="en_safe_controller">
              <property name="text">
-              <string>Enable Controller</string>
+              <string>Enable Safe Controller</string>
              </property>
             </widget>
            </item>
@@ -601,9 +601,16 @@
             </widget>
            </item>
            <item row="1" column="1">
-            <widget class="QPushButton" name="pushButton_2">
+            <widget class="QPushButton" name="en_custom_controller">
              <property name="text">
-              <string>Enable Controller</string>
+              <string>Enable Custom Controller</string>
+             </property>
+            </widget>
+           </item>
+           <item row="1" column="0">
+            <widget class="QPushButton" name="load_yaml_button">
+             <property name="text">
+              <string>Load YAML file</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 9e80e58b..470dfb69 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-29T16:03:13. -->
+<!-- Written by QtCreator 4.0.2, 2017-08-29T18:10:33. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
diff --git a/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py b/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py
index db5d7c0d..dd2b8629 100755
--- a/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py
+++ b/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py
@@ -292,7 +292,6 @@ if __name__ == '__main__':
     time.sleep(1.0)
 
 
-
     bag.close()
     rospy.loginfo("bag closed")
 
diff --git a/pps_ws/src/d_fall_pps/src/PPSClient.cpp b/pps_ws/src/d_fall_pps/src/PPSClient.cpp
index 0d3fcdda..db9d0580 100755
--- a/pps_ws/src/d_fall_pps/src/PPSClient.cpp
+++ b/pps_ws/src/d_fall_pps/src/PPSClient.cpp
@@ -122,16 +122,18 @@ void loadSafeController() {
     ROS_INFO_STREAM("loaded safe controller: " << safeController.getService());
 }
 
-void loadCustomController() {
+void loadCustomController()
+{
 	ros::NodeHandle nodeHandle("~");
 
 	std::string customControllerName;
-	if(!nodeHandle.getParam("customController", customControllerName)) {
+	if(!nodeHandle.getParam("customController", customControllerName))
+    {
 		ROS_ERROR("Failed to get custom controller name");
 		return;
 	}
 
-	customController = ros::service::createClient<Controller>(customControllerName, true);
+    customController = ros::service::createClient<Controller>(customControllerName, true);
     ROS_INFO_STREAM("loaded custom controller " << customControllerName);
 }
 
@@ -443,11 +445,13 @@ void commandCallback(const std_msgs::Int32& commandMsg) {
 
 	switch(cmd) {
     	case CMD_USE_SAFE_CONTROLLER:
+            ROS_INFO("USE_SAFE_CONTROLLER Command received");
     		loadSafeController();
     		usingSafeController = true;
     		break;
 
     	case CMD_USE_CUSTOM_CONTROLLER:
+            ROS_INFO("USE_CUSTOM_CONTROLLER Command received");
     		loadCustomController();
     		usingSafeController = false;
     		break;
-- 
GitLab