Переглянути джерело

fix a bug in map_lanetoxodr. center lane dot lane show fail.

yuchuli 3 роки тому
батько
коміт
8e914e7892

+ 73 - 12
src/controller/apollo_conf_make/mainwindow.cpp

@@ -1,11 +1,17 @@
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
 
+#include <QFileDialog>
+#include <QMessageBox>
+#include <iostream>
+
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
     , ui(new Ui::MainWindow)
 {
     ui->setupUi(this);
+
+    setWindowTitle("Apollo Conf Make");
 }
 
 MainWindow::~MainWindow()
@@ -16,28 +22,83 @@ MainWindow::~MainWindow()
 
 void MainWindow::on_pushButton_Save_clicked()
 {
-    apollo::control::ControlConf xConf1;
-    xConf1.set_steer_angle_rate(100.0);
-
-    google::protobuf::Message * px = (google::protobuf::Message *)&xConf1;
-
     apollo::control::ControlConf xConf;
-    xConf.CopyFrom(*px);
+    QString strtxt = ui->plainTextEdit->toPlainText();
+
+    std::string strconf = strtxt.toStdString();
 
     using google::protobuf::TextFormat;
     using google::protobuf::io::FileOutputStream;
     using google::protobuf::io::ZeroCopyOutputStream;
+    using google::protobuf::io::ZeroCopyInputStream;
+
+    std::istringstream xstrstream(strconf);
+    ZeroCopyInputStream *input = new google::protobuf::io::IstreamInputStream(&xstrstream);
+    bool success = TextFormat::Parse(input, &xConf);
+    if(success)
+    {
+        mConf.CopyFrom(xConf);
+        UpdateConf();
+        qDebug("Parse OK.");
+        QString str = QFileDialog::getSaveFileName(this,"Save Conf",".","*.txt");
+        if(str.isEmpty())return;
+        if(str.right(4) != ".txt")
+        {
+            str.append(".txt");
+        }
+
+        bool bRes = apollo::cyber::common::SetProtoToASCIIFile(mConf,str.toStdString());
 
-//    google::protobuf::io::StringOutputStream
+        if(bRes == false)
+        {
+            QMessageBox::warning(this,"Warning","Save Conf File Fail.",QMessageBox::YesAll);
+            return;
+        }
+
+    }
+    else
+    {
+        QMessageBox::warning(this,"Warning","Parse Conf Error.",QMessageBox::YesAll);
+    }
+//    if (!success) {
+//      AERROR << "Failed to parse file " << file_name << " as text proto.";
+//    }
+
+//    std::string strout;
+ //   ZeroCopyOutputStream *output = new google::protobuf::io::StringOutputStream(&strout);//new FileOutputStream(file_descriptor);
+//    bool success = TextFormat::Print(xConf, output);
+
+
+}
 
+void MainWindow::on_pushButton_LoadTemplate_clicked()
+{
+    QString str = QFileDialog::getOpenFileName(this,"Load Conf",".","*.txt");
+    if(str.isEmpty())return;
+
+    bool bRes = apollo::cyber::common::GetProtoFromASCIIFile(str.toStdString(),&mConf);
+
+    if(bRes == false)
+    {
+        QMessageBox::warning(this,"Warning","Load Template File Fail.",QMessageBox::YesAll);
+        return;
+    }
+
+    UpdateConf();
+
+
+}
+
+void MainWindow::UpdateConf()
+{
+    using google::protobuf::TextFormat;
+    using google::protobuf::io::FileOutputStream;
+    using google::protobuf::io::ZeroCopyOutputStream;
     std::string strout;
     ZeroCopyOutputStream *output = new google::protobuf::io::StringOutputStream(&strout);//new FileOutputStream(file_descriptor);
-    bool success = TextFormat::Print(xConf, output);
-
+    bool success = TextFormat::Print(mConf, output);
     if(success)
     {
-        qDebug("str:\n %s",strout.data());
+        ui->plainTextEdit->setPlainText(strout.data());
     }
-
-    apollo::cyber::common::SetProtoToASCIIFile(xConf,"/home/yuchuli/xconf.txt");
 }

