From ab2788416b1797f72178ee98bbf4b432c38e4bf4 Mon Sep 17 00:00:00 2001
From: beuchatp <beuchatp@control.ee.ethz.ch>
Date: Fri, 1 Dec 2017 08:10:05 +0100
Subject: [PATCH] Fixed subscriber inside switch case not persisting

---
 pps_ws/src/d_fall_pps/src/ParameterService.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/pps_ws/src/d_fall_pps/src/ParameterService.cpp b/pps_ws/src/d_fall_pps/src/ParameterService.cpp
index 7be7f237..fe93bc5d 100755
--- a/pps_ws/src/d_fall_pps/src/ParameterService.cpp
+++ b/pps_ws/src/d_fall_pps/src/ParameterService.cpp
@@ -109,6 +109,8 @@ ros::Publisher controllerYamlReadyForFetchPublihser;
 
 std::string m_ros_namespace;
 
+ros::Subscriber requestLoadControllerYamlSubscriber_agent_to_self;
+
 
 //    ----------------------------------------------------------------------------------
 //    FFFFF  U   U  N   N   CCCC  TTTTT  III   OOO   N   N
@@ -352,12 +354,15 @@ int main(int argc, char* argv[])
             // > Subscribe to requests from: the agent's own "PPSClient" node
             //std::string temp_this_node_namespace = ros::this_node::getNamespace();
             //ros::NodeHandle nh_PPSClient_for_this_agent(temp_this_node_namespace + "/PPSClient");
-            ros::NodeHandle nh_PPSClient_for_this_agent(nodeHandle,"PPSClient");
-            ros::Subscriber requestLoadControllerYamlSubscriber_agent_to_self = nh_PPSClient_for_this_agent.subscribe("requestLoadControllerYaml", 1, requestLoadControllerYamlCallback);
+            
+ros::NodeHandle nh_PPSClient_for_this("PPSClient");
+ros::Subscriber requestLoadContr = nh_PPSClient_for_this.subscribe("hfsfhjfshjfsjfshsdgdagdasgdagad", 1, requestLoadControllerYamlCallback);
 
 
             ROS_INFO_STREAM("This Parameter Service has subscribed to 'requestLoadControllerYaml' messages from both the 'my_GUI' and the 'PPSClient'");
 
+ros::Duration(5).sleep();
+
             break;
         }
 
@@ -368,6 +373,15 @@ int main(int argc, char* argv[])
         }
     }
 
+ros::Subscriber requestLoadControllerYamlSubscriber_agent_to_self;
+ros::Subscriber requestLoadControllerYamlSubscriber_agent_to_selffdxfd;
+if (my_type==TYPE_AGENT)
+{
+
+ros::NodeHandle nh_PPSClient_for_this_agent("PPSClient");
+
+             requestLoadControllerYamlSubscriber_agent_to_self = nh_PPSClient_for_this_agent.subscribe("requestLoadControllerYaml", 1, requestLoadControllerYamlCallback);
+}
     
     // Subscriber for requests that the controller parameters should be re-loaded from
     // the .YAML files on the coordinators machine, and then all the agents should be
-- 
GitLab