From 4ee3ce8a93986ec71a04f9090ce1675d1d5c17cf Mon Sep 17 00:00:00 2001 From: beuchatp <beuchatp@control.ee.ethz.ch> Date: Mon, 4 Dec 2017 16:00:16 +0100 Subject: [PATCH] Adjusted namespacing of the Parameer Service --- .../src/d_fall_pps/src/ParameterService.cpp | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/pps_ws/src/d_fall_pps/src/ParameterService.cpp b/pps_ws/src/d_fall_pps/src/ParameterService.cpp index d94ca277..0d5582aa 100755 --- a/pps_ws/src/d_fall_pps/src/ParameterService.cpp +++ b/pps_ws/src/d_fall_pps/src/ParameterService.cpp @@ -288,7 +288,6 @@ int main(int argc, char* argv[]) // the "~" indcates that "self" is the node handle assigned to this variable. ros::NodeHandle nodeHandle("~"); - m_ros_namespace = ros::this_node::getNamespace(); // Get the value of the "type" parameter into a local string variable std::string type_string; @@ -327,6 +326,37 @@ int main(int argc, char* argv[]) controllerYamlReadyForFetchPublihser = nodeHandle.advertise<std_msgs::Int32>("controllerYamlReadyForFetch", 1); + // Construct the string to the namespace of this Paramater Service + // SUBSCRIBE TO THE APPROPRIATE "request" MESSAGES DEPENDING ON THE "my_type" + switch (my_type) + { + case TYPE_AGENT: + { + //m_ros_namespace = ros::this_node::getNamespace(); + m_ros_namespace = "/" + std::to_string(agentID_to_follow) + "/" + "ParameterService"; + ROS_INFO_STREAM("This Paramter Sercice will load .yaml file parameters into the 'base' namespace: " << m_ros_namespace); + break; + } + + // A COORDINATOR TYPE PARAMETER SERVICE IS REQUESTED FROM: + // > The master GUI + case TYPE_COORDINATOR: + { + //m_ros_namespace = ros::this_node::getNamespace(); + m_ros_namespace = "/" + "ParameterService"; + ROS_INFO_STREAM("This Paramter Sercice will load .yaml file parameters into the 'base' namespace: " << m_ros_namespace); + break; + } + + default: + { + ROS_ERROR("The 'my_type' type parameter was not recognised."); + break; + } + } + + + // Delare the subscribers as local variables here so that they persist for the life // time of this main() function. The varaibles will be assigned in the switch case below -- GitLab