+ 7 - 0
src/controller/apollo_conf_make/mainwindow.h

@@ -21,7 +21,14 @@ public:
 private slots:
     void on_pushButton_Save_clicked();
 
+    void on_pushButton_LoadTemplate_clicked();
+
 private:
     Ui::MainWindow *ui;
+
+    apollo::control::ControlConf mConf;
+
+private:
+    void UpdateConf();
 };
 #endif // MAINWINDOW_H

+ 112 - 7
src/controller/apollo_conf_make/mainwindow.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>800</width>
-    <height>600</height>
+    <width>1280</width>
+    <height>800</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -17,23 +17,128 @@
    <widget class="QPushButton" name="pushButton_Save">
     <property name="geometry">
      <rect>
-      <x>300</x>
-      <y>460</y>
-      <width>89</width>
-      <height>25</height>
+      <x>440</x>
+      <y>30</y>
+      <width>181</width>
+      <height>31</height>
      </rect>
     </property>
     <property name="text">
      <string>Save</string>
     </property>
    </widget>
+   <widget class="QPushButton" name="pushButton_LoadTemplate">
+    <property name="geometry">
+     <rect>
+      <x>80</x>
+      <y>30</y>
+      <width>151</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Load Template</string>
+    </property>
+   </widget>
+   <widget class="QPlainTextEdit" name="plainTextEdit">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>90</y>
+      <width>631</width>
+      <height>641</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPlainTextEdit" name="plainTextEdit_calib">
+    <property name="geometry">
+     <rect>
+      <x>710</x>
+      <y>150</y>
+      <width>531</width>
+      <height>581</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_LoadCalib">
+    <property name="geometry">
+     <rect>
+      <x>730</x>
+      <y>30</y>
+      <width>171</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Load Calib</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_CalibToConf">
+    <property name="geometry">
+     <rect>
+      <x>1050</x>
+      <y>30</y>
+      <width>171</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>CalibToConf</string>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_TorqueRatio">
+    <property name="geometry">
+     <rect>
+      <x>852</x>
+      <y>90</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_BrakeRatio">
+    <property name="geometry">
+     <rect>
+      <x>1130</x>
+      <y>91</y>
+      <width>91</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label">
+    <property name="geometry">
+     <rect>
+      <x>730</x>
+      <y>97</y>
+      <width>91</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Torque Ratio</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="label_2">
+    <property name="geometry">
+     <rect>
+      <x>1010</x>
+      <y>94</y>
+      <width>91</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Brake Ratio</string>
+    </property>
+   </widget>
   </widget>
   <widget class="QMenuBar" name="menubar">
    <property name="geometry">
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>800</width>
+     <width>1280</width>
      <height>28</height>
     </rect>
    </property>

+ 11 - 1
src/tool/map_lanetoxodr/xodrscenfunc.cpp

@@ -265,8 +265,18 @@ std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadMarkItem(RoadDigit *prd)
             {
                 if(nmarktype<2)
                 {
+                    if(xvepre[k].mnlane == 0)
+                    {
+                        int ooo = 0;
+                        ooo++;
+                    }
                     if((nmarktype == 0)||(IsDrawMark(xvepre[k].mS)))
                     {
+                        if(xvepre[k].mnlane == 0)
+                        {
+                            int ooo = 0;
+                            ooo++;
+                        }
                         fx1 = xvepre[k].mfX + 0.5*flmw * cos(xvepre[k].mfhdg - M_PI/2.0);
                         fy1 = (xvepre[k].mfY+0.5*flmw * sin(xvepre[k].mfhdg - M_PI/2.0))*(-1.0);
                         fx2 = xvenxt[k].mfX+ 0.5*flmw * cos(xvenxt[k].mfhdg - M_PI/2.0);
@@ -393,7 +403,7 @@ bool xodrscenfunc::IsDrawMark(double s)
     const double dotlen = 5.0;
 
     double  y = fmod(s,dotdis);
-    if(y>dotlen)return true;
+    if(y>=dotlen)return true;
     else
     {
         return false;