فهرست منبع

car control tool,add key control

lijinliang 3 سال پیش
والد
کامیت
955c471aab
3فایلهای تغییر یافته به همراه40 افزوده شده و 3 حذف شده
  1. 31 0
      src/tool/carControlTester/mainwindow.cpp
  2. 2 0
      src/tool/carControlTester/mainwindow.h
  3. 7 3
      src/tool/carControlTester/mainwindow.ui

+ 31 - 0
src/tool/carControlTester/mainwindow.cpp

@@ -250,3 +250,34 @@ void MainWindow::onTimer()
     steerDeg = car_control_module.get_current_steer_ang_in_deg();
     ui->lineEEPS->setText(QString::number(steerDeg));
 }
+
+void MainWindow::keyPressEvent(QKeyEvent* event){
+    qDebug()<<"keypress!";
+    //(event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier)) &&
+    if((event->key() == Qt::Key_W))
+    {
+        qDebug()<<"acc up";
+        speedSetVal+=0.1;
+        ui->sBoxSpeedSet->setValue(speedSetVal);
+    }
+    else if((event->key() == Qt::Key_S))
+    {
+        qDebug()<<"acc Down";
+        speedSetVal-=0.1;
+        ui->sBoxSpeedSet->setValue(speedSetVal);
+    }
+    //(event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier)) &&
+    else if( (event->key() == Qt::Key_A))
+    {
+        qDebug()<<"turn left"<<EpsSetVal;
+        ui->sBoxEpsSet->setValue(EpsSetVal);
+        EpsSetVal+=5;
+    }
+    else if((event->key() == Qt::Key_D))
+    {
+        qDebug()<<"turn right"<<EpsSetVal;
+        ui->sBoxEpsSet->setValue(EpsSetVal);
+        EpsSetVal-=5;
+    }
+};
+

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

@@ -5,6 +5,7 @@
 #include <QTimer>
 #include <QDebug>
 #include "include/car_control.h"
+#include <QKeyEvent>
 
 namespace Ui {
 class MainWindow;
@@ -53,6 +54,7 @@ private:
     TurnLightIndicReq turnLightSetVal = TurnLightIndicReq::kOff;
     double speedSetVal = 0;
     double EpsSetVal = 0;
+    void keyPressEvent(QKeyEvent* event);
 };
 
 #endif // MAINWINDOW_H

+ 7 - 3
src/tool/carControlTester/mainwindow.ui

@@ -128,10 +128,10 @@
            <number>1</number>
           </property>
           <property name="minimum">
-           <double>-45.000000000000000</double>
+           <double>-400.000000000000000</double>
           </property>
           <property name="maximum">
-           <double>45.000000000000000</double>
+           <double>400.000000000000000</double>
           </property>
           <property name="singleStep">
            <double>5.000000000000000</double>
@@ -340,7 +340,11 @@
      </widget>
     </item>
     <item row="1" column="0" colspan="2">
-     <widget class="QTextBrowser" name="textBrLog"/>
+     <widget class="QTextBrowser" name="textBrLog">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
+     </widget>
     </item>
    </layout>
   </widget>