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 7662abd2 authored by tiagos's avatar tiagos
Browse files

Made the LUT work as a YAML instead of a compiled file

parent 4fa85553
#ifndef TEACHERSERVICE_H
#define TEACHERSERVICE_H
#include "std_msgs/Int32.h"
#include "d_fall_pps/CrazyflieData.h"
#include "StudentSubscriber.h"
//#include "ros/ros.h"
namespace d_fall_pps
{
// Stores the connected student IDs
std::vector<int> studentIDs;
// and subscriptions
std::vector<StudentSubscriber> studentSubscribers;
// Callback once the refresh Student ID button is clicked
void refreshStudents_callback(const std_msgs::Int32 &msg);
// Updates the subscription to the localization data of the students
void subscribeLocalization();
ros::Publisher studentIDs_publisher;
ros::Publisher CFData_publisher;
}
#endif // TEACHERSERVICE_H included
\ No newline at end of file
......@@ -33,6 +33,7 @@
#include "d_fall_pps/CrazyflieDB.h"
#include "d_fall_pps/CrazyflieEntry.h"
#include "d_fall_pps/CFIndex.h"
#include "d_fall_pps/Anchors.h"
#include <std_msgs/Int32.h>
......@@ -189,6 +190,7 @@ private:
std::vector<crazyFly*> CF_vector;
ros::ServiceClient UWBServiceClient;
ros::ServiceClient TeacherServiceClient;
ros::Publisher DBChangedPublisher;
ros::Publisher emergencyStopPublisher;
......@@ -222,6 +224,8 @@ private:
void loadCFs(ros::NodeHandle& nh);
//void createCFObject(const CrazyfliePositionData)
};
......
......@@ -54,6 +54,7 @@ public:
void messageCallback(const ptrToMessage& p_msg);
void studentIDCallback(const std_msgs::Int32MultiArray &ids);
void positionDataCallback(const CrazyfliePositionData& data);
//void positionDataCallback(const CrazyflieData& data);
ros::ServiceClient m_read_db_client;
ros::ServiceClient m_update_db_client;
......@@ -64,6 +65,7 @@ signals:
void newViconData(const ptrToMessage& p_msg);
void newStudentIDs(const std_msgs::Int32MultiArray &ids);
void newPositionData(const CrazyfliePositionData& data);
//void newPositionData(const CrazyflieData& data);
public slots:
void run();
......
......@@ -23,7 +23,7 @@ std::map<std::string, std::string> channel_LUT
// {"CF1", "A12D2"},
// {"CF2", "E341E"},
// {"CF3", "4E21A"},
{"cfOne", "0/76/2M/E7E7E7E701"},
/*{"cfOne", "0/76/2M/E7E7E7E701"},
{"cfTwo", "0/69/2M"},
{"cfThree", "0/72/2M"},
{"cfFour", "0/99/2M"},
......@@ -39,5 +39,5 @@ std::map<std::string, std::string> channel_LUT
{"PPS_CF10", "0/56/2M/E7E7E7E70A"},
{"uwbtest", "0/80/2M/E7E7E7E7E7"},
{"UWB_CF01", "0/80/250K/E7E7E7E7E7"},
{"UWB_CF02", "0/70/2M/E7E7E7E7E7"},
{"UWB_CF02", "0/70/2M/E7E7E7E7E7"},*/
};
......@@ -232,6 +232,7 @@ void MainGUIWindow::_init()
ros::NodeHandle nodeHandle("~");
UWBServiceClient = nodeHandle.serviceClient<Anchors>("/UWBManagerService/UWBData", false);
TeacherServiceClient = nodeHandle.serviceClient<CFIndex>("/TeacherService/Hangar", false);
DBChangedPublisher = nodeHandle.advertise<std_msgs::Int32>("DBChanged", 1);
emergencyStopPublisher = nodeHandle.advertise<std_msgs::Int32>("emergencyStop", 1);
......@@ -294,7 +295,59 @@ void MainGUIWindow::updateComboBoxes()
}
void MainGUIWindow::updateComboBoxesCFs()
{
#ifdef CATKIN_MAKE
ui->comboBoxCFs->clear();
CFIndex cfi;
if(!TeacherServiceClient.call(cfi))
{
ROS_ERROR("[Teacher GUI] could not load CF-Database!");
return;
}
int size = crazyflies_vector.size();
for(int i = 0; i < cfi.response.length; ++i)
{
if(!cf_linker->isCFLinked(cfi.response.data[i]))
{
QString qstr = QString::fromStdString(cfi.response.data[i]);
ui->comboBoxCFs->addItem(qstr);
}
bool found = false;
for(int j = 0; j < size; ++j)
{
if(crazyflies_vector[j]->getName() == cfi.response.data[i])
{
found = true;
break;
}
}
if(!found)
{
CrazyflieData* cfdata = new CrazyflieData();
cfdata->crazyflieName = cfi.response.data[i];
cfdata->x = i * 10;
cfdata->y = 0;
cfdata->z = 0;
cfdata->roll = 0;
cfdata->pitch = 0;
cfdata->yaw = 0;
//cfdata->acquiringTime = data.acquiringTime;
cfdata->occluded = true;
QString filename(":/images/center_rect.svg");
crazyFly* tmp_p_crazyfly = new crazyFly(cfdata, filename);
cf_positionsVector.push_back(tmp_p_crazyfly);
scene->addItem(cf_positionsVector.back());
cf_positionsVector.back()->setAddedToScene(true);
}
}
/*#ifdef CATKIN_MAKE
ui->comboBoxCFs->clear();
for(int i = 0; i < crazyflies_vector.size(); i++)
{
......@@ -304,7 +357,7 @@ void MainGUIWindow::updateComboBoxesCFs()
ui->comboBoxCFs->addItem(qstr);
}
}
#endif
#endif*/
}
void MainGUIWindow::updateComboBoxesCFZones()
......@@ -331,6 +384,8 @@ void MainGUIWindow::updateCFPositions(const CrazyfliePositionData& data)
bool inScene = false;
int index;
//CrazyflieData cfdata = data;
// Reconvert CFPD to CFD
CrazyflieData cfdata;
cfdata.crazyflieName = std::to_string(data.id);
......@@ -1118,7 +1173,10 @@ void MainGUIWindow::loadCFs(ros::NodeHandle& nh)
++counter;
if(success)
{
channel_LUT.insert(std::pair<std::string, std::string>(my_list[0], my_list[1]));
}
}
--counter;
......@@ -1148,6 +1206,9 @@ void MainGUIWindow::loadCFs(ros::NodeHandle& nh)
void MainGUIWindow::on_checkBox_enable_UWB_toggled(bool checked)
{
ROS_ERROR("toggled");
//bool checked = checkState == Qt::Checked;
// Send Command to enable UWB to UWBManagerService
std_msgs::Int32 server_msg;
......@@ -1287,7 +1348,18 @@ void MainGUIWindow::on_set_invert_button_pressed()
void MainGUIWindow::on_comboBoxCFs_currentTextChanged(const QString &arg1)
{
ROS_WARN("Argument %s", arg1.toStdString().c_str());
CFIndex cfi;
cfi.request.cfName = arg1.toStdString();
if(!TeacherServiceClient.call(cfi))
{
ROS_ERROR("[Teacher GUI] failed to get CF Address!");
return;
}
ui->radioAddress_text->setText(QString::fromStdString(cfi.response.data[0]));
/*ROS_WARN("Argument %s", arg1.toStdString().c_str());
std::string key = arg1.toStdString();
auto it = channel_LUT.find(key);
......@@ -1300,7 +1372,7 @@ void MainGUIWindow::on_comboBoxCFs_currentTextChanged(const QString &arg1)
else
{
ROS_INFO("name not found in LUT");
}
}*/
}
......
......@@ -62,7 +62,6 @@ bool rosNodeThread::init()
ros::start();
ros::Time::init();
//ros::NodeHandle nh("~");
nh = new ros::NodeHandle("~");
......
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