Commit 6fc8fb41 authored by roangel's avatar roangel
Browse files

Local position got in GUI. Now need to try it downstairs

parent 49f99aea
......@@ -39,12 +39,28 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
crazyRadioCommandPublisher = nh_PPSClient.advertise<std_msgs::Int32>("crazyRadioCommand", 1);
PPSClientCommandPublisher = nh_PPSClient.advertise<std_msgs::Int32>("Command", 1);
// get student ID
// First get student ID
if(!nh_PPSClient.getParam("studentID", m_student_id))
{
ROS_ERROR("Failed to get studentID");
}
// Then, Central manager
centralManager = nodeHandle.serviceClient<CMQuery>("/CentralManagerService/Query", false);
loadCrazyflieContext();
// we now have the m_context variable with the current context. Put CF Name in label
QString qstr = "StudentID ";
qstr.append(QString::number(m_student_id));
qstr.append(" connected to CF ");
qstr.append(QString::fromStdString(m_context.crazyflieName));
ui->groupBox->setTitle(qstr);
disableGUI();
}
......@@ -165,10 +181,13 @@ void MainWindow::loadCrazyflieContext()
centralManager.waitForExistence(ros::Duration(-1));
if(centralManager.call(contextCall)) {
if(centralManager.call(contextCall))
{
m_context = contextCall.response.crazyflieContext;
ROS_INFO_STREAM("CrazyflieContext:\n" << m_context);
} else {
}
else
{
ROS_ERROR("Failed to load context");
}
......@@ -196,6 +215,28 @@ void MainWindow::updateNewViconData(const ptrToMessage& p_msg) //connected to ne
for(std::vector<CrazyflieData>::const_iterator it = p_msg->crazyflies.begin(); it != p_msg->crazyflies.end(); ++it)
{
CrazyflieData global = *it;
if(global.crazyflieName == m_context.crazyflieName)
{
CrazyflieData local = global;
coordinatesToLocal(local);
// now we have the local coordinates, put them in the labels
QString qstr = "x = ";
qstr.append(QString::number(local.x));
ui->current_x->setText(qstr);
qstr = "y = ";
qstr.append(QString::number(local.y));
ui->current_y->setText(qstr);
qstr = "z = ";
qstr.append(QString::number(local.z));
ui->current_z->setText(qstr);
qstr = "yaw = ";
qstr.append(QString::number(local.yaw));
ui->current_yaw->setText(qstr);
}
}
}
......
......@@ -56,28 +56,28 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="current_x">
<property name="text">
<string>x =</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="current_z">
<property name="text">
<string>z =</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="current_y">
<property name="text">
<string>y =</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<widget class="QLabel" name="current_yaw">
<property name="text">
<string>yaw = </string>
</property>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.2, 2017-08-25T10:03:36. -->
<!-- Written by QtCreator 4.0.2, 2017-08-28T10:10:56. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
......@@ -429,7 +429,6 @@ int main(int argc, char* argv[])
ros::NodeHandle nodeHandle("~");
loadParameters(nodeHandle);
//ros::service::waitForService("/CentralManagerService/CentralManager");
centralManager = nodeHandle.serviceClient<CMQuery>("/CentralManagerService/Query", false);
loadCrazyflieContext();
......
Supports Markdown
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