Quellcode durchsuchen

change tool/map_lanetoxodr. add Dialongobject_outline_cornerRoad, but not complete.

yuchuli vor 3 Jahren
Ursprung
Commit
ae4896b2fd

+ 124 - 0
src/controller/apollo_conf_make/mainwindow.cpp

@@ -4,6 +4,7 @@
 #include <QFileDialog>
 #include <QMessageBox>
 #include <iostream>
+#include <math.h>
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
@@ -11,6 +12,9 @@ MainWindow::MainWindow(QWidget *parent)
 {
     ui->setupUi(this);
 
+    ui->lineEdit_TorqueRatio->setText("1.0");
+    ui->lineEdit_BrakeRatio->setText("1.0");
+
     setWindowTitle("Apollo Conf Make");
 }
 
@@ -102,3 +106,123 @@ void MainWindow::UpdateConf()
         ui->plainTextEdit->setPlainText(strout.data());
     }
 }
+
+void MainWindow::on_pushButton_LoadCalib_clicked()
+{
+    QString str = QFileDialog::getOpenFileName(this,"Load velacctable",".","*.txt");
+    if(str.isEmpty())return;
+
+    std::vector<std::tuple<double, double, double>> xvectortable_torque,xvectortable_brake;
+    QFile xFile;
+    xFile.setFileName(str);
+    if(xFile.open(QIODevice::ReadOnly))
+    {
+        QByteArray ba = xFile.readAll();
+        QString strba;
+        strba.append(ba);
+        QStringList strlinelist =strba.split("\n");// strba.split(QRegExp("[\t ;]+"));
+        int nline = strlinelist.size();
+        int i;
+        for(i=0;i<nline;i++)
+        {
+            QString str = strlinelist.at(i);
+            str = str.trimmed();
+            QStringList strvaluelist = str.split(QRegExp("[\t ;]+"));
+            if(strvaluelist.size()>=4)
+            {
+                double vel,acc,torque,brake;
+                vel = QString(strvaluelist.at(0)).toDouble();
+                acc = QString(strvaluelist.at(1)).toDouble();
+                torque = QString(strvaluelist.at(2)).toDouble();
+                brake = QString(strvaluelist.at(3)).toDouble();
+                xvectortable_torque.push_back(std::make_tuple(vel,acc,torque));
+                xvectortable_brake.push_back(std::make_tuple(vel,acc,brake));
+            }
+        }
+        xFile.close();
+        mvectortable_torque = xvectortable_torque;
+        mvectortable_brake = xvectortable_brake;
+        UpdateVelAcc();
+
+    }
+    else
+    {
+        QMessageBox::warning(this,"Warning","Open File Fail.",QMessageBox::YesAll);
+    }
+
+
+}
+
+void MainWindow::UpdateVelAcc()
+{
+    if(mvectortable_brake.size() == 0)
+    {
+        ui->plainTextEdit_calib->setPlainText("");
+        return;
+    }
+    QString strinfo;
+    unsigned int i;
+    unsigned int ntablesize = mvectortable_torque.size();
+    for(i=0;i<ntablesize;i++)
+    {
+        QString strline;
+        strline = QString::number(std::get<0>(mvectortable_torque[i]),'f',3) + "   "
+                +QString::number(std::get<1>(mvectortable_torque[i]),'f',3) + "   "
+                +QString::number(std::get<2>(mvectortable_torque[i]),'f',3) + "   "
+                +QString::number(std::get<2>(mvectortable_brake[i]),'f',3) + "   "
+                +"\n";
+        strinfo = strinfo+strline;
+    }
+    ui->plainTextEdit_calib->setPlainText(strinfo);
+}
+
+void MainWindow::on_pushButton_CalibToConf_clicked()
+{
+    double ftorqueratio = ui->lineEdit_TorqueRatio->text().toDouble();
+    double fbrakeratio = ui->lineEdit_BrakeRatio->text().toDouble();
+
+    if(mConf.has_mpc_controller_conf() == false)
+    {
+        QMessageBox::warning(this,"Warning","No MPCControllerConf.",QMessageBox::YesAll);
+        return;
+    }
+    apollo::control::LonControllerConf * pLonConf = mConf.mutable_lon_controller_conf();
+
+    apollo::control::MPCControllerConf * pMPCConf = mConf.mutable_mpc_controller_conf();
+    if(pMPCConf == NULL)
+    {
+        QMessageBox::warning(this,"Warning","Get MPCControllerConf Fail.",QMessageBox::YesAll);
+        return;
+    }
+
+    ::apollo::control::calibrationtable::ControlCalibrationTable* pnewtable = new apollo::control::calibrationtable::ControlCalibrationTable();
+
+    unsigned int i;
+    unsigned int ntablesize = mvectortable_torque.size();
+    for(i=0;i<ntablesize;i++)
+    {
+        double fspeed = std::get<0>(mvectortable_torque[i])/3.6;
+        double facc = std::get<1>(mvectortable_torque[i]);
+        double fcmd1 = ftorqueratio * std::get<2>(mvectortable_torque[i]);
+        double fcmd2 = fbrakeratio * std::get<2>(mvectortable_brake[i]);
+        double fcmd = fcmd1;
+        if(fabs(fcmd2)>0.00000001)fcmd = fabs(fcmd2)*(-1.0);
+        apollo::control::calibrationtable::ControlCalibrationInfo* pcalib = pnewtable->add_calibration();
+        pcalib->set_speed(fspeed);
+        pcalib->set_acceleration(facc);
+        pcalib->set_command(fcmd);
+    }
+
+    pMPCConf->set_allocated_calibration_table(pnewtable);
+
+    if(mConf.has_lon_controller_conf())
+    {
+        ::apollo::control::calibrationtable::ControlCalibrationTable* pnewtable2 = new apollo::control::calibrationtable::ControlCalibrationTable();
+        pnewtable2->CopyFrom(*pnewtable);
+        pLonConf->set_allocated_calibration_table(pnewtable2);
+    }
+
+    UpdateConf();
+
+    QMessageBox::information(this,"Info","Update Calibration Table SuccessFull.",QMessageBox::YesAll);
+}

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

@@ -3,6 +3,9 @@
 
 #include <QMainWindow>
 
+#include <tuple>
+#include <vector>
+
 #include "cyber/common/file.h"
 #include "modules/control/proto/control_conf.pb.h"
 
@@ -10,6 +13,17 @@ QT_BEGIN_NAMESPACE
 namespace Ui { class MainWindow; }
 QT_END_NAMESPACE
 
+namespace iv {
+struct tableunit
+{
+public:
+    double mfVel;
+    double mfAcc;
+    double mfTorque;
+    double mfBrake;
+};
+}
+
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
@@ -23,12 +37,19 @@ private slots:
 
     void on_pushButton_LoadTemplate_clicked();
 
+    void on_pushButton_LoadCalib_clicked();
+
+    void on_pushButton_CalibToConf_clicked();
+
 private:
     Ui::MainWindow *ui;
 
     apollo::control::ControlConf mConf;
 
+    std::vector<std::tuple<double, double, double>> mvectortable_torque,mvectortable_brake;
+
 private:
     void UpdateConf();
+    void UpdateVelAcc();
 };
 #endif // MAINWINDOW_H

+ 30 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline.cpp

@@ -1,6 +1,8 @@
 #include "dialogroadobject_outline.h"
 #include "ui_dialogroadobject_outline.h"
 
+#include "dialogroadobject_outline_cornerroad.h"
+
 static std::string gstr_e_outlineFillType[] ={"grass","concrete","cobble","asphalt",
                                              "pavement","gravel","soil"};
 
@@ -360,10 +362,38 @@ void DialogRoadObject_outline::onClickChange()
 
 void DialogRoadObject_outline::onClickcornerRoad()
 {
+    Object * pObject = mpObject;
+
+    if(mpObject == 0)return;
 
+    if(pObject->GetObjectoutlineCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No Outline",QMessageBox::YesAll);
+        return;
+    }
+
+    Object_outlines_outline * poutline = pObject->GetObjectoutline(mpCBOutline->currentIndex());
+
+    if(poutline == NULL)return;
+    DialogRoadObject_Outline_cornerRoad dlgcorner(poutline,0);
+    dlgcorner.exec();
 }
 
 void DialogRoadObject_outline::onClickcornerLocal()
 {
+    Object * pObject = mpObject;
+
+    if(mpObject == 0)return;
+
+    if(pObject->GetObjectoutlineCount() == 0)
+    {
+        QMessageBox::warning(this,"Warning","No Outline",QMessageBox::YesAll);
+        return;
+    }
 
+    Object_outlines_outline * poutline = pObject->GetObjectoutline(mpCBOutline->currentIndex());
+
+    if(poutline == NULL)return;
+    DialogRoadObject_Outline_cornerRoad dlgcorner(poutline,1);
+    dlgcorner.exec();
 }

+ 166 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline_cornerroad.cpp

@@ -0,0 +1,166 @@
+#include "dialogroadobject_outline_cornerroad.h"
+#include "ui_dialogroadobject_outline_cornerroad.h"
+
+DialogRoadObject_Outline_cornerRoad::DialogRoadObject_Outline_cornerRoad(Object_outlines_outline * poutline,int ntype,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadObject_Outline_cornerRoad)
+{
+    ui->setupUi(this);
+
+    mpoutline = poutline;
+
+    mntype = ntype;
+    if(ntype == 1)
+    {
+        ui->label_s->setText("u");
+        ui->label_t->setText("v");
+        ui->label_dz->setText("z");
+        ui->label_corner->setText("cornerLocal");
+    }
+
+    UpdateCB();
+
+    if(ntype == 0)
+        setWindowTitle("Edit Road Object Outline cornerRoad");
+    else
+        setWindowTitle("Edit Road Object Outline cornerLocal");
+}
+
+DialogRoadObject_Outline_cornerRoad::~DialogRoadObject_Outline_cornerRoad()
+{
+    delete ui;
+}
+
+void DialogRoadObject_Outline_cornerRoad::on_pushButton_Add_clicked()
+{
+    if(mpoutline == NULL)return;
+
+    if(mntype == 0)
+    {
+        if(ViewCreate::CheckLE(ui->lineEdit_s,"s",true,this) == false)return;
+        if(ViewCreate::CheckLE(ui->lineEdit_t,"t",true,this) == false)return;
+        if(ViewCreate::CheckLE(ui->lineEdit_dz,"dz",true,this) == false)return;
+    }
+    else
+    {
+        if(ViewCreate::CheckLE(ui->lineEdit_s,"u",true,this) == false)return;
+        if(ViewCreate::CheckLE(ui->lineEdit_t,"v",true,this) == false)return;
+        if(ViewCreate::CheckLE(ui->lineEdit_dz,"z",true,this) == false)return;
+    }
+    if(ViewCreate::CheckLE(ui->lineEdit_height,"height",true,this) == false)return;
+
+    if(mntype == 0)
+    {
+        mpoutline->AddcornerRoad(ui->lineEdit_s->text().toDouble(),
+                                 ui->lineEdit_t->text().toDouble(),
+                                 ui->lineEdit_dz->text().toDouble(),
+                                 ui->lineEdit_height->text().toDouble());
+        Object_outlines_outline_cornerRoad * pcornerRoad = mpoutline->GetLastAddedcornerRoad();
+        if(ViewCreate::CheckLE(ui->lineEdit_id,"id",false,this) == true)
+        {
+            pcornerRoad->Setid(ui->lineEdit_id->text().toInt());
+        }
+    }
+    else
+    {
+        mpoutline->AddcornerLocal(ui->lineEdit_s->text().toDouble(),
+                                 ui->lineEdit_t->text().toDouble(),
+                                 ui->lineEdit_dz->text().toDouble(),
+                                 ui->lineEdit_height->text().toDouble());
+        Object_outlines_outline_cornerLocal * pcornerLocal = mpoutline->GetLastAddedcornerLocal();
+        if(ViewCreate::CheckLE(ui->lineEdit_id,"id",false,this) == true)
+        {
+            pcornerLocal->Setid(ui->lineEdit_id->text().toInt());
+        }
+    }
+
+    UpdateCB();
+
+
+}
+
+void DialogRoadObject_Outline_cornerRoad::on_pushButton_Delete_clicked()
+{
+     if(mpoutline == NULL)return;
+}
+
+void DialogRoadObject_Outline_cornerRoad::on_pushButton_Change_clicked()
+{
+     if(mpoutline == NULL)return;
+}
+
+void DialogRoadObject_Outline_cornerRoad::UpdateCB()
+{
+    ui->comboBox_corner->clear();
+    if(mpoutline == NULL)return;
+    if(mntype == 0)
+    {
+        unsigned ncornerRoadCount = mpoutline->GetcornerRoadCount();
+        unsigned i;
+        for(i=0;i<ncornerRoadCount;i++)
+        {
+            ui->comboBox_corner->addItem("cornerRoad "+ QString::number(i));
+        }
+    }
+    else
+    {
+        unsigned ncornerLocalCount = mpoutline->GetcornerLocalCount();
+        unsigned i;
+        for(i=0;i<ncornerLocalCount;i++)
+        {
+            ui->comboBox_corner->addItem("cornerLocal "+ QString::number(i));
+        }
+    }
+}
+
+void DialogRoadObject_Outline_cornerRoad::on_comboBox_corner_currentIndexChanged(int index)
+{
+    if(index <0)return;
+
+    if(mpoutline == NULL)return;
+
+    if(mntype == 0)
+    {
+        Object_outlines_outline_cornerRoad * pcornerRoad = mpoutline->GetcornerRoad(index);
+        if(pcornerRoad == NULL)
+        {
+            qDebug(" DialogRoadObject_Outline_cornerRoad::on_comboBox_corner_currentIndexChanged get cornerRoad Fail,index:%d",index);
+            return;
+        }
+        ui->lineEdit_s->setText(QString::number(pcornerRoad->Gets()));
+        ui->lineEdit_t->setText(QString::number(pcornerRoad->Gett()));
+        ui->lineEdit_dz->setText(QString::number(pcornerRoad->Getdz()));
+        ui->lineEdit_height->setText(QString::number(pcornerRoad->Getheight()));
+        int id;
+        if(pcornerRoad->Getid(id) == 1)
+        {
+            ui->lineEdit_id->setText(QString::number(id));
+        }
+        else
+        {
+            ui->lineEdit_id->setText("");
+        }
+    }
+    else
+    {
+        Object_outlines_outline_cornerLocal * pcornerLocal = mpoutline->GetcornerLocal(index);
+        if(pcornerLocal == NULL)
+        {
+            qDebug(" DialogRoadObject_Outline_cornerRoad::on_comboBox_corner_currentIndexChanged get cornerRoad Fail,index:%d",index);
+            return;
+        }
+        ui->lineEdit_s->setText(QString::number(pcornerLocal->Getu()));
+        ui->lineEdit_t->setText(QString::number(pcornerLocal->Getv()));
+        ui->lineEdit_dz->setText(QString::number(pcornerLocal->Getz()));
+        ui->lineEdit_height->setText(QString::number(pcornerLocal->Getheight()));
+        int id;
+        if(pcornerLocal->Getid(id) == 1)
+        {
+            ui->lineEdit_id->setText(QString::number(id));
+        }
+        else
+        {
+            ui->lineEdit_id->setText("");
+        }
+    }
+}

+ 40 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline_cornerroad.h

@@ -0,0 +1,40 @@
+#ifndef DIALOGROADOBJECT_OUTLINE_CORNERROAD_H
+#define DIALOGROADOBJECT_OUTLINE_CORNERROAD_H
+
+#include <QDialog>
+
+#include "viewcreate.h"
+
+#include <OpenDrive/OpenDrive.h>
+
+namespace Ui {
+class DialogRoadObject_Outline_cornerRoad;
+}
+
+class DialogRoadObject_Outline_cornerRoad : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadObject_Outline_cornerRoad(Object_outlines_outline * poutline,int ntype, QWidget *parent = nullptr);
+    ~DialogRoadObject_Outline_cornerRoad();
+
+private slots:
+    void on_pushButton_Add_clicked();
+
+    void on_pushButton_Delete_clicked();
+
+    void on_pushButton_Change_clicked();
+
+    void on_comboBox_corner_currentIndexChanged(int index);
+
+private:
+    Ui::DialogRoadObject_Outline_cornerRoad *ui;
+
+    Object_outlines_outline * mpoutline = NULL;
+    int mntype = 0;
+
+    void UpdateCB();
+};
+
+#endif // DIALOGROADOBJECT_OUTLINE_CORNERROAD_H

+ 196 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline_cornerroad.ui

@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadObject_Outline_cornerRoad</class>
+ <widget class="QDialog" name="DialogRoadObject_Outline_cornerRoad">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>607</width>
+    <height>359</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLabel" name="label_corner">
+   <property name="geometry">
+    <rect>
+     <x>50</x>
+     <y>22</y>
+     <width>121</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>cornerRoad</string>
+   </property>
+  </widget>
+  <widget class="QComboBox" name="comboBox_corner">
+   <property name="geometry">
+    <rect>
+     <x>195</x>
+     <y>22</y>
+     <width>201</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_s">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>86</y>
+     <width>71</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>s</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_s">
+   <property name="geometry">
+    <rect>
+     <x>130</x>
+     <y>86</y>
+     <width>141</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_t">
+   <property name="geometry">
+    <rect>
+     <x>340</x>
+     <y>86</y>
+     <width>71</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>t</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_t">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>86</y>
+     <width>141</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_dz">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>149</y>
+     <width>71</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>dz</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_dz">
+   <property name="geometry">
+    <rect>
+     <x>130</x>
+     <y>149</y>
+     <width>141</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_5">
+   <property name="geometry">
+    <rect>
+     <x>340</x>
+     <y>149</y>
+     <width>71</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>height</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_height">
+   <property name="geometry">
+    <rect>
+     <x>430</x>
+     <y>149</y>
+     <width>141</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_6">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>216</y>
+     <width>71</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>id</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_id">
+   <property name="geometry">
+    <rect>
+     <x>130</x>
+     <y>216</y>
+     <width>141</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Add">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>280</y>
+     <width>121</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Delete">
+   <property name="geometry">
+    <rect>
+     <x>245</x>
+     <y>283</y>
+     <width>121</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Change">
+   <property name="geometry">
+    <rect>
+     <x>458</x>
+     <y>285</y>
+     <width>121</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Change</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 3 - 0
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -46,6 +46,7 @@ SOURCES += \
     dialogroadobject.cpp \
     dialogroadobject_material.cpp \
     dialogroadobject_outline.cpp \
+    dialogroadobject_outline_cornerroad.cpp \
     dialogroadobject_outlines.cpp \
     dialogroadobject_parkingspace.cpp \
     dialogroadobject_repeat.cpp \
@@ -103,6 +104,7 @@ HEADERS += \
     dialogroadobject.h \
     dialogroadobject_material.h \
     dialogroadobject_outline.h \
+    dialogroadobject_outline_cornerroad.h \
     dialogroadobject_outlines.h \
     dialogroadobject_parkingspace.h \
     dialogroadobject_repeat.h \
@@ -154,6 +156,7 @@ FORMS += \
         dialogroadobject.ui \
         dialogroadobject_material.ui \
         dialogroadobject_outline.ui \
+        dialogroadobject_outline_cornerroad.ui \
         dialogroadobject_outlines.ui \
         dialogroadobject_parkingspace.ui \
         dialogroadobject_repeat.ui \