From 3aca8d86f104f9a0c5384f94625faa1461a7bc36 Mon Sep 17 00:00:00 2001 From: beuchatp <beuchatp@control.ee.ethz.ch> Date: Mon, 4 Dec 2017 15:31:37 +0100 Subject: [PATCH] Adjusted Ros Info Stream relating to paramters to make things cleaner --- .../src/CustomControllerService.cpp | 14 +++----- pps_ws/src/d_fall_pps/src/PPSClient.cpp | 9 +++-- .../src/d_fall_pps/src/ParameterService.cpp | 33 +++++++++---------- .../d_fall_pps/src/SafeControllerService.cpp | 11 ++----- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/pps_ws/src/d_fall_pps/src/CustomControllerService.cpp b/pps_ws/src/d_fall_pps/src/CustomControllerService.cpp index eae858d8..678b1ba3 100644 --- a/pps_ws/src/d_fall_pps/src/CustomControllerService.cpp +++ b/pps_ws/src/d_fall_pps/src/CustomControllerService.cpp @@ -815,9 +815,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) case FETCH_YAML_CUSTOM_CONTROLLER_COORDINATOR: { // Let the user know that this message was received - ROS_INFO("The CustomControllerService received the message that YAML parameters were (re-)loaded"); - // Let the user know from where the paramters are being fetched - ROS_INFO("> Now fetching the parameter values from the this machine"); + ROS_INFO("The CustomControllerService received the message that YAML parameters were (re-)loaded.\r> Now fetching the parameter values from the this machine."); // Create a node handle to the parameter service running on the coordinator machine ros::NodeHandle nodeHandle_to_coordinator_parameter_service = ros::NodeHandle(namespace_to_coordinator_parameter_service); // Call the function that fetches the parameters @@ -828,9 +826,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) case FETCH_YAML_CUSTOM_CONTROLLER_AGENT: { // Let the user know that this message was received - ROS_INFO("The CustomControllerService received the message that YAML parameters were (re-)loaded"); - // Let the user know which paramters are being fetch - ROS_INFO("> Now fetching the parameter values from the this machine"); + ROS_INFO("The CustomControllerService received the message that YAML parameters were (re-)loaded.\r> Now fetching the parameter values from the this machine"); // Create a node handle to the parameter service running on this agent's machine ros::NodeHandle nodeHandle_to_own_agent_parameter_service = ros::NodeHandle(namespace_to_own_agent_parameter_service); // Call the function that fetches the parameters @@ -841,8 +837,8 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) default: { // Let the user know that the command was not relevant - ROS_INFO("The CustomControllerService received the message that YAML parameters were (re-)loaded"); - ROS_INFO("> However the parameters do not relate to this controller, hence nothing will be fetched."); + //ROS_INFO("The CustomControllerService received the message that YAML parameters were (re-)loaded"); + //ROS_INFO("> However the parameters do not relate to this controller, hence nothing will be fetched."); break; } } @@ -954,7 +950,7 @@ void processFetchedParameters() // Check whether we found our own agent ID if (!foundMyAgentID) { - ROS_INFO("DEBUGGING: not following because my ID was not found"); + //ROS_INFO("DEBUGGING: not following because my ID was not found"); // Revert to the default of not following any agent shouldFollowAnotherAgent = false; agentID_to_follow = 0; diff --git a/pps_ws/src/d_fall_pps/src/PPSClient.cpp b/pps_ws/src/d_fall_pps/src/PPSClient.cpp index 5d7bea66..244dd7e1 100755 --- a/pps_ws/src/d_fall_pps/src/PPSClient.cpp +++ b/pps_ws/src/d_fall_pps/src/PPSClient.cpp @@ -793,7 +793,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) { // Let the user know that this message was received // > and also from where the paramters are being fetched - ROS_INFO("The PPSClient received the message that YAML parameters were (re-)loaded for the Safe Controller.\n>Now fetching the parameter values from the this machine."); + ROS_INFO("The PPSClient received the message that YAML parameters were (re-)loaded for the Safe Controller.\r>Now fetching the parameter values from the coordinator."); // Create a node handle to the parameter service running on the coordinator machine ros::NodeHandle nodeHandle_to_coordinator_parameter_service = ros::NodeHandle(namespace_to_coordinator_parameter_service); // Call the function that fetches the parameters @@ -804,9 +804,9 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) case FETCH_YAML_SAFE_CONTROLLER_AGENT: { // Let the user know that this message was received - ROS_INFO("The PPSClient received the message that YAML parameters were (re-)loaded for the Safe Controller"); + ROS_INFO("The PPSClient received the message that YAML parameters were (re-)loaded for the Safe Controller.\r> Now fetching the parameter values from the this machine"); // Let the user know which paramters are being fetch - ROS_INFO("> Now fetching the parameter values from the this machine"); + ROS_INFO(""); // Create a node handle to the parameter service running on this agent's machine ros::NodeHandle nodeHandle_to_own_agent_parameter_service(namespace_to_own_agent_parameter_service); // Call the function that fetches the parameters @@ -817,8 +817,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) default: { // Let the user know that the command was not relevant - ROS_INFO("The PPSClient received the message that YAML parameters were (re-)loaded"); - ROS_INFO("> However the parameters do not relate to this service, hence nothing will be fetched."); + //ROS_INFO("The PPSClient received the message that YAML parameters were (re-)loaded.\r> However the parameters do not relate to this service, hence nothing will be fetched."); break; } } diff --git a/pps_ws/src/d_fall_pps/src/ParameterService.cpp b/pps_ws/src/d_fall_pps/src/ParameterService.cpp index 6ba594eb..b5c75792 100755 --- a/pps_ws/src/d_fall_pps/src/ParameterService.cpp +++ b/pps_ws/src/d_fall_pps/src/ParameterService.cpp @@ -176,59 +176,58 @@ void requestLoadControllerYamlCallback(const std_msgs::Int32& msg) // Instantiate a local varaible to confirm that something was actually loaded from // a YAML file - bool isReadyForFetch = true; + bool isValidToAttemptLoad = true; // Instantiate a local variable for the string that will be passed to the "system" std::string cmd; // Get the abolute path to "d_fall_pps" std::string d_fall_pps_path = ros::package::getPath("d_fall_pps"); - ROS_INFO_STREAM(d_fall_pps_path); // Switch between loading for the different controllers if ( (controller_to_load_yaml==LOAD_YAML_SAFE_CONTROLLER_COORDINATOR) && (my_type==TYPE_COORDINATOR) ) { // Re-load the parameters of the safe controller: cmd = "rosparam load " + d_fall_pps_path + "/param/SafeController.yaml " + m_ros_namespace + "/SafeControllerService"; - system(cmd.c_str()); - ROS_INFO_STREAM(cmd); } else if ( (controller_to_load_yaml==LOAD_YAML_SAFE_CONTROLLER_AGENT) && (my_type==TYPE_AGENT) ) { // Re-load the parameters of the safe controller: cmd = "rosparam load " + d_fall_pps_path + "/param/SafeController.yaml " + m_ros_namespace + "/SafeControllerService"; - system(cmd.c_str()); - ROS_INFO_STREAM(cmd); } else if ( (controller_to_load_yaml==LOAD_YAML_CUSTOM_CONTROLLER_COORDINATOR) && (my_type==TYPE_COORDINATOR) ) { // Re-load the parameters of the custom controller: cmd = "rosparam load " + d_fall_pps_path + "/param/CustomController.yaml " + m_ros_namespace + "/CustomControllerService"; - system(cmd.c_str()); - ROS_INFO_STREAM(cmd); } else if ( (controller_to_load_yaml==LOAD_YAML_CUSTOM_CONTROLLER_AGENT) && (my_type==TYPE_AGENT) ) { // Re-load the parameters of the custom controller: cmd = "rosparam load " + d_fall_pps_path + "/param/CustomController.yaml " + m_ros_namespace + "/CustomControllerService"; - system(cmd.c_str()); - ROS_INFO_STREAM(cmd); } else { // Let the user know that the command was not recognised - ROS_INFO("Unknown 'controller to load yaml' command, thus nothing will be loaded"); + ROS_INFO("> Unknown 'controller to load yaml' command, thus nothing will be loaded"); // Set the boolean that prevents the fetch message from being sent - isReadyForFetch = false; + isValidToAttemptLoad = false; } - // Pause breifly to ensure that the yaml file is fully loaded - ros::Duration(0.2).sleep(); - // Only bother with sending the "ready for fetch" message if something was actually - // loaded from a YAML file - if (isReadyForFetch) + // Only bother with ttempting to loaded the .yaml file, and subseuently send the "ready for fetch" + // message if something can actually be loaded from a YAML file + if (isValidToAttemptLoad) { + // Let the user know what is about to happen + ROS_INFO_STREAM("> The following path will be used for locating the .yaml file:\r" << d_fall_pps_path << "\rThe comand line string sent to the 'system' is:\r" << cmd ); + + // Re-load the parameters by pass the command line string via a "system" call + // > i.e., this replicates pasting this string in a new terminal window and pressing enter + system(cmd.c_str()); + + // Pause breifly to ensure that the yaml file is fully loaded + ros::Duration(0.2).sleep(); + // Instantiate a local variable for the fetch message std_msgs::Int32 fetch_msg; // Fill in the data of the fetch message diff --git a/pps_ws/src/d_fall_pps/src/SafeControllerService.cpp b/pps_ws/src/d_fall_pps/src/SafeControllerService.cpp index 89a6a96b..afd88060 100755 --- a/pps_ws/src/d_fall_pps/src/SafeControllerService.cpp +++ b/pps_ws/src/d_fall_pps/src/SafeControllerService.cpp @@ -386,9 +386,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) case FETCH_YAML_SAFE_CONTROLLER_COORDINATOR: { // Let the user know that this message was received - ROS_INFO("The SafeControllerService received the message that YAML parameters were (re-)loaded"); - // Let the user know from where the paramters are being fetched - ROS_INFO("> Now fetching the parameter values from the this machine"); + ROS_INFO("The SafeControllerService received the message that YAML parameters were (re-)loaded.\r> Now fetching the parameter values from the coordinator."); // Create a node handle to the parameter service running on the coordinator machine ros::NodeHandle nodeHandle_to_coordinator_parameter_service = ros::NodeHandle(namespace_to_coordinator_parameter_service); // Call the function that fetches the parameters @@ -399,9 +397,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) case FETCH_YAML_SAFE_CONTROLLER_AGENT: { // Let the user know that this message was received - ROS_INFO("The SafeControllerService received the message that YAML parameters were (re-)loaded"); - // Let the user know which paramters are being fetch - ROS_INFO("> Now fetching the parameter values from the this machine"); + ROS_INFO("The SafeControllerService received the message that YAML parameters were (re-)loaded.\r> Now fetching the parameter values from the this machine."); // Create a node handle to the parameter service running on this agent's machine ros::NodeHandle nodeHandle_to_own_agent_parameter_service = ros::NodeHandle(namespace_to_own_agent_parameter_service); // Call the function that fetches the parameters @@ -412,8 +408,7 @@ void yamlReadyForFetchCallback(const std_msgs::Int32& msg) default: { // Let the user know that the command was not relevant - ROS_INFO("The SafeControllerService received the message that YAML parameters were (re-)loaded"); - ROS_INFO("> However the parameters do not relate to this controller, hence nothing will be fetched."); + //ROS_INFO("The SafeControllerService received the message that YAML parameters were (re-)loaded.\r> However the parameters do not relate to this controller, hence nothing will be fetched."); break; } } -- GitLab