From f063d00106e7c8fcd34ea052ca499f83a4c527b5 Mon Sep 17 00:00:00 2001 From: ucart <ucart_groundstation@iastate.edu> Date: Thu, 20 Apr 2017 00:04:08 -0500 Subject: [PATCH] small updates on gui --- controls/DataAnalysisTool/Tool/DataAnalysis.m | 2 +- controls/DataAnalysisTool/Tool/simplePlots.m | 5 +- .../gui/MicroCART/MicroCART.pro.user | 74 ++----------------- groundStation/gui/MicroCART/mainwindow.cpp | 17 ++--- groundStation/gui/MicroCART/mainwindow.h | 2 + groundStation/gui/MicroCART/mainwindow.ui | 7 +- groundStation/gui/MicroCART/quaditem.cpp | 16 ++-- groundStation/gui/MicroCART/quaditem.h | 2 +- groundStation/gui/MicroCART/trackerworker.cpp | 1 + groundStation/src/backend/backend.c | 7 +- wifi_bridge/test_scripts/tcp_timer.py | 13 ++-- 11 files changed, 47 insertions(+), 99 deletions(-) diff --git a/controls/DataAnalysisTool/Tool/DataAnalysis.m b/controls/DataAnalysisTool/Tool/DataAnalysis.m index a7b873173..c5c94179d 100644 --- a/controls/DataAnalysisTool/Tool/DataAnalysis.m +++ b/controls/DataAnalysisTool/Tool/DataAnalysis.m @@ -8,7 +8,7 @@ % window. % %fname = 'sampleLogFileWithMarker.txt'; -fname = ''; +fname = '../../../groundStation/logs/tune_of_w_velocity_2.txt'; % PLOTTING SWITCHES - set them to 0 or 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % diff --git a/controls/DataAnalysisTool/Tool/simplePlots.m b/controls/DataAnalysisTool/Tool/simplePlots.m index 90bef7420..2e9e261cd 100644 --- a/controls/DataAnalysisTool/Tool/simplePlots.m +++ b/controls/DataAnalysisTool/Tool/simplePlots.m @@ -163,7 +163,8 @@ linkaxes([ax1, ax2, ax3, ax4], 'x'); %% vel flow figure; ax2 = subplot(2,2,1); -plot(expData.Time.data, expData.OF_Integrate_X_Integrated.data - expData.X_pos_PID_Correction.data); hold on; +plot(expData.Time.data, expData.OF_Offset_Angle_Rotated_X.data - expData.RC_Pitch_Constant.data); hold on; +plot(expData.Time.data, expData.OF_Offset_Angle_Rotated_X.data); hold on; %plot(expData.Time.data, expData.X_Vel_Correction.data); hold on; %plot(expData.Time.data, [0; raw_derivative]); title('X velocity error'); @@ -174,7 +175,7 @@ title('x vel output'); ax3 = subplot(2,2,3); plot(expData.Time.data, expData.Pitch_PID_Correction.data); hold on; -plot(expData.Time.data, expData.VRPN_Pitch_Constant.data .* 10); +plot(expData.Time.data, expData.Pitch_trim_add_Sum.data .* 10); title('pitch output'); legend('output', 'Pitch x10'); diff --git a/groundStation/gui/MicroCART/MicroCART.pro.user b/groundStation/gui/MicroCART/MicroCART.pro.user index b845d25d8..f36c56fc6 100644 --- a/groundStation/gui/MicroCART/MicroCART.pro.user +++ b/groundStation/gui/MicroCART/MicroCART.pro.user @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 4.0.1, 2017-04-11T17:47:13. --> +<!-- Written by QtCreator 4.1.0, 2017-04-19T23:57:31. --> <qtcreator> <data> <variable>EnvironmentId</variable> - <value type="QByteArray">{ec588c71-c0cc-43f4-8233-a07fa24de8ad}</value> + <value type="QByteArray">{f7736f41-610d-4989-a7d9-6e994afe94ba}</value> </data> <data> <variable>ProjectExplorer.Project.ActiveTarget</variable> @@ -61,72 +61,12 @@ <valuemap type="QVariantMap"> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{c6f8ca21-0eb9-4188-b2e8-fae8725afa1b}</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{94de1029-defb-4d1d-a0ac-6d51aba06ea3}</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/Microcart_17-18/groundStation/gui/build-MicroCART-Desktop-Debug</value> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> - <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value> - <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value> - <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> - <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> - <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> - <value type="QString">-w</value> - <value type="QString">-r</value> - </valuelist> - <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> - <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> - <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value> - <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"> - <value type="QString">-w</value> - <value type="QString">-r</value> - </valuelist> - <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value> - <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> - </valuemap> - <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> - <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> - <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value> - <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> - <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> - </valuemap> - <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/Microcart_17-18/groundStation/gui/build-MicroCART-Desktop-Release</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory"></value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> @@ -185,7 +125,7 @@ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> </valuemap> - <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value> + <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value> <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value> @@ -244,13 +184,13 @@ <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MicroCART</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jake/Microcart_17-18/groundStation/gui/MicroCART/MicroCART.pro</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/local/ucart/Documents/MicroCART_17-18/groundStation/gui/MicroCART/MicroCART.pro</value> <value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">MicroCART.pro</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> - <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/jake/Microcart_17-18/groundStation/gui/build-MicroCART-Desktop-Debug</value> + <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/local/ucart/Documents/MicroCART_17-18/groundStation/gui/MicroCART</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp index 22df6f238..29c350553 100644 --- a/groundStation/gui/MicroCART/mainwindow.cpp +++ b/groundStation/gui/MicroCART/mainwindow.cpp @@ -28,9 +28,10 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); QGraphicsScene *topScene = new QGraphicsScene(this); - QuadItem * quad = new QuadItem(); ui->topView->setScene(topScene); + QuadItem * quad = new QuadItem(); + topScene->addItem(); topScene->addItem(quad); /* Set up environment variables */ @@ -51,7 +52,7 @@ MainWindow::MainWindow(QWidget *parent) : this, SLOT (updateTracker(float, float, float, float, float, float))); connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)), - quad, SLOT (quad->updateQuad(float, float, float, float, float, float))); + quad, SLOT(updateQuad(float,float,float,float,float,float))); /* Create another worker for the control graph */ QThread * cwThread = new QThread(this); @@ -112,13 +113,6 @@ MainWindow::~MainWindow() void MainWindow::updateConsole() { if (backendPipe != -1) { - char buf[256]; - size_t len = 0; - len = readBackend(backendPipe, buf, len); - if (len > 0) { - QLineEdit * con = ui->vConsole; - con->setText(con->text().append(buf)); - } } } @@ -402,3 +396,8 @@ void MainWindow::on_pbLoadWaypoints_clicked() f.close(); } } + +void MainWindow::on_socketPath_returnPressed() +{ + QProcessEnvironment::systemEnvironment().insert("UCART_SOCKET", ui->socketPath->text()); +} diff --git a/groundStation/gui/MicroCART/mainwindow.h b/groundStation/gui/MicroCART/mainwindow.h index de7b2a32d..62b044304 100644 --- a/groundStation/gui/MicroCART/mainwindow.h +++ b/groundStation/gui/MicroCART/mainwindow.h @@ -71,6 +71,8 @@ private slots: void on_pbLoadWaypoints_clicked(); + void on_socketPath_returnPressed(); + private: Ui::MainWindow *ui; pid_t backendPid; diff --git a/groundStation/gui/MicroCART/mainwindow.ui b/groundStation/gui/MicroCART/mainwindow.ui index 16c1d1a5e..eb56d7d32 100644 --- a/groundStation/gui/MicroCART/mainwindow.ui +++ b/groundStation/gui/MicroCART/mainwindow.ui @@ -18,7 +18,7 @@ <item> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> - <number>2</number> + <number>0</number> </property> <widget class="QWidget" name="backend"> <attribute name="title"> @@ -37,7 +37,10 @@ <item row="0" column="1"> <widget class="QLineEdit" name="socketPath"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> + </property> + <property name="text"> + <string/> </property> </widget> </item> diff --git a/groundStation/gui/MicroCART/quaditem.cpp b/groundStation/gui/MicroCART/quaditem.cpp index b43ced998..55e1413af 100644 --- a/groundStation/gui/MicroCART/quaditem.cpp +++ b/groundStation/gui/MicroCART/quaditem.cpp @@ -1,6 +1,7 @@ #include "quaditem.h" #include <QPixmap> #include <QLabel> +#include <QtMath> QuadItem::QuadItem() { @@ -20,13 +21,12 @@ void QuadItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void QuadItem::updateQuad(float longitudinal, float lateral, float height, float pitch, float roll, float yaw) { - this->setPos(longitudinal*10, lateral*10); - - QPointF center = boundingRect().center(); - QTransform trans = this->transform(); - trans.translate(center.x(), center.y()); - trans.rotate(yaw); - trans.translate(-center.x(), -center.y()); - this->setTransform(trans); + QPointF center = boundingRect().center(); + this->setTransform(QTransform().translate(center.x(), center.y()).rotate(qRadiansToDegrees(yaw)).translate(-center.x(), -center.y())); + this->setPos(longitudinal*100, lateral*100); +// QTransform trans = this->transform(); +// trans.translate(center.x(), center.y()); +// trans.translate(-center.x(), -center.y()); +// this->setTransform(trans); update(); } diff --git a/groundStation/gui/MicroCART/quaditem.h b/groundStation/gui/MicroCART/quaditem.h index 068880219..3f271806b 100644 --- a/groundStation/gui/MicroCART/quaditem.h +++ b/groundStation/gui/MicroCART/quaditem.h @@ -17,7 +17,7 @@ public: QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); -private slots: +public slots: void updateQuad(float longitudinal, float lateral, float height, float pitch, float roll, float yaw); }; diff --git a/groundStation/gui/MicroCART/trackerworker.cpp b/groundStation/gui/MicroCART/trackerworker.cpp index 9a6830a77..13d9c15bc 100644 --- a/groundStation/gui/MicroCART/trackerworker.cpp +++ b/groundStation/gui/MicroCART/trackerworker.cpp @@ -2,6 +2,7 @@ #include <QThread> #include "frontend_common.h" #include "frontend_tracker.h" +#include "quaditem.h" TrackerWorker::TrackerWorker() : QObject(), conn(NULL) diff --git a/groundStation/src/backend/backend.c b/groundStation/src/backend/backend.c index 3819ebc53..f384a6a1a 100644 --- a/groundStation/src/backend/backend.c +++ b/groundStation/src/backend/backend.c @@ -844,10 +844,13 @@ static void quad_recv() { memmove(respBuf, respBuf + packetlen, respBufLen - packetlen); respBufLen -= packetlen; + char * debug_string; switch (m.msg_type) { - case DEBUG_ID: + case DEBUG_ID: /* in case of debug. Quad send null terminated string in data */ - printf(" (Quad) : %s\n", data); + debug_string = strndup((char *)data, m.data_len); + printf(" (Quad) : %s\n", debug_string); + free(debug_string); break; case LOG_ID: if (!quadlog_file_open) { diff --git a/wifi_bridge/test_scripts/tcp_timer.py b/wifi_bridge/test_scripts/tcp_timer.py index 78664a980..6732f0501 100644 --- a/wifi_bridge/test_scripts/tcp_timer.py +++ b/wifi_bridge/test_scripts/tcp_timer.py @@ -11,12 +11,12 @@ TCP_PORT = 8080 message = bytes(range(36)) times_full = [] times_network = [] -times = [0.0]*100 +times = [0.0]*200 dropped = True response = bytes("initial", 'ASCII') addr = "initial" recvd_data = [] -for i in range(100): +for i in range(200): if dropped: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) @@ -51,11 +51,10 @@ for i in range(100): while time.perf_counter() - send_time < 0.01: pass -# with open("tcp_dist.csv", 'w', newline='') as f: -# writer = csv.writer(f) -# for time in times_network: -# time = time + 2.6 -# writer.writerow([time]) + with open("tcp_dist.csv", 'w', newline='') as f: + writer = csv.writer(f) + for t in times_network: + writer.writerow([t]) for time in [times_full, times_network]: print("lowest: " + str(min(time))) -- GitLab