diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h index 9ef5f5338135cc83fcff19bd3a665af381bfea74..59a83270d896999da551d02b8ae12e79c7060f9d 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h @@ -3,6 +3,35 @@ #include <QWidget> +#ifdef CATKIN_MAKE +#include <std_msgs/Int32.h> +#include <std_msgs/Float32.h> + +#include <ros/ros.h> +#include <ros/network.h> +#include <ros/package.h> + +// #include "d_fall_pps/AreaBounds.h" +// #include "d_fall_pps/CrazyflieContext.h" +// #include "d_fall_pps/CMQuery.h" + +// using namespace d_fall_pps; +#endif + + +// COMMANDS FOR THE FLYING STATE/CONTROLLER USED +// The constants that "command" changes in the +// operation state of this agent. These "commands" +// are sent from this GUI node to the "PPSClient" +// node where the command is enacted +#define CMD_USE_SAFE_CONTROLLER 1 +#define CMD_USE_DEMO_CONTROLLER 2 +#define CMD_USE_STUDENT_CONTROLLER 3 +#define CMD_USE_MPC_CONTROLLER 4 +#define CMD_USE_REMOTE_CONTROLLER 5 +#define CMD_USE_TUNING_CONTROLLER 6 + + namespace Ui { class EnableControllerLoadYamlBar; } @@ -31,6 +60,15 @@ private slots: private: Ui::EnableControllerLoadYamlBar *ui; + +#ifdef CATKIN_MAKE + // --------------------------------------------------- // + // PRIVATE VARIABLES FOR ROS + + // PUBLISHERS AND SUBSRIBERS + // > For Crazyradio commands based on button clicks + ros::Publisher commandAllPublisher; +#endif }; #endif // ENABLECONTROLLERLOADYAMLBAR_H diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp index 7e3dee64e552b25ff067659511ec957797aa06f1..8fd105fccb923e4055c648f05704e3ace75edcc2 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp @@ -6,6 +6,16 @@ EnableControllerLoadYamlBar::EnableControllerLoadYamlBar(QWidget *parent) : ui(new Ui::EnableControllerLoadYamlBar) { ui->setupUi(this); + + +#ifdef CATKIN_MAKE + //ros::init(); + // CREATE A NODE HANDLE TO THE ROOT OF THE D-FaLL SYSTEM + ros::NodeHandle dfall_root_nodeHandle("/dfall"); + + commandAllPublisher = dfall_root_nodeHandle.advertise<std_msgs::Int32>("/my_GUI/commandAllAgents", 1); +#endif + } EnableControllerLoadYamlBar::~EnableControllerLoadYamlBar() @@ -20,17 +30,32 @@ EnableControllerLoadYamlBar::~EnableControllerLoadYamlBar() void EnableControllerLoadYamlBar::on_enable_safe_button_clicked() { - +#ifdef CATKIN_MAKE + std_msgs::Int32 msg; + msg.data = CMD_USE_SAFE_CONTROLLER; + this->commandAllPublisher.publish(msg); + ROS_INFO("[FLYING AGENT GUI] Enable Safe Controller"); +#endif } void EnableControllerLoadYamlBar::on_enable_demo_button_clicked() { - +#ifdef CATKIN_MAKE + std_msgs::Int32 msg; + msg.data = CMD_USE_DEMO_CONTROLLER; + this->commandAllPublisher.publish(msg); + ROS_INFO("[FLYING AGENT GUI] Enable Demo Controller"); +#endif } void EnableControllerLoadYamlBar::on_enable_student_button_clicked() { - +#ifdef CATKIN_MAKE + std_msgs::Int32 msg; + msg.data = CMD_USE_STUDENT_CONTROLLER; + this->commandAllPublisher.publish(msg); + ROS_INFO("[FLYING AGENT GUI] Enable Student Controller"); +#endif } void EnableControllerLoadYamlBar::on_enable_mpc_button_clicked() diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp index 7a2ae595abbf8899253df4dd12ce9b6ac11e7ff4..13382717afcd986dd53802e851654e8964486949 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp @@ -40,15 +40,17 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : //ROS_INFO("[flyingAgentGUI] Debug Point 5"); m_rosNodeThread = new rosNodeThread(argc, argv, "flyingAgentGUI"); #endif + +#ifdef CATKIN_MAKE + m_rosNodeThread->init(); +#endif ui->setupUi(this); // ADD KEYBOARD SHORTCUTS // > For "kill GUI node", press "CTRL+C" while the GUI window is the focus m_close_GUI_shortcut = new QShortcut(QKeySequence(tr("CTRL+C")), this, SLOT(close())); -#ifdef CATKIN_MAKE - m_rosNodeThread->init(); -#endif + }