Commit 3cdac115 authored by pragash1's avatar pragash1
Browse files

Added GUI DroneX Tab

Added necessary files for DroneX Controller
parent 63e4a175
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#define REMOTE_CONTROLLER 5 #define REMOTE_CONTROLLER 5
#define TUNING_CONTROLLER 6 #define TUNING_CONTROLLER 6
#define PICKER_CONTROLLER 7 #define PICKER_CONTROLLER 7
#define DRONEX_CONTROLLER 8
// Commands for CrazyRadio // Commands for CrazyRadio
...@@ -77,6 +78,7 @@ ...@@ -77,6 +78,7 @@
#define CMD_USE_REMOTE_CONTROLLER 5 #define CMD_USE_REMOTE_CONTROLLER 5
#define CMD_USE_TUNING_CONTROLLER 6 #define CMD_USE_TUNING_CONTROLLER 6
#define CMD_USE_PICKER_CONTROLLER 7 #define CMD_USE_PICKER_CONTROLLER 7
#define CMD_USE_DRONEX_CONTROLLER 8
#define CMD_CRAZYFLY_TAKE_OFF 11 #define CMD_CRAZYFLY_TAKE_OFF 11
#define CMD_CRAZYFLY_LAND 12 #define CMD_CRAZYFLY_LAND 12
...@@ -109,6 +111,7 @@ ...@@ -109,6 +111,7 @@
#define LOAD_YAML_REMOTE_CONTROLLER_AGENT 5 #define LOAD_YAML_REMOTE_CONTROLLER_AGENT 5
#define LOAD_YAML_TUNING_CONTROLLER_AGENT 6 #define LOAD_YAML_TUNING_CONTROLLER_AGENT 6
#define LOAD_YAML_PICKER_CONTROLLER_AGENT 7 #define LOAD_YAML_PICKER_CONTROLLER_AGENT 7
#define LOAD_YAML_DRONEX_CONTROLLER_AGENT 8
#define LOAD_YAML_SAFE_CONTROLLER_COORDINATOR 11 #define LOAD_YAML_SAFE_CONTROLLER_COORDINATOR 11
#define LOAD_YAML_DEMO_CONTROLLER_COORDINATOR 12 #define LOAD_YAML_DEMO_CONTROLLER_COORDINATOR 12
...@@ -117,6 +120,8 @@ ...@@ -117,6 +120,8 @@
#define LOAD_YAML_REMOTE_CONTROLLER_COORDINATOR 15 #define LOAD_YAML_REMOTE_CONTROLLER_COORDINATOR 15
#define LOAD_YAML_TUNING_CONTROLLER_COORDINATOR 16 #define LOAD_YAML_TUNING_CONTROLLER_COORDINATOR 16
#define LOAD_YAML_PICKER_CONTROLLER_COORDINATOR 17 #define LOAD_YAML_PICKER_CONTROLLER_COORDINATOR 17
#define LOAD_YAML_DRONEX_CONTROLLER_COORDINATOR 18
// FOR WHICH BUTTON WAS PRESSED IN THE PICKER CONTOLLER // FOR WHICH BUTTON WAS PRESSED IN THE PICKER CONTOLLER
...@@ -235,6 +240,11 @@ private slots: ...@@ -235,6 +240,11 @@ private slots:
// > For the dial // > For the dial
void on_picker_yaw_dial_valueChanged(int value); void on_picker_yaw_dial_valueChanged(int value);
// Interationswith the DroneX controller tab
void on_dronex_take_off_button_clicked();
void on_dronex_land_button_clicked();
...@@ -322,6 +332,10 @@ private: ...@@ -322,6 +332,10 @@ private:
ros::Publisher tuningVerticalGainPublisher; ros::Publisher tuningVerticalGainPublisher;
ros::Publisher tuningHeadingGainPublisher; ros::Publisher tuningHeadingGainPublisher;
// > For the DRONEX CONTROLLER
ros::Publisher droneXSetpointPublisher;
ros::Subscriber droneXSetpointSubscriber;
// > For the PICKER CONTROLLER // > For the PICKER CONTROLLER
......
...@@ -109,6 +109,13 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : ...@@ -109,6 +109,13 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
pickerSetpointSubscriber = nodeHandle.subscribe("PickerControllerService/Setpoint", 1, &MainWindow::pickerSetpointCallback, this); pickerSetpointSubscriber = nodeHandle.subscribe("PickerControllerService/Setpoint", 1, &MainWindow::pickerSetpointCallback, this);
pickerSetpointToGUISubscriber = nodeHandle.subscribe("PickerControllerService/SetpointToGUI", 1, &MainWindow::pickerSetpointCallback, this); pickerSetpointToGUISubscriber = nodeHandle.subscribe("PickerControllerService/SetpointToGUI", 1, &MainWindow::pickerSetpointCallback, this);
//TODO add Publisher and Subscriber for DroneX
// SET ALL SLIDERS AND DIALS TO DEFAULT VALUES // SET ALL SLIDERS AND DIALS TO DEFAULT VALUES
ui->picker_z_slider->setValue( 40 ); ui->picker_z_slider->setValue( 40 );
ui->picker_mass_slider->setValue( 29 ); ui->picker_mass_slider->setValue( 29 );
...@@ -231,6 +238,8 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : ...@@ -231,6 +238,8 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
initialize_student_setpoint(); initialize_student_setpoint();
initialize_mpc_setpoint(); initialize_mpc_setpoint();
initialize_picker_setpoint(); initialize_picker_setpoint();
//TODO add initialize_dronex_setpoint();
} }
...@@ -265,6 +274,7 @@ void MainWindow::highlightSafeControllerTab() ...@@ -265,6 +274,7 @@ void MainWindow::highlightSafeControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
} }
void MainWindow::highlightPickerControllerTab() void MainWindow::highlightPickerControllerTab()
{ {
...@@ -275,6 +285,7 @@ void MainWindow::highlightPickerControllerTab() ...@@ -275,6 +285,7 @@ void MainWindow::highlightPickerControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
} }
void MainWindow::highlightDemoControllerTab() void MainWindow::highlightDemoControllerTab()
{ {
...@@ -285,6 +296,7 @@ void MainWindow::highlightDemoControllerTab() ...@@ -285,6 +296,7 @@ void MainWindow::highlightDemoControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
} }
void MainWindow::highlightStudentControllerTab() void MainWindow::highlightStudentControllerTab()
{ {
...@@ -295,6 +307,7 @@ void MainWindow::highlightStudentControllerTab() ...@@ -295,6 +307,7 @@ void MainWindow::highlightStudentControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
} }
void MainWindow::highlightMpcControllerTab() void MainWindow::highlightMpcControllerTab()
{ {
...@@ -305,6 +318,7 @@ void MainWindow::highlightMpcControllerTab() ...@@ -305,6 +318,7 @@ void MainWindow::highlightMpcControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::green); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::green);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
} }
void MainWindow::highlightRemoteControllerTab() void MainWindow::highlightRemoteControllerTab()
{ {
...@@ -315,6 +329,7 @@ void MainWindow::highlightRemoteControllerTab() ...@@ -315,6 +329,7 @@ void MainWindow::highlightRemoteControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::green); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::green);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
} }
void MainWindow::highlightTuningControllerTab() void MainWindow::highlightTuningControllerTab()
{ {
...@@ -325,8 +340,19 @@ void MainWindow::highlightTuningControllerTab() ...@@ -325,8 +340,19 @@ void MainWindow::highlightTuningControllerTab()
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black); ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::green); ui->tabWidget->tabBar()->setTabTextColor(6, Qt::green);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::black);
}
void MainWindow::highlightDroneXControllerTab()
{
ui->tabWidget->tabBar()->setTabTextColor(0, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(1, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(2, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(3, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(4, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(5, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(6, Qt::black);
ui->tabWidget->tabBar()->setTabTextColor(7, Qt::green);
} }
void MainWindow::DBChangedCallback(const std_msgs::Int32& msg) void MainWindow::DBChangedCallback(const std_msgs::Int32& msg)
{ {
...@@ -359,6 +385,8 @@ void MainWindow::controllerUsedChangedCallback(const std_msgs::Int32& msg) ...@@ -359,6 +385,8 @@ void MainWindow::controllerUsedChangedCallback(const std_msgs::Int32& msg)
case PICKER_CONTROLLER: case PICKER_CONTROLLER:
highlightPickerControllerTab(); highlightPickerControllerTab();
break; break;
case DRONEX_CONTROLLER:
highlightDroneXControllerTab();
default: default:
break; break;
} }
...@@ -1490,6 +1518,26 @@ void MainWindow::on_enable_picker_controller_clicked() ...@@ -1490,6 +1518,26 @@ void MainWindow::on_enable_picker_controller_clicked()
// TODO
// # Custom command buttons - FOR DRONEX CONTROLLER
void MainWindow::on_dronex_take_off_button_clicked(){
ROS_INFO("DroneX: Take off from DroneX! - Please upgrade my function in MainWindow.cpp!!!!!!!!!!!!!!!!!!!");
}
void MainWindow::on_dronex_land_button_clicked(){
ROS_INFO("DroneX: Land on DroneX - Please upgrade my function in MainWindow.cpp!!!!!!!!!!!!!!!!!!!");
}
// # Custom command buttons - FOR DEMO CONTROLLER // # Custom command buttons - FOR DEMO CONTROLLER
void MainWindow::on_demoButton_1_clicked() void MainWindow::on_demoButton_1_clicked()
{ {
...@@ -1910,6 +1958,3 @@ void MainWindow::on_picker_yaw_dial_valueChanged(int value) ...@@ -1910,6 +1958,3 @@ void MainWindow::on_picker_yaw_dial_valueChanged(int value)
// Publish the message // Publish the message
this->pickerYawSetpointPublisher.publish(msg); this->pickerYawSetpointPublisher.publish(msg);
} }
...@@ -391,7 +391,7 @@ ...@@ -391,7 +391,7 @@
</font> </font>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<property name="usesScrollButtons"> <property name="usesScrollButtons">
<bool>true</bool> <bool>true</bool>
...@@ -399,6 +399,35 @@ ...@@ -399,6 +399,35 @@
<property name="tabsClosable"> <property name="tabsClosable">
<bool>false</bool> <bool>false</bool>
</property> </property>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Page</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_22">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_21">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QPushButton" name="take_off_mothership_button">
<property name="text">
<string>Take off from Mothership</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="land_on_mothership_button">
<property name="text">
<string>Land on Mothership</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_safe"> <widget class="QWidget" name="tab_safe">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
...@@ -4006,6 +4035,48 @@ ...@@ -4006,6 +4035,48 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="2">
<widget class="QLabel" name="label_22">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>YAML</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="8" column="1"> <item row="8" column="1">
<widget class="Line" name="line_20"> <widget class="Line" name="line_20">
<property name="orientation"> <property name="orientation">
...@@ -4418,41 +4489,6 @@ ...@@ -4418,41 +4489,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2">
<widget class="QLabel" name="label_22">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>YAML</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="1"> <item row="5" column="1">
<widget class="Line" name="line_4"> <widget class="Line" name="line_4">
<property name="orientation"> <property name="orientation">
...@@ -4467,13 +4503,6 @@ ...@@ -4467,13 +4503,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="10" column="1"> <item row="10" column="1">
<widget class="Line" name="line_5"> <widget class="Line" name="line_5">
<property name="orientation"> <property name="orientation">
...@@ -4659,7 +4688,7 @@ ...@@ -4659,7 +4688,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1500</width> <width>1500</width>
<height>25</height> <height>22</height>
</rect> </rect>
</property> </property>
</widget> </widget>
......
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
#define REMOTE_CONTROLLER 5 #define REMOTE_CONTROLLER 5
#define TUNING_CONTROLLER 6 #define TUNING_CONTROLLER 6
#define PICKER_CONTROLLER 7 #define PICKER_CONTROLLER 7
#define DRONEX_CONTROLLER 8
// The constants that "command" changes in the // The constants that "command" changes in the
// operation state of this agent // operation state of this agent
...@@ -100,6 +101,7 @@ ...@@ -100,6 +101,7 @@
#define CMD_USE_REMOTE_CONTROLLER 5 #define CMD_USE_REMOTE_CONTROLLER 5
#define CMD_USE_TUNING_CONTROLLER 6 #define CMD_USE_TUNING_CONTROLLER 6
#define CMD_USE_PICKER_CONTROLLER 7 #define CMD_USE_PICKER_CONTROLLER 7
#define CMD_USE_DRONEX_CONTROLLER 8
#define CMD_CRAZYFLY_TAKE_OFF 11 #define CMD_CRAZYFLY_TAKE_OFF 11
...@@ -162,6 +164,9 @@ ros::ServiceClient remoteController; ...@@ -162,6 +164,9 @@ ros::ServiceClient remoteController;
ros::ServiceClient tuningController; ros::ServiceClient tuningController;
// The Picker controller specified in the ClientConfig.yaml // The Picker controller specified in the ClientConfig.yaml
ros::ServiceClient pickerController; ros::ServiceClient pickerController;
// The DroneX controller specified in the ClientConfig.yaml
//TODO
ros::ServiceClient dronexController;
//values for safteyCheck //values for safteyCheck
...@@ -308,14 +313,10 @@ void loadMpcController(); ...@@ -308,14 +313,10 @@ void loadMpcController();
void loadRemoteController(); void loadRemoteController();
void loadTuningController(); void loadTuningController();
void loadPickerController(); void loadPickerController();
void loadDroneXController();
void sendMessageUsingController(int controller); void sendMessageUsingController(int controller);
void setInstantController(int controller); void setInstantController(int controller);
int getInstantController(); int getInstantController();
void setControllerUsed(int controller); void setControllerUsed(int controller);
int getControllerUsed(); int getControllerUsed();
...@@ -5,6 +5,7 @@ mpcController: "MpcControllerService/MpcController" ...@@ -5,6 +5,7 @@ mpcController: "MpcControllerService/MpcController"
remoteController: "RemoteControllerService/RemoteController" remoteController: "RemoteControllerService/RemoteController"
tuningController: "TuningControllerService/TuningController" tuningController: "TuningControllerService/TuningController"
pickerController: "PickerControllerService/PickerController" pickerController: "PickerControllerService/PickerController"
droneXController: "DroneXControllerService/DroneXController"
strictSafety: false strictSafety: false
angleMargin: 0.8 angleMargin: 0.8
...@@ -12,4 +13,3 @@ angleMargin: 0.8 ...@@ -12,4 +13,3 @@ angleMargin: 0.8
battery_threshold_while_flying: 2.60 # in V battery_threshold_while_flying: 2.60 # in V
battery_threshold_while_motors_off: 3.30 # in V battery_threshold_while_motors_off: 3.30 # in V
battery_polling_period: 200 # in ms battery_polling_period: 200 # in ms
4,PPS_CF03,0/16/2M/E7E7E7E703,0,0.345924,-1.31629,-0.2,4.30616,1.15886,1.2
...@@ -307,6 +307,10 @@ void viconCallback(const ViconData& viconData) ...@@ -307,6 +307,10 @@ void viconCallback(const ViconData& viconData)
case PICKER_CONTROLLER: case PICKER_CONTROLLER:
success = pickerController.call(controllerCall); success = pickerController.call(controllerCall);
break; break;
//TODO
case DRONEX_CONTROLLER:
success = droneXController.call(controllerCall);
break;
default: default:
ROS_ERROR("[PPS CLIENT] the current controller was not recognised"); ROS_ERROR("[PPS CLIENT] the current controller was not recognised");
break; break;
...@@ -473,6 +477,11 @@ void commandCallback(const std_msgs::Int32& commandMsg) { ...@@ -473,6 +477,11 @@ void commandCallback(const std_msgs::Int32& commandMsg) {
setControllerUsed(PICKER_CONTROLLER); setControllerUsed(PICKER_CONTROLLER);
break; break;
//TODO
case CMD_USE_DRONEX_CONTROLLER:
ROS_INFO("[PPS CLIENT] USE_DRONEX_CONTROLLER Command received");
setControllerUsed(DRONEX_CONTROLLER);
break;
case CMD_CRAZYFLY_TAKE_OFF: case CMD_CRAZYFLY_TAKE_OFF:
if(flying_state == STATE_MOTORS_OFF) if(flying_state == STATE_MOTORS_OFF)
{ {
...@@ -895,6 +904,22 @@ void loadPickerController() ...@@ -895,6 +904,22 @@ void loadPickerController()
ROS_INFO_STREAM("[PPS CLIENT] Loaded picker controller " << pickerController.getService()); ROS_INFO_STREAM("[PPS CLIENT] Loaded picker controller " << pickerController.getService());
} }
// TODO
void loadDroneXController(){
ros::NodeHandle nodeHandle("~");
std::string droneXControllerName;
if(!nodeHandle.getParam("droneXController", droneXControllerName))
{
ROS_ERROR("[PPS CLIENT] Failed to get droneX controller name");
return;
}
droneXController = ros::service::createClient<Controller>(droneXControllerName, true);
ROS_INFO_STREAM("[PPS CLIENT] Loaded droneX controller " << droneXController.getService());