Răsfoiți Sursa

add tool_xodrtovectormap. in this program, only write some test vectormap code ,test code created vectormap through test, is ok, no junction. vectormap work is half.not complete.

yuchuli 3 ani în urmă
părinte
comite
90aa5b2be1

+ 4 - 4
src/ros/catkin/src/lane_planner/nodes/lane_navi/lane_navi.cpp

@@ -228,12 +228,12 @@ void ThreadTest()
 
       tablet_socket_msgs::route_cmd xc;
  tablet_socket_msgs::Waypoint p1;
-  p1.lat = 35;
-  p1.lon = -9;
+  p1.lat =60;// -14;
+  p1.lon = 3;//35;
  xc.point.push_back(p1);
   tablet_socket_msgs::Waypoint p2;
-  p2.lat = -155;//-68;
-  p2.lon = -68;//-155;
+  p2.lat = 290;//-311;//-68;
+  p2.lon =  3;//-101;//37;//-155;
   xc.point.push_back(p2);
 
   create_waypoint(xc);

+ 1 - 1
src/ros/catkin/src/map_file/launch/vector_map_loader.launch

@@ -2,7 +2,7 @@
 <launch>
   <node pkg="map_file" type="vector_map_loader" name="vector_map_loader" output="screen">
     <param name="load_mode" value="directory" />
-    <param name="map_dir" value="$(env HOME)/map/vector_map" />
+    <param name="map_dir" value="$(env HOME)/map/testvector" />
     <param name="host_name" value="133.6.148.90" />
     <param name="port" value="80" />
     <param name="user" value="" />

+ 73 - 0
src/tool/tool_xodrtovectormap/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 11 - 0
src/tool/tool_xodrtovectormap/main.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();
+}

+ 18 - 0
src/tool/tool_xodrtovectormap/mainwindow.cpp

@@ -0,0 +1,18 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include "xodr2vectormap.h"
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+    xodr2vectormap xv;
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+

+ 21 - 0
src/tool/tool_xodrtovectormap/mainwindow.h

@@ -0,0 +1,21 @@
+#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:
+    Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H

+ 22 - 0
src/tool/tool_xodrtovectormap/mainwindow.ui

@@ -0,0 +1,22 @@
+<?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>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget"/>
+  <widget class="QMenuBar" name="menubar"/>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 33 - 0
src/tool/tool_xodrtovectormap/tool_xodrtovectormap.pro

@@ -0,0 +1,33 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    main.cpp \
+    mainwindow.cpp \
+    xodr2vectormap.cpp
+
+HEADERS += \
+    mainwindow.h \
+    xodr2vectormap.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

+ 167 - 0
src/tool/tool_xodrtovectormap/xodr2vectormap.cpp

@@ -0,0 +1,167 @@
+#include "xodr2vectormap.h"
+
+
+#include <QFile>
+
+xodr2vectormap::xodr2vectormap()
+{
+    testvector();
+
+}
+
+void xodr2vectormap::testvector()
+{
+    QString strfolder = "/home/yuchuli/map/testvector";
+
+    QFile xFilePoints;
+    xFilePoints.setFileName(strfolder + "/point.csv");
+    if(!xFilePoints.open(QIODevice::ReadWrite))
+    {
+        qDebug("point file open fail.");
+        return;
+    }
+
+    char strline[1000];
+    snprintf(strline,1000,"PID,B,L,H,Bx,Ly,ReF,MCODE1,MCODE2,MCODE3\n");
+    xFilePoints.write(strline);
+    int i;
+    for(i=0;i<31;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%f,%f,%f,%d,%d,%d,%d\n",
+                 i+1,0,0,0.0,i*10.0,3.0,7,0,0,0);
+        xFilePoints.write(strline);
+    }
+    for(i=31;i<62;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%f,%f,%f,%d,%d,%d,%d\n",
+                 i+1,0,0,0.0,(i-31)*10.0,0.0,7,0,0,0);
+        xFilePoints.write(strline);
+    }
+    for(i=62;i<93;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%f,%f,%f,%d,%d,%d,%d\n",
+                 i+1,0,0,0.0,(i-62)*10.0,-3.0,7,0,0,0);
+        xFilePoints.write(strline);
+    }
+    xFilePoints.close();
+
+    QFile xFileLine;
+    xFileLine.setFileName(strfolder + "/line.csv");
+    if(!xFileLine.open(QIODevice::ReadWrite))
+    {
+        qDebug("line file open fail.");
+        return;
+    }
+
+    snprintf(strline,1000,"LID,BPID,FPID,BLID,FLID\n");
+    xFileLine.write(strline);
+    for(i=0;i<28;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%d,%d\n",
+                 i+1,i+32,i+33,i,i+2);
+        xFileLine.write(strline);
+    }
+    snprintf(strline,1000,"%d,%d,%d,%d,%d\n",
+             i+1,i+32,i+33,i,0);
+    xFileLine.write(strline);
+    xFileLine.close();
+
+    QFile xFileWhiteLine;
+    xFileWhiteLine.setFileName(strfolder + "/whiteline.csv");
+    if(!xFileWhiteLine.open(QIODevice::ReadWrite))
+    {
+        qDebug("whiteline file open fail.");
+        return;
+    }
+
+    snprintf(strline,1000,"ID,LID,Width,Color,type,LinkID\n");
+    xFileWhiteLine.write(strline);
+    for(i=0;i<29;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%f,Y,%d,%d\n",
+                 i+1,i+1,0.15,0,0);
+        xFileWhiteLine.write(strline);
+    }
+    xFileWhiteLine.close();
+
+    QFile xFileNode;
+    xFileNode.setFileName(strfolder + "/node.csv");
+    if(!xFileNode.open(QIODevice::ReadWrite))
+    {
+        qDebug(" node file open fail.");
+        return;
+    }
+    snprintf(strline,1000,"NID,PID\n");
+    xFileNode.write(strline);
+    for(i=0;i<31;i++)
+    {
+        snprintf(strline,1000,"%d,%d\n",i,i+1);
+        xFileNode.write(strline);
+    }
+    for(i=31;i<62;i++)
+    {
+        snprintf(strline,1000,"%d,%d\n",i,93-(i-31));
+        xFileNode.write(strline);
+    }
+    xFileNode.close();
+
+    QFile xFileLane;
+    xFileLane.setFileName(strfolder + "/lane.csv");
+    if(!xFileLane.open(QIODevice::ReadWrite))
+    {
+        qDebug(" node file open fail.");
+        return;
+    }
+    snprintf(strline,1000,"LnID,DID,BLID,FLID,BNID,FNID,JCT,BLID2,BLID3,BLID4,FLID2,FLID3,FLID4,ClossID,Span,LCnt,Lno,LaneType,LimitVel,RefVel,RoadSecID,LaneChgFG\n");
+    xFileLane.write(strline);
+
+    for(i=0;i<29;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+                 i+1,i+1,i,i+2,i,i+1,
+                 0,0,0,0,
+                 0,0,0,0,
+                 1,4,1,0,
+                 20,20,0,0);
+        xFileLane.write(strline);
+    }
+    snprintf(strline,1000,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+             i+1,i+1,i,0,i,i+1,
+             0,0,0,0,
+             0,0,0,0,
+             1,4,1,0,
+             20,20,0,0);
+    xFileLane.write(strline);
+    i++;
+
+
+    snprintf(strline,1000,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+             i+1,i+1,0,i+2,i+1,i+2,
+             0,0,0,0,
+             0,0,0,0,
+             1,4,1,0,
+             20,20,0,0);
+    xFileLane.write(strline);
+    i++;
+
+    for(i=31;i<59;i++)
+    {
+        snprintf(strline,1000,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+                 i+1,i+1,i,i+2,i+1,i+2,
+                 0,0,0,0,
+                 0,0,0,0,
+                 1,4,1,0,
+                 20,20,0,0);
+        xFileLane.write(strline);
+    }
+    snprintf(strline,1000,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+             i+1,i+1,i,0,i+1,i+2,
+             0,0,0,0,
+             0,0,0,0,
+             1,4,1,0,
+             20,20,0,0);
+    xFileLane.write(strline);
+    xFileLane.close();
+
+
+}

+ 14 - 0
src/tool/tool_xodrtovectormap/xodr2vectormap.h

@@ -0,0 +1,14 @@
+#ifndef XODR2VECTORMAP_H
+#define XODR2VECTORMAP_H
+
+
+class xodr2vectormap
+{
+public:
+    xodr2vectormap();
+
+private:
+    void testvector();
+};
+
+#endif // XODR2VECTORMAP_H