diff --git a/dfall_ws/src/dfall_pkg/CMakeLists.txt b/dfall_ws/src/dfall_pkg/CMakeLists.txt index b2848be89c640c47c1939afc1626a92209efec77..1c4d9be33e6baf59676aa28724071a289fca1df0 100755 --- a/dfall_ws/src/dfall_pkg/CMakeLists.txt +++ b/dfall_ws/src/dfall_pkg/CMakeLists.txt @@ -281,6 +281,7 @@ add_message_files( add_service_files( FILES IntIntService.srv + IntStringService.srv Controller.srv CMRead.srv CMQuery.srv @@ -393,42 +394,43 @@ endif() # add_executable(${PROJECT_NAME}_node src/dfall_pkg_node.cpp) if(VICON_LIBRARY) - add_executable(ViconDataPublisher src/nodes/ViconDataPublisher.cpp) + add_executable(ViconDataPublisher src/nodes/ViconDataPublisher.cpp) endif() -add_executable(FlyingAgentClient src/nodes/FlyingAgentClient.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(BatteryMonitor src/nodes/BatteryMonitor.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(CrazyRadioEmulator src/nodes/CrazyRadioEmulator.cpp - src/classes/QuadrotorSimulator.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(CsoneControllerService src/nodes/CsoneControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(DefaultControllerService src/nodes/DefaultControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -# add_executable(SafeControllerService src/nodes/SafeControllerService.cpp) -# add_executable(DemoControllerService src/nodes/DemoControllerService.cpp -# src/classes/GetParamtersAndNamespaces.cpp) -add_executable(StudentControllerService src/nodes/StudentControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -# add_executable(MpcControllerService src/nodes/MpcControllerService.cpp) -add_executable(RemoteControllerService src/nodes/RemoteControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(TuningControllerService src/nodes/TuningControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(PickerControllerService src/nodes/PickerControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(TemplateControllerService src/nodes/TemplateControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) +add_executable(FlyingAgentClient src/nodes/FlyingAgentClient.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(AgentStatusForWebInterface src/nodes/AgentStatusForWebInterface.cpp) +add_executable(BatteryMonitor src/nodes/BatteryMonitor.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(CrazyRadioEmulator src/nodes/CrazyRadioEmulator.cpp + src/classes/QuadrotorSimulator.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(CsoneControllerService src/nodes/CsoneControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(DefaultControllerService src/nodes/DefaultControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) +# add_executable(SafeControllerService src/nodes/SafeControllerService.cpp) +# add_executable(DemoControllerService src/nodes/DemoControllerService.cpp +# src/classes/GetParamtersAndNamespaces.cpp) +add_executable(StudentControllerService src/nodes/StudentControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) +# add_executable(MpcControllerService src/nodes/MpcControllerService.cpp) +add_executable(RemoteControllerService src/nodes/RemoteControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(TuningControllerService src/nodes/TuningControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(PickerControllerService src/nodes/PickerControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(TemplateControllerService src/nodes/TemplateControllerService.cpp + src/classes/GetParamtersAndNamespaces.cpp) add_executable(TestMotorsControllerService src/nodes/TestMotorsControllerService.cpp - src/classes/GetParamtersAndNamespaces.cpp) -add_executable(CentralManagerService src/nodes/CentralManagerService.cpp src/classes/CrazyflieIO.cpp) -add_executable(ParameterService src/nodes/ParameterService.cpp) + src/classes/GetParamtersAndNamespaces.cpp) +add_executable(CentralManagerService src/nodes/CentralManagerService.cpp src/classes/CrazyflieIO.cpp) +add_executable(ParameterService src/nodes/ParameterService.cpp) -add_executable(MocapEmulator src/nodes/MocapEmulator.cpp - src/classes/QuadrotorSimulator.cpp - src/classes/GetParamtersAndNamespaces.cpp) +add_executable(MocapEmulator src/nodes/MocapEmulator.cpp + src/classes/QuadrotorSimulator.cpp + src/classes/GetParamtersAndNamespaces.cpp) @@ -496,24 +498,25 @@ if(VICON_LIBRARY) add_dependencies(ViconDataPublisher dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) endif() -add_dependencies(FlyingAgentClient dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(BatteryMonitor dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(CrazyRadioEmulator dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(CsoneControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(DefaultControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -# add_dependencies(SafeControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -# add_dependencies(DemoControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(StudentControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -# add_dependencies(MpcControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(RemoteControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(TuningControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(PickerControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(TemplateControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(FlyingAgentClient dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(AgentStatusForWebInterface dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(BatteryMonitor dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(CrazyRadioEmulator dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(CsoneControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(DefaultControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +# add_dependencies(SafeControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +# add_dependencies(DemoControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(StudentControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +# add_dependencies(MpcControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(RemoteControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(TuningControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(PickerControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(TemplateControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) add_dependencies(TestMotorsControllerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(CentralManagerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(ParameterService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(CentralManagerService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(ParameterService dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) -add_dependencies(MocapEmulator dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) +add_dependencies(MocapEmulator dfall_pkg_generate_messages_cpp ${catkin_EXPORTED_TARGETS}) @@ -550,28 +553,29 @@ if(VICON_LIBRARY) target_link_libraries(ViconDataPublisher ${VICON_LIBRARY}) endif() -target_link_libraries(FlyingAgentClient ${catkin_LIBRARIES}) -target_link_libraries(BatteryMonitor ${catkin_LIBRARIES}) -target_link_libraries(CrazyRadioEmulator ${catkin_LIBRARIES}) -target_link_libraries(CsoneControllerService ${catkin_LIBRARIES}) -target_link_libraries(DefaultControllerService ${catkin_LIBRARIES}) -# target_link_libraries(SafeControllerService ${catkin_LIBRARIES}) -# target_link_libraries(DemoControllerService ${catkin_LIBRARIES}) -target_link_libraries(StudentControllerService ${catkin_LIBRARIES}) +target_link_libraries(FlyingAgentClient ${catkin_LIBRARIES}) +target_link_libraries(AgentStatusForWebInterface ${catkin_LIBRARIES}) +target_link_libraries(BatteryMonitor ${catkin_LIBRARIES}) +target_link_libraries(CrazyRadioEmulator ${catkin_LIBRARIES}) +target_link_libraries(CsoneControllerService ${catkin_LIBRARIES}) +target_link_libraries(DefaultControllerService ${catkin_LIBRARIES}) +# target_link_libraries(SafeControllerService ${catkin_LIBRARIES}) +# target_link_libraries(DemoControllerService ${catkin_LIBRARIES}) +target_link_libraries(StudentControllerService ${catkin_LIBRARIES}) # if(Eigen3_FOUND) -# target_link_libraries(MpcControllerService ${catkin_LIBRARIES} Eigen3::Eigen) +# target_link_libraries(MpcControllerService ${catkin_LIBRARIES} Eigen3::Eigen) # else() -# target_link_libraries(MpcControllerService ${catkin_LIBRARIES}) +# target_link_libraries(MpcControllerService ${catkin_LIBRARIES}) # endif() -target_link_libraries(RemoteControllerService ${catkin_LIBRARIES}) -target_link_libraries(TuningControllerService ${catkin_LIBRARIES}) -target_link_libraries(PickerControllerService ${catkin_LIBRARIES}) -target_link_libraries(TemplateControllerService ${catkin_LIBRARIES}) +target_link_libraries(RemoteControllerService ${catkin_LIBRARIES}) +target_link_libraries(TuningControllerService ${catkin_LIBRARIES}) +target_link_libraries(PickerControllerService ${catkin_LIBRARIES}) +target_link_libraries(TemplateControllerService ${catkin_LIBRARIES}) target_link_libraries(TestMotorsControllerService ${catkin_LIBRARIES}) -target_link_libraries(CentralManagerService ${catkin_LIBRARIES}) -target_link_libraries(ParameterService ${catkin_LIBRARIES}) +target_link_libraries(CentralManagerService ${catkin_LIBRARIES}) +target_link_libraries(ParameterService ${catkin_LIBRARIES}) -target_link_libraries(MocapEmulator ${catkin_LIBRARIES}) +target_link_libraries(MocapEmulator ${catkin_LIBRARIES}) if(Qt5_FOUND) diff --git a/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h b/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..2f9724babdcaeaab82766a7b4a2905f335c0176c --- /dev/null +++ b/dfall_ws/src/dfall_pkg/include/nodes/AgentStatusForWebInterface.h @@ -0,0 +1,152 @@ +// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat +// +// This file is part of D-FaLL-System. +// +// D-FaLL-System is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// D-FaLL-System is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>. +// +// +// ---------------------------------------------------------------------------------- +// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M +// D D F aaa L L S Y Y S T E MM MM +// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M +// D D F a aa L L S Y S T E M M +// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M +// +// +// DESCRIPTION: +// The service that provides data to the web interface +// +// ---------------------------------------------------------------------------------- + + + + + +// ---------------------------------------------------------------------------------- +// III N N CCCC L U U DDDD EEEEE SSSS +// I NN N C L U U D D E S +// I N N N C L U U D D EEE SSS +// I N NN C L U U D D E S +// III N N CCCC LLLLL UUU DDDD EEEEE SSSS +// ---------------------------------------------------------------------------------- + +#include <stdlib.h> +//#include <iostream> +#include <string> + +#include <ros/ros.h> +#include <ros/package.h> +#include <ros/network.h> + +// Include the standard message types +#include "std_msgs/Int32.h" +//#include "std_msgs/Float32.h" +//#include <std_msgs/String.h> + +// Include the DFALL message types +#include "dfall_pkg/SetpointWithHeader.h" + +// Include the DFALL service types +#include "dfall_pkg/IntStringService.h" + +// Include the shared definitions +#include "nodes/Constants.h" +//#include "classes/GetParamtersAndNamespaces.h" + +// SPECIFY THE PACKAGE NAMESPACE +using namespace dfall_pkg; +//using namespace std; + + + +// ---------------------------------------------------------------------------------- +// DDDD EEEEE FFFFF III N N EEEEE SSSS +// D D E F I NN N E S +// D D EEE FFF I N N N EEE SSS +// D D E F I N NN E S +// DDDD EEEEE F III N N EEEEE SSSS +// ---------------------------------------------------------------------------------- + + + + + +// ---------------------------------------------------------------------------------- +// V V A RRRR III A BBBB L EEEEE SSSS +// V V A A R R I A A B B L E S +// V V A A RRRR I A A BBBB L EEE SSS +// V V AAAAA R R I AAAAA B B L E S +// V A A R R III A A BBBB LLLLL EEEEE SSSS +// ---------------------------------------------------------------------------------- + + +// The crazyradio status +// > as received via messages +int m_crazyradio_status = CRAZY_RADIO_STATE_DISCONNECTED; + +// The flying state of the agent +// > as received via messages +int m_agent_operating_state = STATE_UNAVAILABLE; + +// The instant controller, +// > as received via messages +int m_instant_controller = DEFAULT_CONTROLLER; + +// The battery level +// > as received via messages +int m_battery_level = BATTERY_LEVEL_UNAVAILABLE; + +// The setpoint of the default controller +// > as received via messages +float m_setpoint_default[4] = {0.0,0.0,0.4,0.0}; + +// The setpoint of the student controller +// > as received via messages +float m_setpoint_student[4] = {0.0,0.0,0.4,0.0}; + + + + + +// ---------------------------------------------------------------------------------- +// FFFFF U U N N CCCC TTTTT III OOO N N +// F U U NN N C T I O O NN N +// FFF U U N N N C T I O O N N N +// F U U N NN C T I O O N NN +// F UUU N N CCCC T III OOO N N +// +// PPPP RRRR OOO TTTTT OOO TTTTT Y Y PPPP EEEEE SSSS +// P P R R O O T O O T Y Y P P E S +// PPPP RRRR O O T O O T Y PPPP EEE SSS +// P R R O O T O O T Y P E S +// P R R OOO T OOO T Y P EEEEE SSSS +// ---------------------------------------------------------------------------------- + + +// Callbacks for messages with the status of things: +// > For the status of the crazyradio +void crazyRadioStatusCallback(const std_msgs::Int32& msg); +// > For the flying state of the agent +void agentOperatingStateCallback(const std_msgs::Int32& msg); +// > For the instant controller +void instantControllerChangedCallback(const std_msgs::Int32& msg); +// > For the battery level +void newBatteryLevelCallback(const std_msgs::Int32& msg); +// > For the Default Controller Setpoint +void defaultControllerSetpointChangedCallback(const SetpointWithHeader& newSetpoint); +// > For the Student Controller Setpoint +void studentControllerSetpointChangedCallback(const SetpointWithHeader& newSetpoint); + +// Service callback for providing status to the Web Interface +bool statusForWebInterfaceCallback(IntStringService::Request &request, IntStringService::Response &response); \ No newline at end of file diff --git a/dfall_ws/src/dfall_pkg/launch/agent.launch b/dfall_ws/src/dfall_pkg/launch/agent.launch index f613b0e7def089bf6e3b89dd116e5a503071fd78..0ed62bb46297b6ae7a1b30cb2974fcc45f5bd8bc 100755 --- a/dfall_ws/src/dfall_pkg/launch/agent.launch +++ b/dfall_ws/src/dfall_pkg/launch/agent.launch @@ -217,6 +217,15 @@ /> </node> </group> + + <!-- AGENT STATUS FOR WEB INTERFACE --> + <node + pkg = "dfall_pkg" + name = "AgentStatusForWebInterface" + output = "screen" + type = "AgentStatusForWebInterface" + > + </node> </group> diff --git a/dfall_ws/src/dfall_pkg/launch/pi_agent.launch b/dfall_ws/src/dfall_pkg/launch/pi_agent.launch index a4e6f97e40a38b23e96a065b0a89909d201554a2..e54ae35197193d785326dce1ac3a01ab49bda64e 100755 --- a/dfall_ws/src/dfall_pkg/launch/pi_agent.launch +++ b/dfall_ws/src/dfall_pkg/launch/pi_agent.launch @@ -139,6 +139,15 @@ /> </node> + <!-- AGENT STATUS FOR WEB INTERFACE --> + <node + pkg = "dfall_pkg" + name = "AgentStatusForWebInterface" + output = "screen" + type = "AgentStatusForWebInterface" + > + </node> + </group> </launch> diff --git a/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp b/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aae072edc5f574f3f0181bb66b62c7294f149c40 --- /dev/null +++ b/dfall_ws/src/dfall_pkg/src/nodes/AgentStatusForWebInterface.cpp @@ -0,0 +1,219 @@ +// Copyright (C) 2019, ETH Zurich, D-ITET, Paul Beuchat +// +// This file is part of D-FaLL-System. +// +// D-FaLL-System is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// D-FaLL-System is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with D-FaLL-System. If not, see <http://www.gnu.org/licenses/>. +// +// +// ---------------------------------------------------------------------------------- +// DDDD FFFFF L L SSSS Y Y SSSS TTTTT EEEEE M M +// D D F aaa L L S Y Y S T E MM MM +// D D --- FFFF a a L L --- SSS Y SSS T EEE M M M +// D D F a aa L L S Y S T E M M +// DDDD F aa a LLLL LLLL SSSS Y SSSS T EEEEE M M +// +// +// DESCRIPTION: +// The service that provides data to the web interface +// +// ---------------------------------------------------------------------------------- + + + + + +// INCLUDE THE HEADER +#include "nodes/AgentStatusForWebInterface.h" + + + + + + + + + + + +// ---------------------------------------------------------------------------------- +// FFFFF U U N N CCCC TTTTT III OOO N N +// F U U NN N C T I O O NN N +// FFF U U N N N C T I O O N N N +// F U U N NN C T I O O N NN +// F UUU N N CCCC T III OOO N N +// +// III M M PPPP L EEEEE M M EEEEE N N TTTTT A TTTTT III OOO N N +// I MM MM P P L E MM MM E NN N T A A T I O O NN N +// I M M M PPPP L EEE M M M EEE N N N T A A T I O O N N N +// I M M P L E M M E N NN T AAAAA T I O O N NN +// III M M P LLLLL EEEEE M M EEEEE N N T A A T III OOO N N +// ---------------------------------------------------------------------------------- + + + +// CALLBACKS FOR MESSAGES WITH THE STATUS OF THINGS + +// > For the status of the crazyradio +void crazyRadioStatusCallback(const std_msgs::Int32& msg) +{ + m_crazyradio_status = msg.data; +} + + +// > For the flying state of the agent +void agentOperatingStateCallback(const std_msgs::Int32& msg) +{ + m_agent_operating_state = msg.data; +} + +// > For the instant controller +void instantControllerChangedCallback(const std_msgs::Int32& msg) +{ + m_instant_controller = msg.data; +} + +// > For the battery level +void newBatteryLevelCallback(const std_msgs::Int32& msg) +{ + m_battery_level = msg.data; +} + +// > For the Default Controller Setpoint +void defaultControllerSetpointChangedCallback(const SetpointWithHeader& newSetpoint) +{ + m_setpoint_default[0] = newSetpoint.x; + m_setpoint_default[1] = newSetpoint.y; + m_setpoint_default[2] = newSetpoint.z; + m_setpoint_default[3] = newSetpoint.yaw; +} + +// > For the Student Controller Setpoint +void studentControllerSetpointChangedCallback(const SetpointWithHeader& newSetpoint) +{ + m_setpoint_student[0] = newSetpoint.x; + m_setpoint_student[1] = newSetpoint.y; + m_setpoint_student[2] = newSetpoint.z; + m_setpoint_student[3] = newSetpoint.yaw; +} + + + + + +// SERVICE CALLBACK FOR PROVIDING STATUS TO THE WEB INTERFACE +bool statusForWebInterfaceCallback(IntStringService::Request &request, IntStringService::Response &response) +{ + // Concatenate the json together using a string stream + std::stringstream ss; + ss << "{\"crazyradiostatus\": \"" << m_crazyradio_status << "\"}"; + std::string s = ss.str(); + // Put the string into the response + //response.data = "test of service for web interface"; + //response.data = "{\"crazyradiostatus\": \"%d\"}", m_crazyradio_status; + response.data = ss.str(); + + // Return success + return true; +} + + + + +// ---------------------------------------------------------------------------------- +// M M A III N N +// MM MM A A I NN N +// M M M A A I N N N +// M M AAAAA I N NN +// M M A A III N N +// ---------------------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + // Starting the ROS-node + ros::init(argc, argv, "AgentStatusForWebInterface"); + + // Create a "ros::NodeHandle" type local variable "nodeHandle" + // as the current node, the "~" indcates that "self" is the + // node handle assigned to this variable. + ros::NodeHandle nodeHandle("~"); + + // Get the namespace of this "AgentStatusForWebInterface" node + std::string m_namespace = ros::this_node::getNamespace(); + ROS_INFO_STREAM("[AGENT STATUS FOR WEB INTERFACE] ros::this_node::getNamespace() = " << m_namespace); + + + + + + // SUBSCRIBERS + + // FOR THE CRAZY RADIO STATUS: + // > Get a node handle to the Crazy Radio + std::string namespace_to_crazyradio = m_namespace + "/CrazyRadio"; + ros::NodeHandle nodeHandle_to_crazyradio(namespace_to_crazyradio); + // > Subscribe to the topic + ros::Subscriber crazyRadioStatusSubscriber = nodeHandle_to_crazyradio.subscribe("CrazyRadioStatus", 1, crazyRadioStatusCallback); + + // FOR THE FLYING STATE OF THE AGENT + // > Get a node handle to the Flying Agent Client + std::string namespace_to_FlyingAgentClient = m_namespace + "/FlyingAgentClient"; + ros::NodeHandle nodeHandle_to_FlyingAgentClient(namespace_to_FlyingAgentClient); + // > Subscribe to the topic + ros::Subscriber agentOperatingStateSubscriber = nodeHandle_to_FlyingAgentClient.subscribe("FlyingState", 1, agentOperatingStateCallback); + + // FOR THE INSTANT CONTROLLER + // > Subscribe to the topic + ros::Subscriber instantControllerSubscriber = nodeHandle_to_FlyingAgentClient.subscribe("ControllerUsed", 1, instantControllerChangedCallback); + + // FOR THE BATTERY LEVEL + // > Get a node handle to the Battery Monitor + std::string namespace_to_BatteryMonitor = m_namespace + "/BatteryMonitor"; + ros::NodeHandle nodeHandle_to_BatteryMonitor(namespace_to_BatteryMonitor); + // > Subscribe to the topic + ros::Subscriber newBatteryLevelSubscriber = nodeHandle_to_BatteryMonitor.subscribe("Level", 1, newBatteryLevelCallback); + + // FOR THE DEFAULT CONTROLLER SETPOINT + // > Get a node handle to the Default Controller Service + std::string namespace_to_DefaultController = m_namespace + "/DefaultControllerService"; + ros::NodeHandle nodeHandle_to_DefaultController(namespace_to_DefaultController); + // > Subscribe to the topic + ros::Subscriber defaultControllerSetpointChangedSubscriber = nodeHandle_to_DefaultController.subscribe("SetpointChanged", 1, defaultControllerSetpointChangedCallback); + + // FOR THE STUDENT CONTROLLER SETPOINT + // > Get a node handle to the Student Controller Service + std::string namespace_to_StudentController = m_namespace + "/StudentControllerService"; + ros::NodeHandle nodeHandle_to_StudentController(namespace_to_StudentController); + // > Subscribe to the topic + ros::Subscriber stuentControllerSetpointChangedSubscriber = nodeHandle_to_StudentController.subscribe("SetpointChanged", 1, studentControllerSetpointChangedCallback); + + + + + + // SERVICE SERVERS + + // Service callback for provide status to the Web Interface + ros::ServiceServer statusForWebInterfaceService = nodeHandle.advertiseService("StatusAsJson", statusForWebInterfaceCallback); + + + + + + // Inform the user the this node is ready + ROS_INFO("[AGENT STATUS FOR WEB INTERFACE] Ready :-)"); + // Spin as a single-thread node + ros::spin(); + + return 0; +} diff --git a/dfall_ws/src/dfall_pkg/srv/IntStringService.srv b/dfall_ws/src/dfall_pkg/srv/IntStringService.srv new file mode 100644 index 0000000000000000000000000000000000000000..0c46a893757e9e93c86d10bb798cc6e37d357532 --- /dev/null +++ b/dfall_ws/src/dfall_pkg/srv/IntStringService.srv @@ -0,0 +1,3 @@ +uint32 data +--- +string data \ No newline at end of file