Browse Source

change code.

yuchuli 2 years ago
parent
commit
bc7ee32055

+ 3 - 0
src/driver/driver_map_xodrload/driver_map_xodrload.pro

@@ -94,6 +94,9 @@ INCLUDEPATH += /home/nvidia/Downloads/proj-8.2.1/src
 LIBS += /home/nvidia/Downloads/proj-8.2.1/build/lib/libproj.so.22
 }
 
+
+#DEFINES += TESTSPEEDPLAN
+
 #LIBS += -lproj
 
 

+ 130 - 0
src/driver/driver_map_xodrload/main.cpp

@@ -644,6 +644,132 @@ void CalcSide(std::vector<PlanPoint> & xPlan)
     return;
 }
 
+#ifdef TESTSPEEDPLAN
+#include <math.h>
+#include <limits>
+
+double valuemin(double a,double b)
+{
+    if(a<b)return a;
+    return  b;
+}
+int getPlanSpeed(std::vector<iv::GPSData> MapTrace)
+{
+                int mode0to5count=0,mode0to18count=0,mode0to5countSum=0,mode0to18countSum=0,mode18count=0,mode18countSum=0,mode0to5flash=0,mode18flash=0;
+                double straightSpeed=40;
+                double straightCurveSpeed=30;
+                double Curve_SmallSpeed=15;
+                double Curve_LargeSpeed=8;
+
+                std::vector<std::vector<double>> doubledata;
+
+                doubledata.clear();
+                for (int i = 0; i < MapTrace.size(); i++) {   //                                       1225/14:25
+                             std::vector<double> temp;
+                             temp.clear();
+                             temp.push_back(0);temp.push_back(0);temp.push_back(0);temp.push_back(0);temp.push_back(0);//先push四个空量,然后就可以给量赋值了
+                             doubledata.push_back(temp);
+                             doubledata[i][0] = MapTrace.at(i)->gps_x;
+                             doubledata[i][1] = MapTrace.at(i)->gps_y;
+                             doubledata[i][2] = (MapTrace.at(i)->ins_heading_angle) / 180 * M_PI;
+                             doubledata[i][3]=0;
+                             doubledata[i][4]=0;
+                }
+
+                for(int i=0;i<doubledata.size();i++)
+                {
+                    if((MapTrace[i]->mfCurvature>-0.02)&&(MapTrace[i]->mfCurvature<0.02)){
+                        MapTrace[i]->roadMode=5;
+                    }else if(((MapTrace[i]->mfCurvature>=0.02)&&(MapTrace[i]->mfCurvature<=0.16))||((MapTrace[i]->mfCurvature>=-0.16)&&(MapTrace[i]->mfCurvature<=-0.02))){
+                        MapTrace[i]->roadMode=18;
+                    }else if(((MapTrace[i]->mfCurvature>0.16))||((MapTrace[i]->mfCurvature<-0.16))){
+                        MapTrace[i]->roadMode=14;
+                    }
+                }
+                for(int i=0;i<MapTrace.size();i++)
+                {
+                    if(MapTrace[i]->roadMode==0){
+                        doubledata[i][4]=straightSpeed;
+                        mode0to5count++;
+                        //mode0to18count++;
+                        mode18count=0;
+                        mode0to5flash=mode0to5count;
+                    }else if(MapTrace[i]->roadMode==5){
+                        doubledata[i][4]=straightCurveSpeed;
+                        mode0to5count++;
+                        //mode0to18count++;
+                        mode18count=0;
+                        mode0to5flash=mode0to5count;
+                    }else if(MapTrace[i]->roadMode==18){
+                        mode0to5countSum=mode0to5count;
+                        doubledata[i][4]=Curve_SmallSpeed;
+
+                        double brake_distance_double=(pow((straightCurveSpeed/3.6),2)-pow((Curve_SmallSpeed/3.6),2))*10/0.6;
+                        int brake_distance=(int)brake_distance_double;
+                        int step_count=0;
+                        if((i>brake_distance)&&(mode0to5countSum>brake_distance))
+                        {
+                            double step_speed=(straightCurveSpeed-Curve_SmallSpeed)/brake_distance;
+
+                            for(int j=i;j>i-brake_distance;j--){
+                                doubledata[j][4]=valuemin((Curve_SmallSpeed+step_count*step_speed),straightCurveSpeed);
+                                step_count++;
+                            }
+                        }else if(mode0to5countSum>0){
+                            for(int j=i;j>=i-mode0to5countSum;j--){
+                                doubledata[j][4]=Curve_SmallSpeed;
+                                step_count++;
+                            }
+                        }else{
+                            doubledata[i][4]=Curve_SmallSpeed;
+                        }
+                        mode0to5count=0;
+                        //mode0to18count++;
+                        mode18count++;
+                        mode18flash=mode18count;
+                    }else if(MapTrace[i]->roadMode==14){
+                        mode0to18countSum=mode0to5flash+mode18flash;
+                        mode18countSum=mode18count;
+                        double brake_distanceLarge_double=(pow((Curve_SmallSpeed/3.6),2)-pow((Curve_LargeSpeed/3.6),2))*10/0.6;
+                        double brake_distance0to18_double=(pow((straightCurveSpeed/3.6),2)-pow((Curve_LargeSpeed/3.6),2))*10/0.6;
+                        int brake_distanceLarge=(int)brake_distanceLarge_double;
+                        int brake_distance0to18=(int)brake_distance0to18_double;
+                        int step_count=0;
+                        doubledata[i][4]=Curve_LargeSpeed;
+
+                        if(mode18countSum>brake_distanceLarge)
+                        {
+                                double step_speed=(Curve_SmallSpeed-Curve_LargeSpeed)/brake_distanceLarge;
+
+                                for(int j=i;j>i-brake_distanceLarge;j--){
+                                    doubledata[j][4]=valuemin((Curve_LargeSpeed+step_count*step_speed),Curve_SmallSpeed);
+                                    step_count++;
+                                }
+
+                        }else if(mode0to18countSum>brake_distance0to18){
+
+                                double step_speed=(straightCurveSpeed-Curve_LargeSpeed)/brake_distance0to18;
+
+                                for(int j=i;j>i-brake_distance0to18;j--){
+                                    doubledata[j][4]=valuemin((Curve_LargeSpeed+step_count*step_speed),straightCurveSpeed);
+                                    step_count++;
+                                }
+                        }else{
+                                doubledata[i][4]=Curve_LargeSpeed;
+                        }
+
+                        mode0to5count=0;
+                        mode18count=0;
+                        mode0to5flash=0;
+                        mode18flash=0;
+                    }
+                }
+
+                return 0;
+
+}
+
+#endif
 
 void SetPlan(xodrobj xo)
 {
@@ -934,6 +1060,10 @@ void SetPlan(xodrobj xo)
     xfile_1.close();
     ShareMap(mapdata);
 
+#ifdef TESTSPEEDPLAN
+    getPlanSpeed(mapdata);
+#endif
+
     ShareMapGlobal(xPlan);
 
     int nnewmapsize = xtrace.ByteSize();

+ 73 - 0
src/map/odtolanelet/.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
+

+ 8 - 0
src/map/odtolanelet/main.cpp

@@ -0,0 +1,8 @@
+#include <QCoreApplication>
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+
+    return a.exec();
+}

+ 6 - 0
src/map/odtolanelet/odtolanelet.cpp

@@ -0,0 +1,6 @@
+#include "odtolanelet.h"
+
+odtolanelet::odtolanelet()
+{
+
+}

+ 11 - 0
src/map/odtolanelet/odtolanelet.h

@@ -0,0 +1,11 @@
+#ifndef ODTOLANELET_H
+#define ODTOLANELET_H
+
+
+class odtolanelet
+{
+public:
+    odtolanelet();
+};
+
+#endif // ODTOLANELET_H

+ 26 - 0
src/map/odtolanelet/odtolanelet.pro

@@ -0,0 +1,26 @@
+QT -= gui
+
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as 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 you use 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 \
+    odtolanelet.cpp
+
+
+!include(../../common/common/xodr/OpenDrive/OpenDrive.pri ) {
+    error( "Couldn't find the OpenDrive.pri file!" )
+}
+
+HEADERS += \
+    odtolanelet.h

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

@@ -4656,6 +4656,17 @@ void MainWindow::onClickRoadDel()
     }
     int nroadid = mpCBRoad->currentText().toInt();
 
+
+    QMessageBox::StandardButton button;
+    button=QMessageBox::question(this,tr("Delete Road"),QString(tr("Delete Road?")),QMessageBox::Yes|QMessageBox::No);
+    if(button==QMessageBox::No)
+    {
+        return;
+    }
+    else if(button==QMessageBox::Yes)
+    {
+    }
+
     Road * pRoad = 0;
     int nroadsize = mxodr.GetRoadCount();
     int i;