Commit 74908be7 authored by roangel's avatar roangel
Browse files

First try DBChanged topic. Need to test it

parent 7a14460f
......@@ -17,6 +17,8 @@
#include "d_fall_pps/CrazyflieDB.h"
#include "d_fall_pps/CrazyflieEntry.h"
#include <std_msgs/Int32.h>
using namespace d_fall_pps;
#endif
......@@ -142,6 +144,8 @@ private:
std::vector<Marker*> markers_vector;
std::vector<crazyFly*> crazyflies_vector;
CFLinker* cf_linker;
ros::Publisher DBChangedPublisher;
#endif
void updateComboBoxesCFs();
......
......@@ -20,6 +20,10 @@
#include "d_fall_pps/CMUpdate.h"
#include "d_fall_pps/CMCommand.h"
#include "CentralManagerService.h"
#include <ros/ros.h>
#include <ros/network.h>
#endif
#include <string>
......@@ -191,6 +195,9 @@ void MainGUIWindow::_init()
qRegisterMetaType<ptrToMessage>("ptrToMessage");
QObject::connect(_rosNodeThread, SIGNAL(newViconData(const ptrToMessage&)), this, SLOT(updateNewViconData(const ptrToMessage&)));
QObject::connect(cf_linker, SIGNAL(updateComboBoxes()), this, SLOT(updateComboBoxes()));
ros::NodeHandle nodeHandle("~");
DBChangedPublisher = nodeHandle.advertise<std_msgs::Int32>("DBChanged", 1);
#endif
}
......@@ -756,6 +763,11 @@ void MainGUIWindow::on_save_in_DB_button_clicked()
// save the database in the file
fill_database_file();
// Now also publish a ROS message stating that we changed the DB, so the nodes can update it
std_msgs::Int32 msg;
msg.data = 1;
this->DBChangedPublisher.publish(msg);
}
void MainGUIWindow::clear_database_file()
......
......@@ -81,6 +81,8 @@ private:
ros::Publisher setpointPublisher;
ros::Subscriber setpointSubscriber;
ros::Subscriber DBChangedSubscriber;
ros::ServiceClient centralManager;
// callbacks
......@@ -88,6 +90,7 @@ private:
void CFBatteryCallback(const std_msgs::Float32& msg);
void flyingStateChangedCallback(const std_msgs::Int32& msg);
void setpointCallback(const Setpoint& newSetpoint);
void DBChangedCallback(const std_msgs::Int32& msg);
float fromVoltageToPercent(float voltage);
void updateBatteryVoltage(float battery_voltage);
......
......@@ -39,6 +39,7 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
setpointPublisher = nodeHandle.advertise<Setpoint>("SafeControllerService/Setpoint", 1);
setpointSubscriber = nodeHandle.subscribe("SafeControllerService/Setpoint", 1, &MainWindow::setpointCallback, this);
DBChangedSubscriber = nodeHandle.subscribe("my_GUI/DBChanged", 1, &MainWindow::DBChangedCallback, this);
// communication with PPS Client, just to make it possible to communicate through terminal also we use PPSClient's name
......@@ -84,6 +85,11 @@ void MainWindow::enableGUI()
ui->groupBox->setEnabled(true);
}
void MainWindow::DBChangedCallback(const std_msgs::Int32& msg)
{
loadCrazyflieContext();
}
void MainWindow::setpointCallback(const Setpoint& newSetpoint)
{
m_setpoint = newSetpoint;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>424</height>
<width>809</width>
<height>573</height>
</rect>
</property>
<property name="windowTitle">
......@@ -15,6 +15,563 @@
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Safe Controller</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="6" column="1">
<widget class="QLineEdit" name="current_roll">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="current_y">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="current_yaw">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="current_z">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="current_x_label">
<property name="text">
<string>x =</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="current_z_label">
<property name="text">
<string>z =</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="current_y_label">
<property name="text">
<string>y =</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="current_yaw_label">
<property name="text">
<string>yaw = </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="current_x">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="current_pitch_label">
<property name="text">
<string>pitch =</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="current_roll_label">
<property name="text">
<string>roll =</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="current_pitch">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Current</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="diff_x">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="diff_y">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="diff_z">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="diff_yaw">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Difference</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="2">
<widget class="QLineEdit" name="new_setpoint_y"/>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="new_setpoint_yaw"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="new_setpoint_x"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="current_setpoint_y">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="current_setpoint_x">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>yaw =</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Current</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>x =</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>z =</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>y =</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="current_setpoint_z">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="set_setpoint_button">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Set setpoint</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="current_setpoint_yaw">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="new_setpoint_z"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Setpoint:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_13">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>New</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Enable Controller</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Custom Controller</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="6" column="1">
<widget class="QLineEdit" name="current_roll_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="current_y_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="current_yaw_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="current_z_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="current_x_label_2">
<property name="text">
<string>x =</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="current_z_label_2">
<property name="text">
<string>z =</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="current_y_label_2">
<property name="text">
<string>y =</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="current_yaw_label_2">
<property name="text">
<string>yaw = </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="current_x_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="current_pitch_label_2">
<property name="text">
<string>pitch =</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="current_roll_label_2">
<property name="text">
<string>roll =</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="current_pitch_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Current</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="diff_x_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="diff_y_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="diff_z_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="diff_yaw_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Difference</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="2" column="2">
<widget class="QLineEdit" name="new_setpoint_y_2"/>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="new_setpoint_yaw_2"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="new_setpoint_x_2"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="current_setpoint_y_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="current_setpoint_x_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>yaw =</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_15">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Current</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>x =</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>z =</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>y =</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="current_setpoint_z_2">
<property name="readOnly">