Browse Source

change simple_planning_simulator. add vehicle track mode.

yuchuli 1 year ago
parent
commit
c6aafdfdcb

BIN
doc/工具/场景仿真工具使用手册.doc


File diff suppressed because it is too large
+ 581 - 825
src/driver/driver_grpc_client/ivgrpc.pb.cc


File diff suppressed because it is too large
+ 1044 - 491
src/driver/driver_grpc_client/ivgrpc.pb.h


+ 1 - 0
src/tool/map_lanetoxodr/view/myview.cpp

@@ -144,6 +144,7 @@ void MyView::mouseDoubleClickEvent(QMouseEvent *event)
     double centerx = (psH->value() + psH->size().width()/2)/beishu;
 
 
+
 //    qDebug("x is %d y is %d view center x is %d  centerx is %d",event->pos().x(),
 //           event->pos().y(),
 //           viewport()->rect().center().x(),centerx);

+ 22 - 0
src/tool/simple_planning_simulator/mainwindow.cpp

@@ -35,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent)
     image = new QImage(VIEW_WIDTH, VIEW_HEIGHT, QImage::Format_RGB32);//画布的初始化大小设为300*300,使用32位颜色
     myview->setCacheMode(myview->CacheBackground);
 
+
     painter = new QPainter(image);
 
     painter->end();
@@ -45,6 +46,8 @@ MainWindow::MainWindow(QWidget *parent)
     mpscene = new  QGraphicsScene(0,0,VIEW_WIDTH,VIEW_HEIGHT);
     mpscene->setBackgroundBrush(Qt::darkGreen);
 
+
+
     mnFontHeight =  ui->centralwidget->fontMetrics().height();
 
     QTabWidget * p = new QTabWidget(ui->centralwidget);
@@ -55,6 +58,9 @@ MainWindow::MainWindow(QWidget *parent)
     mpLabel_Status = new QLabel(this);
     ui->statusbar->addPermanentWidget(mpLabel_Status);
 
+    ui->actionTrack->setChecked(false);
+    mbTrack = false;
+
     mTabMain = p;
 
     CreateCar();
@@ -717,6 +723,7 @@ void MainWindow::DelObjFromVector(unsigned int index)
 
 void MainWindow::onClickDelObj()
 {
+
     if(mvectorsimobj.size() == 0)return;
     unsigned int index = mpCBObj->currentIndex();
     DelObjFromVector(index);
@@ -821,6 +828,8 @@ void MainWindow::onTimerUpdateCarPos()
 
 
     mppixcar->setPos(mfViewMoveX +VIEW_WIDTH/2.0 + x - x1 ,-mfViewMoveY+VIEW_HEIGHT/2.0 - y + y1);
+
+    if(mbTrack)myview->centerOn(mfViewMoveX +VIEW_WIDTH/2.0 + x - x1 ,-mfViewMoveY+VIEW_HEIGHT/2.0 - y + y1);
 }
 
 void MainWindow::UpdateDecition(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
@@ -925,3 +934,16 @@ void MainWindow::on_actionLoadObject_triggered()
     }
 }
 
+
+void MainWindow::on_actionTrack_triggered()
+{
+    if(ui->actionTrack->isChecked())
+    {
+        mbTrack = true;
+    }
+    else
+    {
+        mbTrack = false;
+    }
+}
+

+ 4 - 0
src/tool/simple_planning_simulator/mainwindow.h

@@ -62,6 +62,8 @@ private slots:
 
     void on_actionLoadObject_triggered();
 
+    void on_actionTrack_triggered();
+
 private:
     Ui::MainWindow *ui;
 
@@ -110,6 +112,8 @@ private:
 
     bool mbSimulate = false;
 
+    bool mbTrack = false;
+
 
 private:
     int mnFontHeight;

+ 15 - 0
src/tool/simple_planning_simulator/mainwindow.ui

@@ -41,7 +41,14 @@
     </property>
     <addaction name="actionMeasuring_Distance"/>
    </widget>
+   <widget class="QMenu" name="menuView">
+    <property name="title">
+     <string>View</string>
+    </property>
+    <addaction name="actionTrack"/>
+   </widget>
    <addaction name="menuFile"/>
+   <addaction name="menuView"/>
    <addaction name="menuTool"/>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
@@ -65,6 +72,14 @@
     <string>LoadObject</string>
    </property>
   </action>
+  <action name="actionTrack">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Track</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="sim.qrc"/>

+ 4 - 2
src/tool/simple_planning_simulator/simmodel_shenlan.cpp

@@ -55,7 +55,7 @@ void simmodel_shenlan::CalcModel()
         {
         mx = mx - mvel*fdifftime * cos(mhdg);
         my = my - mvel*fdifftime * sin(mhdg);
-        mhdg = mhdg - mvel * tan(mwheelsteer)/mfwheelbase;
+        mhdg = mhdg - mvel * fdifftime * tan(mwheelsteer)/mfwheelbase;
         }
 
         if(mshift == SHIFT_GEER::PARK)
@@ -73,7 +73,7 @@ void simmodel_shenlan::CalcModel()
         if(mfcmd_brake<0)
         {
         facc = mfcmd_brake;
-        if((mvel<=0) &&(mshift == SHIFT_GEER::DRIVE))
+        if((mvel<=0)) // &&(mshift == SHIFT_GEER::DRIVE))
         {
             mvel = 0;
             facc = 0;
@@ -102,6 +102,8 @@ void simmodel_shenlan::CalcModel()
         }
         mvel = mvel + facc * fdifftime;
 
+//        std::cout<<" acc: "<<macc<<std::endl;
+
         double fwheelsteer = mwheelsteer;
 
         fwheelsteer = mfwheelratio * fwheelsteer *180.0/M_PI;

Some files were not shown because too many files changed in this diff