To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit fc10c3c2 authored by tiagos's avatar tiagos
Browse files

everything closes cleanly now

parent fde16c01
......@@ -77,6 +77,7 @@ private:
ViconData m_vicon_data;
ros::NodeHandle* nh;
ros::Subscriber m_vicon_subscriber;
ros::Subscriber studentID_subscriber;
ros::Subscriber positionData_subscriber;
......
......@@ -27,6 +27,7 @@
#include <QString>
#include <QMetaType>
#include <QDir>
#include <QShortcut>
#include <regex>
#ifdef CATKIN_MAKE
......@@ -52,7 +53,9 @@
#define UWB_UPDATE_DISABLE 0
#define UWB_UPDATE_ENABLE 1
#define UWB_UPDATE_ANCHORS 5
#define UWB_CALIBRATE_ANCHORS 7
#define UWB_CALIBRATE_ANCHORS 7
float offset[3] = {0};
#ifdef CATKIN_MAKE
using namespace d_fall_pps;
......@@ -73,6 +76,7 @@ MainGUIWindow::MainGUIWindow(int argc, char **argv, QWidget *parent) :
MainGUIWindow::~MainGUIWindow()
{
delete ui;
delete _rosNodeThread;
}
int MainGUIWindow::getTabIndexFromName(QString name)
......@@ -239,6 +243,7 @@ void MainGUIWindow::_init()
// add space bar shortcut to stop all motors
ui->all_motors_off_button->setShortcut(tr("Space"));
QShortcut* sk = new QShortcut(QKeySequence(tr("CTRL+C")), this, SLOT(close()));
// set anchor table settings
ui->table_anchorPos->verticalHeader()->setVisible(false);
......@@ -998,9 +1003,9 @@ bool MainGUIWindow::updateUWBSettings(bool enableChecked)
// Receive the updated information
Anchors a;
a.request.x = 1;
a.request.y = 2;
a.request.z = 3;
a.request.x = offset[0];
a.request.y = offset[1];
a.request.z = offset[2];
if(UWBServiceClient.call(a))
{
......@@ -1096,6 +1101,8 @@ void MainGUIWindow::on_reloadAnchors_button_pressed()
UWBServiceClientUpdate_publisher.publish(server_msg);
updateUWBSettings(!ui->checkBox_enable_UWB->isChecked());
ui->checkBox_enable_UWB->setEnabled(true);
}
void MainGUIWindow::on_calibrateAnchors_button_pressed()
......@@ -1112,12 +1119,27 @@ void MainGUIWindow::on_calibrateAnchors_button_pressed()
ui->checkBox_localisation_done->setChecked(true);
ui->checkBox_enable_UWB->setEnabled(true);
ui->reloadAnchors_button->setEnabled(true);
//ui->reloadAnchors_button->setEnabled(true);
ui->set_offset_button->setEnabled(true);
ui->uwbxoffset->setEnabled(true);
ui->uwbyoffset->setEnabled(true);
ui->uwbzoffset->setEnabled(true);
}
void MainGUIWindow::on_set_offset_button_pressed()
{
ROS_WARN("Calib done");
offset[0] = ui->uwbxoffset->value() * 10;
offset[1] = ui->uwbyoffset->value() * 10;
offset[2] = ui->uwbzoffset->value() * 10;
updateUWBSettings(!ui->checkBox_enable_UWB->isChecked());
offset[0] = offset[1] = offset[2] = 0;
ui->uwbxoffset->setValue(0);
ui->uwbyoffset->setValue(0);
ui->uwbzoffset->setValue(0);
ROS_WARN("[Teacher GUI] Set Offset!");
}
void MainGUIWindow::on_comboBoxCFs_currentTextChanged(const QString &arg1)
......@@ -1145,3 +1167,8 @@ void MainGUIWindow::on_all_motors_off_button_clicked()
ROS_ERROR("All motors switched off!");
}
/*void MainGUIWindow::close()
{
ROS_ERROR("Closed");
}*/
......@@ -514,9 +514,9 @@
<property name="text">
<string>Reload Anchors</string>
</property>
<property name="enabled">
<!-- <property name="enabled">
<bool>false</bool>
</property>
</property> -->
</widget>
</item>
......@@ -543,6 +543,9 @@
<property name="singleStep">
<double>0.001</double>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
......@@ -566,6 +569,9 @@
<property name="singleStep">
<double>0.001</double>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
......@@ -589,6 +595,9 @@
<property name="singleStep">
<double>0.001</double>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
......
......@@ -33,13 +33,17 @@ rosNodeThread::rosNodeThread(int argc, char** pArgv, const char * node_name, QO
rosNodeThread::~rosNodeThread()
{
// join the thread
m_pThread->exit();
// delete the nodehandle so ros can shutdown cleanly
delete nh;
if (ros::isStarted())
{
ros::shutdown();
ros::waitForShutdown();
} // end if
m_pThread->wait();
} // end destructor
bool rosNodeThread::init()
......@@ -58,16 +62,18 @@ bool rosNodeThread::init()
ros::start();
ros::Time::init();
ros::NodeHandle nh("~");
//ros::NodeHandle nh("~");
nh = new ros::NodeHandle("~");
m_vicon_subscriber = nh.subscribe("/ViconDataPublisher/ViconData", 100, &rosNodeThread::messageCallback, this);
studentID_subscriber = nh.subscribe("/TeacherService/studentIDs", 1, &rosNodeThread::studentIDCallback, this);
positionData_subscriber = nh.subscribe("/TeacherService/positionData", 1, &rosNodeThread::positionDataCallback, this);
m_vicon_subscriber = nh->subscribe("/ViconDataPublisher/ViconData", 100, &rosNodeThread::messageCallback, this);
studentID_subscriber = nh->subscribe("/TeacherService/studentIDs", 1, &rosNodeThread::studentIDCallback, this);
positionData_subscriber = nh->subscribe("/TeacherService/positionData", 1, &rosNodeThread::positionDataCallback, this);
// clients for db services:
m_read_db_client = nh.serviceClient<CMRead>("/CentralManagerService/Read", false);
m_update_db_client = nh.serviceClient<CMUpdate>("/CentralManagerService/Update", false);
m_command_db_client = nh.serviceClient<CMCommand>("/CentralManagerService/Command", false);
m_read_db_client = nh->serviceClient<CMRead>("/CentralManagerService/Read", false);
m_update_db_client = nh->serviceClient<CMUpdate>("/CentralManagerService/Update", false);
m_command_db_client = nh->serviceClient<CMCommand>("/CentralManagerService/Command", false);
m_pThread->start();
return true;
......
......@@ -11,7 +11,7 @@
</node>
<!-- When we have a GUI, this has to be adapted and included -->
<node pkg="d_fall_pps" name="my_GUI" output="screen" type="my_GUI">
<node pkg="d_fall_pps" name="my_GUI" output="screen" type="my_GUI" required="true">
<!-- <rosparam command="load" file="$(find d_fall_pps)/launch/ControlParams.yaml" /> -->
</node>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment