Forráskód Böngészése

add odtolanelet_win for use gui to convert opendrive to lanelet.

yuchuli 1 éve
szülő
commit
e1d619be73

+ 81 - 0
src/map/odtolanelet/mainwindow.cpp

@@ -0,0 +1,81 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QFileDialog>
+#include <QMessageBox>
+
+#include "odtolanelet.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    setWindowTitle(tr("Convert OpenDrive Map To LaneLet2 Map"));
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+
+void MainWindow::on_pushButton_Convert_clicked()
+{
+    QString strhome = getenv("HOME");
+    if(strhome.isEmpty())
+    {
+        strhome = ".";
+    }
+
+    QString str = QFileDialog::getOpenFileName(this,tr("Load XODR"),strhome,"*.xodr");
+    if(str.isEmpty())return;
+
+    QString strlanelet = QFileDialog::getSaveFileName(this,tr("Save LaneLet2"),strhome,"*.osm");
+    if(strlanelet.isEmpty())return;
+
+
+    if(strlanelet.length()>4)
+    {
+        if(strlanelet.right(4) == ".osm")
+        {
+//            qDebug("not need append.");
+        }
+        else
+        {
+            strlanelet.append(".osm");
+        }
+    }
+    else
+    {
+        strlanelet.append(".osm");
+    }
+
+
+//    qDebug("name: %s",strlanelet.toLatin1().data());
+
+
+    odtolanelet * potl = new odtolanelet(str.toStdString());
+
+    int nrtn = 0;
+
+    int64_t time1 = std::chrono::system_clock::now().time_since_epoch().count();
+    nrtn = potl->ConvertToLanelet(strlanelet.toStdString());
+    int64_t time2 = std::chrono::system_clock::now().time_since_epoch().count();
+
+    std::cout<<"use time: "<<(time2 - time1)<<std::endl;
+
+    if(nrtn == 0)
+    {
+        QMessageBox::information(this,tr("Success"),tr("Success Convert."),QMessageBox::YesAll);
+    }
+    else
+    {
+        QMessageBox::warning(this,tr("Warning"),tr("Fail Convert."),QMessageBox::YesAll);
+    }
+
+    delete potl;
+
+}
+

+ 24 - 0
src/map/odtolanelet/mainwindow.h

@@ -0,0 +1,24 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private slots:
+    void on_pushButton_Convert_clicked();
+
+private:
+    Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H

+ 45 - 0
src/map/odtolanelet/mainwindow.ui

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>492</width>
+    <height>278</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QPushButton" name="pushButton_Convert">
+    <property name="geometry">
+     <rect>
+      <x>130</x>
+      <y>90</y>
+      <width>181</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Convert</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>492</width>
+     <height>27</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 11 - 0
src/map/odtolanelet/odmain.cpp

@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}

+ 68 - 0
src/map/odtolanelet/odtolanelet_win.pro

@@ -0,0 +1,68 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++17
+
+# You can make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    odmain.cpp \
+    mainwindow.cpp \
+    odtolanelet.cpp \
+    roadsample.cpp \
+    gaussprojector.cpp \
+    ../../common/common/math/gnss_coordinate_convert.cpp
+
+!include(../../common/common/xodr/OpenDrive/OpenDrive.pri ) {
+    error( "Couldn't find the OpenDrive.pri file!" )
+}
+
+!include(../../common/common/xodr/TinyXML/TinyXML.pri ) {
+    error( "Couldn't find the TinyXML.pri file!" )
+}
+
+!include(../../common/common/xodr/odaux/odaux.pri ) {
+    error( "Couldn't find the odaux.pri file!" )
+}
+
+
+
+HEADERS += \
+    mainwindow.h \
+    odtolanelet.h \
+    roadsample.h \
+    gaussprojector.h \
+    ../../common/common/math/gnss_coordinate_convert.h
+
+FORMS += \
+    mainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+INCLUDEPATH += $$PWD/../../common/common/xodr
+INCLUDEPATH += $$PWD/../../common/common
+
+INCLUDEPATH += $$PWD/../../common/common/xodr/odaux
+
+INCLUDEPATH += $$PWD/../../map/lanelet2/include
+
+LIBS += -L$$PWD/../../map/lanelet2/bin -llanelet2_core -llanelet2_io
+
+
+if(contains(DEFINES,TESTROUTING)){
+LIBS +=  -llanelet2_routing -llanelet2_traffic_rules
+}
+
+LIBS += -lGeographic
+
+
+LIBS += -lboost_system -lboost_serialization  -lboost_filesystem -lpugixml
+
+unix:INCLUDEPATH += /usr/include/eigen3
+win32:INCLUDEPATH += D:\File\soft\eigen

+ 5 - 0
src/ros2/rospilot.workspace

@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<Workspace>
+    <Distribution path="/opt/ros/humble"/>
+    <DefaultBuildSystem value="2"/>
+</Workspace>

+ 7 - 0
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -6101,3 +6101,10 @@ void MainWindow::on_actionEdit_Road_Priority_triggered()
 
     mpfb->SetOpenDrive(mxodr);
 }
+
+void MainWindow::on_actionExport_Current_Road_triggered()
+{
+    int index = mpCBRoad->currentIndex();
+    qDebug("index: %d",index);
+}
+

+ 2 - 0
src/tool/map_lanetoxodr/mainwindow.h

@@ -251,6 +251,8 @@ private slots:
 
     void on_actionEdit_Road_Priority_triggered();
 
+    void on_actionExport_Current_Road_triggered();
+
 private:
 
 

+ 7 - 1
src/tool/map_lanetoxodr/mainwindow.ui

@@ -24,7 +24,7 @@
      <x>0</x>
      <y>0</y>
      <width>785</width>
-     <height>28</height>
+     <height>27</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
@@ -64,6 +64,7 @@
     <addaction name="actionAdd_Road_From_CDA"/>
     <addaction name="actionDraw_Road_From_CDA"/>
     <addaction name="actionAdd_Roads_From_Labels"/>
+    <addaction name="actionExport_Current_Road"/>
    </widget>
    <widget class="QMenu" name="menuView">
     <property name="title">
@@ -230,6 +231,11 @@
     <string>Edit Road Priority</string>
    </property>
   </action>
+  <action name="actionExport_Current_Road">
+   <property name="text">
+    <string>Export Current Road</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>