Przeglądaj źródła

add tool_takeover.

yuchuli 1 rok temu
rodzic
commit
536036ad75

+ 1 - 1
deploylib.sh

@@ -1,6 +1,6 @@
 #! /bin/bash
 
-Qtgccdir=''
+Qtgccdir='/usr/lib/x86_64-linux-gnu/qt5'
 if [ ${#Qtgccdir} -lt 6 ]; then
   echo "Because not set gcc_64 , so auto find gcc_64 "
   optfiles=`find /opt -name 'gcc_64'` 

+ 1 - 1
deploywithfind.sh

@@ -1,6 +1,6 @@
 #! /bin/bash
 
-Qtgccdir=''
+Qtgccdir='/usr/lib/x86_64-linux-gnu/qt5'
 if [ ${#Qtgccdir} -lt 6 ]; then
   echo "Because not set gcc_64 , so auto find gcc_64 "
   optfiles=`find /opt -name 'gcc_64'` 

+ 1 - 1
src/driver/driver_cloud_grpc_server_h264/main.cpp

@@ -205,7 +205,7 @@ class UploadServiceImpl final : public iv::UploadThread::Service {
 };
 
 void RunServer() {
-  std::string server_address("0.0.0.0:50051");
+  std::string server_address("0.0.0.0:51051");
   UploadServiceImpl service;
 
   grpc::EnableDefaultHealthCheckService(true);

+ 2 - 0
src/driver/driver_group_grpc_server/groupdb.cpp

@@ -4,6 +4,8 @@
 
 #include <QDir>
 
+#include <thread>
+
 groupdb::groupdb(std::string strdbpath)
 {
     mstrdbpath = strdbpath;

+ 15 - 0
src/include/proto/takeover.proto

@@ -0,0 +1,15 @@
+syntax = "proto2";
+
+package iv.brain;
+
+message takeover
+{
+    required bool bTakeWheel = 1;                
+    optional double fwheelAngle = 2;           
+    required bool bTakeAcc = 3;          
+    optional double fAcc = 4;        
+    required bool bTakeBrake = 5;               
+    optional double minDecelerate = 6;         
+    required bool bTakeSpeed = 7;               
+    optional double  fSpeed = 8;             
+};

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

+ 132 - 0
src/tool/tool_takeover/mainwindow.cpp

@@ -0,0 +1,132 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <iostream>
+#include "takeover.pb.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    ui->checkBox_minDec->setChecked(false);
+    ui->checkBox_speed->setChecked(false);
+    ui->horizontalSlider_Speed->setVisible(false);
+    ui->lineEdit_Speed->setVisible(false);
+    ui->horizontalSlider_minDec->setVisible(false);
+    ui->lineEdit_minDec->setVisible(false);
+
+    setWindowTitle("Take Over");
+
+    mpa = iv::modulecomm::RegisterSend("takeover",1000,1);
+
+    mpTimer = new QTimer;
+    mpTimer->setInterval(100);
+    connect(mpTimer,SIGNAL(timeout()),this,SLOT(onTimer()));
+    mpTimer->start();
+
+}
+
+MainWindow::~MainWindow()
+{
+    delete mpTimer;
+
+    iv::modulecomm::Unregister(mpa);
+
+    delete ui;
+}
+
+void MainWindow::on_checkBox_speed_clicked()
+{
+    if(ui->checkBox_speed->isChecked())
+    {
+        ui->horizontalSlider_Speed->setVisible(true);
+        ui->horizontalSlider_Speed->setValue(15);
+        ui->lineEdit_Speed->setVisible(true);
+    }
+    else
+    {
+        ui->horizontalSlider_Speed->setVisible(false);
+        ui->lineEdit_Speed->setVisible(false);
+    }
+}
+
+void MainWindow::on_horizontalSlider_Speed_valueChanged(int value)
+{
+    ui->lineEdit_Speed->setText(QString::number(value));
+}
+
+void MainWindow::on_checkBox_minDec_clicked()
+{
+    if(ui->checkBox_minDec->isChecked())
+    {
+        ui->horizontalSlider_minDec->setVisible(true);
+        ui->lineEdit_minDec->setVisible(true);
+        ui->horizontalSlider_minDec->setValue(15);
+    }
+    else
+    {
+        ui->horizontalSlider_minDec->setVisible(false);
+        ui->lineEdit_minDec->setVisible(false);
+    }
+}
+
+void MainWindow::on_horizontalSlider_minDec_valueChanged(int value)
+{
+    double fvalue = value * 0.1 - 1.0;
+    ui->lineEdit_minDec->setText(QString::number(fvalue,'f',1));
+}
+
+void MainWindow::on_pushButton_5kmh_clicked()
+{
+    ui->horizontalSlider_Speed->setValue(5);
+}
+
+void MainWindow::on_pushButton_15kmh_clicked()
+{
+    ui->horizontalSlider_Speed->setValue(15);
+}
+
+void MainWindow::on_pushButton_m1ms2_clicked()
+{
+    ui->horizontalSlider_minDec->setValue(0);
+}
+
+void MainWindow::on_pushButton_d5ms2_clicked()
+{
+   ui->horizontalSlider_minDec->setValue(15);
+}
+
+void MainWindow::onTimer()
+{
+    iv::brain::takeover xtakeover;
+    xtakeover.set_btakeacc(false);
+    xtakeover.set_btakebrake(false);
+    xtakeover.set_btakespeed(false);
+    xtakeover.set_btakewheel(false);
+
+    if(ui->checkBox_minDec->isChecked())
+    {
+        double minDec = ui->lineEdit_minDec->text().toDouble();
+        xtakeover.set_mindecelerate(minDec);
+    }
+
+    if(ui->checkBox_speed->isChecked())
+    {
+        double fspeed = ui->lineEdit_Speed->text().toDouble();
+        xtakeover.set_fspeed(fspeed);
+    }
+
+    int nsize = xtakeover.ByteSize();
+    std::shared_ptr<char> pstr_ptr = std::shared_ptr<char>(new char[nsize]);
+    if(xtakeover.SerializeToArray(pstr_ptr.get(),nsize))
+    {
+        iv::modulecomm::ModuleSendMsg(mpa, pstr_ptr.get(),nsize);
+    }
+    else
+    {
+        std::cout<<" Serialize take over Fail."<<std::endl;
+    }
+
+}

+ 48 - 0
src/tool/tool_takeover/mainwindow.h

@@ -0,0 +1,48 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QTimer>
+
+#include "modulecomm.h"
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QWidget *parent = 0);
+    ~MainWindow();
+
+private slots:
+    void on_checkBox_speed_clicked();
+
+    void on_horizontalSlider_Speed_valueChanged(int value);
+
+    void on_checkBox_minDec_clicked();
+
+    void on_horizontalSlider_minDec_valueChanged(int value);
+
+    void on_pushButton_5kmh_clicked();
+
+    void on_pushButton_15kmh_clicked();
+
+    void on_pushButton_m1ms2_clicked();
+
+    void on_pushButton_d5ms2_clicked();
+
+    void onTimer();
+
+private:
+    Ui::MainWindow *ui;
+
+    void * mpa;
+    QTimer * mpTimer;
+
+};
+
+#endif // MAINWINDOW_H

+ 171 - 0
src/tool/tool_takeover/mainwindow.ui

@@ -0,0 +1,171 @@
+<?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>723</width>
+    <height>466</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QCheckBox" name="checkBox_speed">
+    <property name="geometry">
+     <rect>
+      <x>27</x>
+      <y>50</y>
+      <width>121</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>车速控制</string>
+    </property>
+   </widget>
+   <widget class="QSlider" name="horizontalSlider_Speed">
+    <property name="geometry">
+     <rect>
+      <x>230</x>
+      <y>60</y>
+      <width>321</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="maximum">
+     <number>15</number>
+    </property>
+    <property name="orientation">
+     <enum>Qt::Horizontal</enum>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="checkBox_minDec">
+    <property name="geometry">
+     <rect>
+      <x>25</x>
+      <y>140</y>
+      <width>121</width>
+      <height>51</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>减速度控制</string>
+    </property>
+   </widget>
+   <widget class="QSlider" name="horizontalSlider_minDec">
+    <property name="geometry">
+     <rect>
+      <x>230</x>
+      <y>160</y>
+      <width>321</width>
+      <height>31</height>
+     </rect>
+    </property>
+    <property name="maximum">
+     <number>15</number>
+    </property>
+    <property name="orientation">
+     <enum>Qt::Horizontal</enum>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_Speed">
+    <property name="geometry">
+     <rect>
+      <x>600</x>
+      <y>50</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QLineEdit" name="lineEdit_minDec">
+    <property name="geometry">
+     <rect>
+      <x>600</x>
+      <y>151</y>
+      <width>101</width>
+      <height>41</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_5kmh">
+    <property name="geometry">
+     <rect>
+      <x>20</x>
+      <y>260</y>
+      <width>111</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>5km/h</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_15kmh">
+    <property name="geometry">
+     <rect>
+      <x>190</x>
+      <y>260</y>
+      <width>111</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>15km/h</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_m1ms2">
+    <property name="geometry">
+     <rect>
+      <x>354</x>
+      <y>260</y>
+      <width>111</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>-1.0m/s2</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton_d5ms2">
+    <property name="geometry">
+     <rect>
+      <x>516</x>
+      <y>260</y>
+      <width>111</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>0.5m/s2</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>723</width>
+     <height>28</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

+ 45 - 0
src/tool/tool_takeover/tool_takeover.pro

@@ -0,0 +1,45 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2023-04-24T11:23:34
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = tool_takeover
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as 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 \
+        mainwindow.cpp \
+    ../../include/msgtype/takeover.pb.cc
+
+HEADERS += \
+        mainwindow.h \
+    ../../include/msgtype/takeover.pb.h
+
+FORMS += \
+        mainwindow.ui
+
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}

+ 1 - 1
src/ui/ui_ads_hmi/ui_ads_hmi.pro

@@ -4,7 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui network webenginewidgets
+QT       += core gui network #webenginewidgets
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets