Browse Source

change testsideparkcalc. add lon lat input.

yuchuli 2 months ago
parent
commit
0e6f281499

+ 62 - 0
src/test/testsideparkcalc/mainwindow.cpp

@@ -1,6 +1,7 @@
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
 
+#include  "math/gnss_coordinate_convert.h"
 
 
 #define VIEW_WIDTH 1300
@@ -42,6 +43,13 @@ MainWindow::MainWindow(QWidget *parent)
     QGraphicsLineItem * pliney = new QGraphicsLineItem(RATIO * X_MOVE,0,RATIO * X_MOVE,VIEW_HEIGHT);
     mpscene->addItem(pliney);
 
+    ui->lineEdit_ParkLon->setText("116.0");
+    ui->lineEdit_ParkLat->setText("39.0");
+    ui->lineEdit_ParkHeading->setText("90.0");
+    ui->lineEdit_NowLon->setText("116.00006");
+    ui->lineEdit_NowLat->setText("39.00005");
+    ui->lineEdit_NowHeading->setText("360.0");
+
     setWindowTitle("Calc Park   (if HDG>0.5236  Vertical Park , Else Side Park)");
 }
 
@@ -602,3 +610,57 @@ void MainWindow::on_pushButton_Calc_clicked()
     }
 }
 
+
+void MainWindow::on_pushButton_CalcXY_clicked()
+{
+    double lon_base,lat_base,heading_base;
+    double lon_test,lat_test,heading_test;
+
+    double x_base,y_base,hdg_base;
+    double x_test,y_test,hdg_test;
+
+    double x_rel,y_rel,hdg_rel;
+    double x_rel_raw,y_rel_raw;
+
+    double fDis;
+
+    lon_base = ui->lineEdit_ParkLon->text().toDouble();
+    lat_base = ui->lineEdit_ParkLat->text().toDouble();
+    heading_base = ui->lineEdit_ParkHeading->text().toDouble();
+
+    lon_test = ui->lineEdit_NowLon->text().toDouble();
+    lat_test = ui->lineEdit_NowLat->text().toDouble();
+    heading_test = ui->lineEdit_NowHeading->text().toDouble();
+
+
+    GaussProjCal(lon_base,lat_base,&x_base,&y_base);
+    GaussProjCal(lon_test,lat_test,&x_test,&y_test);
+
+
+    x_rel_raw = x_test - x_base;
+    y_rel_raw = y_test - y_base;
+
+    hdg_base = (90-heading_base)*M_PI/180.0;
+    normalhdg(hdg_base);
+
+    hdg_test = (90-heading_test)*M_PI/180.0;
+    normalhdg(hdg_test);
+
+    hdg_rel = hdg_test - hdg_base;
+    normalhdg(hdg_rel);
+
+    x_rel = x_rel_raw * cos(-hdg_base) - y_rel_raw * sin(-hdg_base);
+    y_rel = x_rel_raw * sin(-hdg_base) + y_rel_raw * cos(-hdg_base);
+
+    ui->lineEdit_NowX->setText(QString::number(x_rel,'f',3));
+    ui->lineEdit_NowY->setText(QString::number(y_rel,'f',3));
+    ui->lineEdit_NowHdg->setText(QString::number(hdg_rel,'f',3));
+
+}
+
+void MainWindow::normalhdg(double & hdg)
+{
+    while(hdg >= (2.0*M_PI))hdg = hdg - M_PI * 2.0;
+    while(hdg < 0)hdg  = hdg  + M_PI * 2.0;
+}
+

+ 5 - 0
src/test/testsideparkcalc/mainwindow.h

@@ -25,6 +25,8 @@ public:
 private slots:
     void on_pushButton_Calc_clicked();
 
+    void on_pushButton_CalcXY_clicked();
+
 private:
     double mfRadius = 5.0;
     double mfMaxWheel = 430.0;
@@ -49,5 +51,8 @@ private:
     void SidePark(double x,double y ,double hdg, double fMinRadius,double fMaxWheel,double fStraightDis);
     void VerticalPark(double x,double y ,double hdg, double fMinRadius,double fMaxWheel,double fStraightDis);
 
+private:
+    void normalhdg(double & hdg);
+
 };
 #endif // MAINWINDOW_H

+ 190 - 16
src/test/testsideparkcalc/mainwindow.ui

@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1280</width>
+    <width>1920</width>
     <height>800</height>
    </rect>
   </property>
@@ -17,14 +17,14 @@
    <widget class="QPushButton" name="pushButton_Calc">
     <property name="geometry">
      <rect>
-      <x>1010</x>
+      <x>760</x>
       <y>30</y>
-      <width>171</width>
+      <width>101</width>
       <height>41</height>
      </rect>
     </property>
     <property name="text">
-     <string>Calc</string>
+     <string>Calc Park</string>
     </property>
    </widget>
    <widget class="QLineEdit" name="lineEdit_NowX">
@@ -53,7 +53,7 @@
    <widget class="QLineEdit" name="lineEdit_NowY">
     <property name="geometry">
      <rect>
-      <x>440</x>
+      <x>371</x>
       <y>17</y>
       <width>121</width>
       <height>31</height>
@@ -66,7 +66,7 @@
    <widget class="QLabel" name="label_2">
     <property name="geometry">
      <rect>
-      <x>350</x>
+      <x>281</x>
       <y>12</y>
       <width>91</width>
       <height>31</height>
@@ -79,7 +79,7 @@
    <widget class="QLabel" name="label_3">
     <property name="geometry">
      <rect>
-      <x>650</x>
+      <x>509</x>
       <y>10</y>
       <width>91</width>
       <height>31</height>
@@ -92,7 +92,7 @@
    <widget class="QLineEdit" name="lineEdit_NowHdg">
     <property name="geometry">
      <rect>
-      <x>740</x>
+      <x>613</x>
       <y>13</y>
       <width>121</width>
       <height>31</height>
@@ -125,7 +125,7 @@
    <widget class="QLineEdit" name="lineEdit_MaxWheel">
     <property name="geometry">
      <rect>
-      <x>440</x>
+      <x>371</x>
       <y>60</y>
       <width>121</width>
       <height>31</height>
@@ -135,7 +135,7 @@
    <widget class="QLineEdit" name="lineEdit_StraightDis">
     <property name="geometry">
      <rect>
-      <x>741</x>
+      <x>614</x>
       <y>60</y>
       <width>121</width>
       <height>31</height>
@@ -152,33 +152,190 @@
      </rect>
     </property>
     <property name="text">
-     <string>转弯半径:</string>
+     <string>Radius:</string>
     </property>
    </widget>
    <widget class="QLabel" name="label_5">
     <property name="geometry">
      <rect>
-      <x>350</x>
+      <x>281</x>
       <y>60</y>
       <width>91</width>
       <height>31</height>
      </rect>
     </property>
     <property name="text">
-     <string>转向角度:</string>
+     <string>Wheel:</string>
     </property>
    </widget>
    <widget class="QLabel" name="label_6">
     <property name="geometry">
      <rect>
-      <x>650</x>
+      <x>507</x>
       <y>60</y>
+      <width>101</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Last Straight:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_7">
+    <property name="geometry">
+     <rect>
+      <x>927</x>
+      <y>16</y>
+      <width>91</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Park Lon:</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_ParkHeading">
+    <property name="geometry">
+     <rect>
+      <x>1520</x>
+      <y>14</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string/>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_8">
+    <property name="geometry">
+     <rect>
+      <x>1178</x>
+      <y>61</y>
+      <width>91</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Now Lat:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_9">
+    <property name="geometry">
+     <rect>
+      <x>1396</x>
+      <y>61</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Now Heading:</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_NowLat">
+    <property name="geometry">
+     <rect>
+      <x>1262</x>
+      <y>61</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_10">
+    <property name="geometry">
+     <rect>
+      <x>1178</x>
+      <y>13</y>
+      <width>91</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Park Lat:</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_NowLon">
+    <property name="geometry">
+     <rect>
+      <x>1020</x>
+      <y>61</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_ParkLon">
+    <property name="geometry">
+     <rect>
+      <x>1020</x>
+      <y>13</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_11">
+    <property name="geometry">
+     <rect>
+      <x>927</x>
+      <y>61</y>
       <width>91</width>
       <height>31</height>
      </rect>
     </property>
     <property name="text">
-     <string>直线距离:</string>
+     <string>Now Lon:</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_12">
+    <property name="geometry">
+     <rect>
+      <x>1396</x>
+      <y>11</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Park Heading:</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_ParkLat">
+    <property name="geometry">
+     <rect>
+      <x>1261</x>
+      <y>18</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string/>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_NowHeading">
+    <property name="geometry">
+     <rect>
+      <x>1521</x>
+      <y>61</y>
+      <width>121</width>
+      <height>31</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_CalcXY">
+    <property name="geometry">
+     <rect>
+      <x>1670</x>
+      <y>35</y>
+      <width>121</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Calc XY</string>
     </property>
    </widget>
   </widget>
@@ -187,13 +344,30 @@
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>1280</width>
+     <width>1920</width>
      <height>27</height>
     </rect>
    </property>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
  </widget>
+ <tabstops>
+  <tabstop>lineEdit_NowX</tabstop>
+  <tabstop>lineEdit_NowY</tabstop>
+  <tabstop>lineEdit_NowHdg</tabstop>
+  <tabstop>lineEdit_MinRadius</tabstop>
+  <tabstop>lineEdit_MaxWheel</tabstop>
+  <tabstop>lineEdit_StraightDis</tabstop>
+  <tabstop>pushButton_Calc</tabstop>
+  <tabstop>lineEdit_ParkLon</tabstop>
+  <tabstop>lineEdit_ParkLat</tabstop>
+  <tabstop>lineEdit_ParkHeading</tabstop>
+  <tabstop>lineEdit_NowLon</tabstop>
+  <tabstop>lineEdit_NowLat</tabstop>
+  <tabstop>lineEdit_NowHeading</tabstop>
+  <tabstop>pushButton_CalcXY</tabstop>
+  <tabstop>plainTextEdit</tabstop>
+ </tabstops>
  <resources/>
  <connections/>
 </ui>

+ 4 - 0
src/test/testsideparkcalc/testsideparkcalc.pro

@@ -12,12 +12,14 @@ SOURCES += \
     main.cpp \
     mainwindow.cpp \
     myview.cpp \
+    ../../common/common/math/gnss_coordinate_convert.cpp \
     sideparkcalc.cpp \
     verticalparkcalc.cpp
 
 HEADERS += \
     mainwindow.h \
     myview.h \
+    ../../common/common/math/gnss_coordinate_convert.h \
     sideparkcalc.h \
     verticalparkcalc.h
 
@@ -28,3 +30,5 @@ FORMS += \
 qnx: target.path = /tmp/$${TARGET}/bin
 else: unix:!android: target.path = /opt/$${TARGET}/bin
 !isEmpty(target.path): INSTALLS += target
+
+INCLUDEPATH += $$PWD/../../common/common