|
@@ -0,0 +1,841 @@
|
|
|
+#include "mainwindow.h"
|
|
|
+#include "ui_mainwindow.h"
|
|
|
+#include "pos_def.h"
|
|
|
+
|
|
|
+MainWindow * gw;
|
|
|
+//#include "QStringLiteral"
|
|
|
+
|
|
|
+#ifdef NVIDIA_AGX
|
|
|
+#include "opencv2/imgcodecs/legacy/constants_c.h" //OpenCV4 use this line
|
|
|
+#include <opencv2/imgproc/types_c.h> //OpenCV4 use this line
|
|
|
+#endif
|
|
|
+
|
|
|
+#include <opencv2/opencv.hpp>
|
|
|
+#include <opencv2/core.hpp>
|
|
|
+
|
|
|
+iv::gps::gpsimu ggpsimu;
|
|
|
+qint64 gTimeGPSIMUUpdate = 0;
|
|
|
+
|
|
|
+iv::vision::rawpic grawpic[CAMERA_NUM];
|
|
|
+qint64 gTimeRawPic[CAMERA_NUM] = {0,0,0,0};
|
|
|
+QMutex gMutexPic[CAMERA_NUM];
|
|
|
+
|
|
|
+extern std::string gstrmem_gpsimu;
|
|
|
+extern std::string gstrmem_pic[CAMERA_NUM];
|
|
|
+extern std::vector<iv::pos_def> gvectorpos;
|
|
|
+extern std::string gstryaml_path;
|
|
|
+
|
|
|
+class xodrobj
|
|
|
+{
|
|
|
+public:
|
|
|
+ double flatsrc;
|
|
|
+ double flonsrc;
|
|
|
+ double fhgdsrc;
|
|
|
+ double flat;
|
|
|
+ double flon;
|
|
|
+ int lane;
|
|
|
+};
|
|
|
+
|
|
|
+namespace iv {
|
|
|
+struct simpletrace
|
|
|
+{
|
|
|
+ double gps_lat = 0;//纬度
|
|
|
+ double gps_lng = 0;//经度
|
|
|
+
|
|
|
+ double gps_x = 0;
|
|
|
+ double gps_y = 0;
|
|
|
+ double gps_z = 0;
|
|
|
+
|
|
|
+
|
|
|
+ double ins_heading_angle = 0; //航向角
|
|
|
+};
|
|
|
+}
|
|
|
+
|
|
|
+std::vector<iv::simpletrace> gvectorsimplerace;
|
|
|
+QMutex gMutexTrace;
|
|
|
+qint64 gTimeTrace = 0;
|
|
|
+
|
|
|
+void Listenpic(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ if(nSize<1000)return;
|
|
|
+ iv::vision::rawpic pic;
|
|
|
+ if(false == pic.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ std::cout<<"picview Listenpic fail."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int indexpic = -1;
|
|
|
+ for(int i =0;i<CAMERA_NUM;i++)
|
|
|
+ {
|
|
|
+ if(strncmp(strmemname,gstrmem_pic[i].data(),256) == 0)
|
|
|
+ {
|
|
|
+ indexpic = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(indexpic >= 0)
|
|
|
+ {
|
|
|
+ gMutexPic[indexpic].lock();
|
|
|
+ grawpic[indexpic].CopyFrom(pic);
|
|
|
+ gTimeRawPic[indexpic] = QDateTime::currentMSecsSinceEpoch();
|
|
|
+ gMutexPic[indexpic].unlock();
|
|
|
+ gw->saveavi(indexpic);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void Listensimpletrace(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ int npoint = nSize/sizeof(iv::simpletrace);
|
|
|
+ if(npoint < 1)
|
|
|
+ {
|
|
|
+ std::cout<<"simple trace is very smalll"<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ gMutexTrace.lock();
|
|
|
+ gvectorsimplerace.clear();
|
|
|
+ gvectorsimplerace.resize(npoint);
|
|
|
+ memcpy(gvectorsimplerace.data(),strdata,npoint*sizeof(iv::simpletrace));
|
|
|
+ gTimeTrace = QDateTime::currentMSecsSinceEpoch();
|
|
|
+ gMutexTrace.unlock();
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void Listengpsimu(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+// ggpsimu->UpdateGPSIMU(strdata,nSize);
|
|
|
+
|
|
|
+ iv::gps::gpsimu xgpsimu;
|
|
|
+ if(!xgpsimu.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ std::cout<<"ListenRaw Parse error."<<std::endl;
|
|
|
+ }
|
|
|
+ ggpsimu.CopyFrom(xgpsimu);
|
|
|
+ gTimeGPSIMUUpdate = QDateTime::currentMSecsSinceEpoch();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+MainWindow::MainWindow(QWidget *parent)
|
|
|
+ : QMainWindow(parent)
|
|
|
+ , ui(new Ui::MainWindow)
|
|
|
+{
|
|
|
+ gw = this;
|
|
|
+ ui->setupUi(this);
|
|
|
+
|
|
|
+// int * pax = 0;
|
|
|
+// *pax = 1;
|
|
|
+
|
|
|
+ mpJRT = new JoyReadThread();
|
|
|
+ mpJRT->start();
|
|
|
+
|
|
|
+ void * pa = iv::modulecomm::RegisterRecv(gstrmem_gpsimu.data(),Listengpsimu);
|
|
|
+ int i;
|
|
|
+ for(i=0;i<CAMERA_NUM;i++)
|
|
|
+ pa = iv::modulecomm::RegisterRecv(gstrmem_pic[i].data(),Listenpic);
|
|
|
+
|
|
|
+
|
|
|
+ CreateView();
|
|
|
+
|
|
|
+ mpPicView = new IVPicView();
|
|
|
+ mpPicView->start();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int nstation = gvectorpos.size();
|
|
|
+ for(i=0;i<nstation;i++)
|
|
|
+ {
|
|
|
+ ui->comboBox_Station->addItem(gvectorpos[i].mstrstationname.data());
|
|
|
+ }
|
|
|
+
|
|
|
+ ui->radioButton_auto->setChecked(true);
|
|
|
+
|
|
|
+ mpa = iv::modulecomm::RegisterSend("remotectrl",10000,1);
|
|
|
+
|
|
|
+ mpTimerManual = new QTimer(this);
|
|
|
+ connect(mpTimerManual,SIGNAL(timeout()),this,SLOT(onTimerManual()));
|
|
|
+
|
|
|
+ mpTimerRemote = new QTimer(this);
|
|
|
+ connect(mpTimerRemote,SIGNAL(timeout()),this,SLOT(onTimerRemote()));
|
|
|
+ mpTimerRemote->start(10);
|
|
|
+
|
|
|
+ mpTimerUpdateView = new QTimer(this);
|
|
|
+ connect(mpTimerUpdateView,SIGNAL(timeout()),this,SLOT(onTimerUpdateView()));
|
|
|
+ mpTimerUpdateView->start(1000);
|
|
|
+
|
|
|
+ QTimer * timer = new QTimer(this);
|
|
|
+ connect(timer,SIGNAL(timeout()),this,SLOT(onTimerUpdatePic()));
|
|
|
+ timer->start(10);
|
|
|
+
|
|
|
+ mpadst = iv::modulecomm::RegisterSend("xodrreq",1000,1);
|
|
|
+ mpasimpletrace = iv::modulecomm::RegisterRecv("simpletrace",Listensimpletrace);
|
|
|
+
|
|
|
+ mgrpcpc = new grpcpc(gstryaml_path);
|
|
|
+ mgrpcpc->start();
|
|
|
+
|
|
|
+ mstrVIN = mgrpcpc->GetVIN().data();
|
|
|
+ mstrVIN = " VIN:"+ mstrVIN+" ";
|
|
|
+
|
|
|
+ mpPicSave[0] = new ivpicsave("./","front",mstrVIN.toStdString());
|
|
|
+ mpPicSave[1] = new ivpicsave("./","rear",mstrVIN.toStdString());
|
|
|
+ mpPicSave[2] = new ivpicsave("./","left",mstrVIN.toStdString());
|
|
|
+ mpPicSave[3] = new ivpicsave("./","right",mstrVIN.toStdString());
|
|
|
+
|
|
|
+ for(i=0;i<4;i++)
|
|
|
+ {
|
|
|
+ mpPicSave[i]->start();
|
|
|
+ }
|
|
|
+
|
|
|
+ mppicdlg = new DialogPic(this);
|
|
|
+ mppicdlg->setModal(false);
|
|
|
+ connect(mppicdlg,SIGNAL(finished(int)),this,SLOT(onCloseDlg()));
|
|
|
+
|
|
|
+ mpbigpicdlg = new DialogBigPic(this);
|
|
|
+ mpbigpicdlg->setModal(false);
|
|
|
+ connect(mpbigpicdlg,SIGNAL(finished(int)),this,SLOT(onCloseBigDlg()));
|
|
|
+
|
|
|
+ setWindowTitle(mstrProgName +mstrVIN+ mstrGPSTime + mstrPicTime);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+MainWindow::~MainWindow()
|
|
|
+{
|
|
|
+
|
|
|
+ delete ui;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::CreateView()
|
|
|
+{
|
|
|
+ mMapview = new QWebEngineView(ui->centralwidget);
|
|
|
+// qDebug((QDir::currentPath()).toLatin1().data());
|
|
|
+ mMapview->load(QUrl(QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("BaiDuMap.html")));
|
|
|
+
|
|
|
+ mMapview->setGeometry(10,10,800,800);
|
|
|
+
|
|
|
+// mMapview->page()->runJavaScript("theLocation(117.355,39.066);"); //117.355,39.066
|
|
|
+
|
|
|
+ mpWheel = new Speed(ui->groupBox_rem);
|
|
|
+ mpWheel->settitle(QStringLiteral("方向盘"));
|
|
|
+
|
|
|
+ mpAcc = new Speed(ui->groupBox_rem);
|
|
|
+
|
|
|
+ mpAcc->settitle(QStringLiteral("油门"));
|
|
|
+ mpAcc->updatevalue(0);
|
|
|
+ mpAcc->setminvalue(0);
|
|
|
+ mpAcc->setmaxvalue(100);
|
|
|
+
|
|
|
+ mpBrake = new Speed(ui->groupBox_rem);
|
|
|
+ mpBrake->settitle(QStringLiteral("刹车"));
|
|
|
+ mpBrake->updatevalue(0);
|
|
|
+ mpBrake->setminvalue(0);
|
|
|
+ mpBrake->setmaxvalue(100);
|
|
|
+
|
|
|
+ mmyview = new MyView(ui->centralwidget);
|
|
|
+ mmyview->setObjectName(QStringLiteral("graphicsView"));
|
|
|
+ mmyview->setGeometry(QRect(30, 30, 600, 600));
|
|
|
+
|
|
|
+ mmyview->setCacheMode(mmyview->CacheBackground);
|
|
|
+
|
|
|
+ mscene = new QGraphicsScene;
|
|
|
+
|
|
|
+ ui->radioButton_Null->setChecked(true);
|
|
|
+
|
|
|
+ ui->radioButton_picfront->setChecked(true);
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void MainWindow::keyPressEvent(QKeyEvent *event)
|
|
|
+{
|
|
|
+
|
|
|
+ //按键按下,key值放入容器,如果是长按触发的repeat就不判断
|
|
|
+ if(!event->isAutoRepeat())
|
|
|
+ mPressKeys.insert(event->key());
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::keyReleaseEvent(QKeyEvent *event)
|
|
|
+{
|
|
|
+ if(!event->isAutoRepeat())mPressKeys.remove(event->key());
|
|
|
+ qDebug("key count is %d",mPressKeys.count());
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::resizeEvent(QResizeEvent *event)
|
|
|
+{
|
|
|
+ QSize sizemain = ui->centralwidget->size();
|
|
|
+ qDebug("size x = %d y=%d",sizemain.width(),sizemain.height());
|
|
|
+
|
|
|
+ mMapview->setGeometry(10,10,sizemain.width()/2,sizemain.height()*3/5);
|
|
|
+
|
|
|
+ mmyview->setGeometry(10+sizemain.width()/2+10,10,sizemain.width()/2-30,sizemain.height()*3/5);
|
|
|
+
|
|
|
+ ui->lineEdit_lat->setGeometry(sizemain.width()-100,10,90,30);
|
|
|
+ ui->lineEdit_lon->setGeometry(sizemain.width()-100,50,90,30);
|
|
|
+ ui->pushButton_test->setGeometry(sizemain.width()-100,90,90,30);
|
|
|
+
|
|
|
+// mpWheel->setGeometry(sizemain.width()/2 + 20,10,200,200);
|
|
|
+
|
|
|
+ int grouppos_x = 10;
|
|
|
+ int grouppos_y = 20 + sizemain.height() *3/5;
|
|
|
+ int grouppos_width = sizemain.width()*6/10;
|
|
|
+ int grouppos_height = sizemain.height()*2/5 - 20;
|
|
|
+
|
|
|
+
|
|
|
+ int speed_width = grouppos_height-40;
|
|
|
+ if((speed_width*3 + 150)>grouppos_width)speed_width = (grouppos_width - 150)/3;
|
|
|
+
|
|
|
+ mpWheel->setGeometry(100,30,speed_width,speed_width);
|
|
|
+ mpBrake->setGeometry(120 + speed_width,30,speed_width,speed_width);
|
|
|
+ mpAcc->setGeometry(140 + 2*speed_width,30,speed_width,speed_width);
|
|
|
+ ui->groupBox_rem->setGeometry(grouppos_x,grouppos_y,grouppos_width,grouppos_height);
|
|
|
+
|
|
|
+ int grouppic_x = 10 + sizemain.width()*6/10 + 10;
|
|
|
+ int grouppic_y = 20 + sizemain.height() *3/5;
|
|
|
+ int grouppic_width = sizemain.width()*4/10 - 30;
|
|
|
+ int grouppic_height = sizemain.height()*1/10;
|
|
|
+
|
|
|
+ ui->groupBox_picsel->setGeometry(grouppic_x,grouppic_y,grouppic_width,grouppic_height);
|
|
|
+
|
|
|
+ int groupmap_x = 10 + sizemain.width()*6/10 + 10;
|
|
|
+ int groupmap_y = 20 + sizemain.height() *7/10;
|
|
|
+ int groupmap_width = sizemain.width()*4/10 - 30;
|
|
|
+ int groupmap_height = sizemain.height()*1/10;
|
|
|
+
|
|
|
+ ui->comboBox_Station->setGeometry(10,30,groupmap_width*3/5,30);
|
|
|
+ ui->pushButton_Go->setGeometry(20 + groupmap_width*3/5,30,groupmap_width*2/5 - 30,30);
|
|
|
+
|
|
|
+ ui->groupBox_map->setGeometry(groupmap_x,groupmap_y,groupmap_width,groupmap_height);
|
|
|
+
|
|
|
+ int groupgps_x = 10 + sizemain.width()*6/10 + 10;
|
|
|
+ int groupgps_y = 30 + sizemain.height() *8/10;
|
|
|
+ int groupgps_width = sizemain.width()*4/10 - 30;
|
|
|
+ int groupgps_height = sizemain.height()*2/10 - 30;
|
|
|
+
|
|
|
+ ui->groupBox_gps->setGeometry(groupgps_x,groupgps_y,groupgps_width,groupgps_height);
|
|
|
+
|
|
|
+ int lablewidth = (groupgps_width-50)*2/10;
|
|
|
+ int lewidth = (groupgps_width-50)*3/10;
|
|
|
+ int leheight = 26;
|
|
|
+
|
|
|
+ int nypos = 40;
|
|
|
+ ui->label_gpsins->setGeometry(10,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpsins->setGeometry(20+lablewidth,nypos,lewidth,leheight);
|
|
|
+ ui->label_gpsrtk->setGeometry(30+lablewidth+lewidth,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpsrtk->setGeometry(40+2*lablewidth +lewidth,nypos,lewidth,leheight);
|
|
|
+
|
|
|
+ nypos = nypos + leheight*11/10;
|
|
|
+ ui->label_gpslon->setGeometry(10,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpslon->setGeometry(20+lablewidth,nypos,lewidth,leheight);
|
|
|
+ ui->label_gpslat->setGeometry(30+lablewidth+lewidth,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpslat->setGeometry(40+2*lablewidth +lewidth,nypos,lewidth,leheight);
|
|
|
+
|
|
|
+ nypos = nypos + leheight*11/10;
|
|
|
+ ui->label_gpsheading->setGeometry(10,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpsheading->setGeometry(20+lablewidth,nypos,lewidth,leheight);
|
|
|
+ ui->label_gpsheight->setGeometry(30+lablewidth+lewidth,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpsheight->setGeometry(40+2*lablewidth +lewidth,nypos,lewidth,leheight);
|
|
|
+
|
|
|
+ nypos = nypos + leheight*11/10;
|
|
|
+ ui->label_gpsspeed->setGeometry(10,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpsspeed->setGeometry(20+lablewidth,nypos,lewidth,leheight);
|
|
|
+ ui->label_gpssat->setGeometry(30+lablewidth+lewidth,nypos,lablewidth,leheight);
|
|
|
+ ui->lineEdit_gpssat->setGeometry(40+2*lablewidth +lewidth,nypos,lewidth,leheight);
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void MainWindow::on_pushButton_test_clicked()
|
|
|
+{
|
|
|
+ double flat = ui->lineEdit_lat->text().toDouble();
|
|
|
+ double flon = ui->lineEdit_lon->text().toDouble();
|
|
|
+
|
|
|
+ char strscript[256];
|
|
|
+ snprintf(strscript,255,"theLocation(%11.7f,%11.7f);",flon,flat);
|
|
|
+ mMapview->page()->runJavaScript(strscript);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_manual_clicked()
|
|
|
+{
|
|
|
+ ui->radioButton_manual->setChecked(true);
|
|
|
+ mPressKeys.clear();
|
|
|
+ mfAcc = 0;
|
|
|
+ mfWheel = 0;
|
|
|
+ mfBrake = 0;
|
|
|
+ mpWheel->updatevalue(mfWheel);
|
|
|
+ mpAcc->updatevalue(mfAcc);
|
|
|
+ mpBrake->updatevalue(mfBrake);
|
|
|
+ mManualTime.restart();
|
|
|
+ mnLastTime = mManualTime.elapsed();
|
|
|
+ mpTimerManual->start(10);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onTimerManual()
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+ double fOldWheel = mfWheel;
|
|
|
+ double fOldAcc = mfAcc;
|
|
|
+ double fOldBrake = mfBrake;
|
|
|
+ int timediff = mManualTime.elapsed() - mnLastTime;
|
|
|
+ mnLastTime = mManualTime.elapsed();
|
|
|
+
|
|
|
+ int nOldShift = mnShift;
|
|
|
+
|
|
|
+ if(mpJRT->isOK())
|
|
|
+ {
|
|
|
+ mfWheel = mpJRT->GetWheel() * (-100.0)/32768.0;
|
|
|
+ mfAcc = ((mpJRT->GetAcc()-32767.0)/65535)*(-100.0);
|
|
|
+ mfBrake = ((mpJRT->GetBrake()-32767.0)/65535)*(-100.0);
|
|
|
+ if(mfWheel != fOldWheel)mpWheel->updatevalue(mfWheel);
|
|
|
+ if(mfAcc != fOldAcc)mpAcc->updatevalue(mfAcc);
|
|
|
+ if(mfBrake != fOldBrake)mpBrake->updatevalue(mfBrake);
|
|
|
+
|
|
|
+ int x = mpJRT->GetShift();
|
|
|
+ if(x > 0)mnShift = 1;
|
|
|
+ if(x == 0)mnShift = 0;
|
|
|
+ if(x < 0)mnShift = -1;
|
|
|
+ if(mnShift != nOldShift)
|
|
|
+ {
|
|
|
+ switch (mnShift) {
|
|
|
+ case 1:
|
|
|
+ ui->radioButton_Drive->setChecked(true);
|
|
|
+ ui->radioButton_picfront->setChecked(true);
|
|
|
+ on_radioButton_picfront_clicked();
|
|
|
+ break;
|
|
|
+ case 0:
|
|
|
+ ui->radioButton_Null->setChecked(true);
|
|
|
+ break;
|
|
|
+ case -1:
|
|
|
+ ui->radioButton_Rear->setChecked(true);
|
|
|
+ ui->radioButton_picrear->setChecked(true);
|
|
|
+ on_radioButton_picrear_clicked();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(mPressKeys.contains(Qt::Key_A)&&(mPressKeys.contains((Qt::Key_D))))
|
|
|
+ {
|
|
|
+ mfWheel = mfWheel;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(mPressKeys.contains(Qt::Key_A))
|
|
|
+ {
|
|
|
+ if(mfWheel<0)mfWheel = 0;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mfWheel = mfWheel + timediff*mfWheelSpeed/1000;
|
|
|
+ if(mfWheel < -100)mfWheel = -100;
|
|
|
+ if(mfWheel > 100 )mfWheel = 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mPressKeys.contains(Qt::Key_D))
|
|
|
+ {
|
|
|
+ if(mfWheel>0)mfWheel = 0;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mfWheel = mfWheel - timediff*mfWheelSpeed/1000;
|
|
|
+ if(mfWheel < -100)mfWheel = -100;
|
|
|
+ if(mfWheel > 100 )mfWheel = 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!mPressKeys.contains(Qt::Key_A)&&(!mPressKeys.contains((Qt::Key_D))))
|
|
|
+ {
|
|
|
+ if(mfWheel != 0)
|
|
|
+ {
|
|
|
+ if(mfWheel > 0)mfWheel = mfWheel - timediff*mfWheelAutoDownSpeed/1000;
|
|
|
+ else mfWheel = mfWheel + timediff*mfWheelAutoDownSpeed/1000;
|
|
|
+ if(fabs(mfWheel)< 10)mfWheel =0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mPressKeys.contains(Qt::Key_W)&&(mPressKeys.contains((Qt::Key_S))))
|
|
|
+ {
|
|
|
+ mfAcc = 0;
|
|
|
+ mfBrake = mfBrake + timediff*mfBrakeSpeed/1000;
|
|
|
+ if(mfBrake<0)mfBrake = 0;
|
|
|
+ if(mfBrake > 100)mfBrake = 100;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(mPressKeys.contains(Qt::Key_W))
|
|
|
+ {
|
|
|
+ mfBrake = 0;
|
|
|
+ mfAcc = mfAcc + timediff*mfAccSpeed/1000;
|
|
|
+ if(mfAcc<0)mfAcc = 0;
|
|
|
+ if(mfAcc > 100)mfAcc = 100;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mPressKeys.contains(Qt::Key_S))
|
|
|
+ {
|
|
|
+ mfAcc = 0;
|
|
|
+ mfBrake = mfBrake + timediff*mfBrakeSpeed/1000;
|
|
|
+ if(mfBrake<0)mfBrake = 0;
|
|
|
+ if(mfBrake > 100)mfBrake = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(!mPressKeys.contains(Qt::Key_W)&&(!mPressKeys.contains((Qt::Key_S))))
|
|
|
+ {
|
|
|
+ if(mfBrake != 0)
|
|
|
+ {
|
|
|
+ mfBrake = mfBrake - timediff*mfBrakeAutoDownSpeed/1000;
|
|
|
+ if(mfBrake<0)mfBrake = 0;
|
|
|
+ if(mfBrake > 100)mfBrake = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mfAcc != 0)
|
|
|
+ {
|
|
|
+ mfAcc = mfAcc - timediff*mfAccAutoDownSpeed/1000;
|
|
|
+ if(mfAcc<0)mfAcc = 0;
|
|
|
+ if(mfAcc > 100)mfAcc = 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mfWheel != fOldWheel)mpWheel->updatevalue(mfWheel);
|
|
|
+ if(mfAcc != fOldAcc)mpAcc->updatevalue(mfAcc);
|
|
|
+ if(mfBrake != fOldBrake)mpBrake->updatevalue(mfBrake);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_auto_clicked()
|
|
|
+{
|
|
|
+ ui->radioButton_auto->setChecked(true);
|
|
|
+ mPressKeys.clear();
|
|
|
+ mpTimerManual->stop();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onTimerRemote()
|
|
|
+{
|
|
|
+ if(ui->radioButton_auto->isChecked())
|
|
|
+ {
|
|
|
+ mremotectrl.set_ntype(iv::remotectrl_CtrlType_AUTO);
|
|
|
+// mfAcc = 0;
|
|
|
+// mfBrake = 0;
|
|
|
+// mfWheel =0;
|
|
|
+// mpWheel->updatevalue(mfWheel);
|
|
|
+// mpAcc->updatevalue(mfAcc);
|
|
|
+// mpBrake->updatevalue(mfBrake);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mremotectrl.set_ntype(iv::remotectrl_CtrlType_REMOTE);
|
|
|
+
|
|
|
+ }
|
|
|
+ mremotectrl.set_acc(mfAcc);
|
|
|
+ mremotectrl.set_brake(mfBrake);
|
|
|
+ mremotectrl.set_wheel(mfWheel);
|
|
|
+ mremotectrl.set_shift(mnShift);
|
|
|
+
|
|
|
+ int nsersize = mremotectrl.ByteSize();
|
|
|
+ char * strbuf = new char[nsersize];
|
|
|
+ if(mremotectrl.SerializeToArray(strbuf,nsersize))
|
|
|
+ {
|
|
|
+ iv::modulecomm::ModuleSendMsg(mpa,strbuf,nsersize);
|
|
|
+ }
|
|
|
+ delete strbuf;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onTimerUpdatePic()
|
|
|
+{
|
|
|
+ static qint64 time_pic = 0;
|
|
|
+
|
|
|
+ static qint64 time_trace = 0;
|
|
|
+ static int pos = 0;
|
|
|
+ static std::vector<iv::simpletrace> xvectorsimpletrace;
|
|
|
+
|
|
|
+ if((mnSelPic>=0)&&(mnSelPic<4))
|
|
|
+ {
|
|
|
+ if((gTimeRawPic[mnSelPic] != time_pic) && (gTimeRawPic[mnSelPic] != 0))
|
|
|
+ // if((gTimeRawPic[mnSelPic] != time_pic))
|
|
|
+ {
|
|
|
+ time_pic = gTimeRawPic[mnSelPic];
|
|
|
+ iv::vision::rawpic xpic;
|
|
|
+ gMutexPic[mnSelPic].lock();
|
|
|
+ xpic.CopyFrom(grawpic[mnSelPic]);
|
|
|
+ gMutexPic[mnSelPic].unlock();
|
|
|
+ mpPicView->SetPic(xpic);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mpPicView->IsHaveNew())update();
|
|
|
+
|
|
|
+ if(gTimeTrace != time_trace)
|
|
|
+ {
|
|
|
+ time_trace = gTimeTrace;
|
|
|
+
|
|
|
+ gMutexTrace.lock();
|
|
|
+ xvectorsimpletrace = gvectorsimplerace;
|
|
|
+ gMutexTrace.unlock();
|
|
|
+ pos = 0;
|
|
|
+ if(xvectorsimpletrace.size()> 0)
|
|
|
+ {
|
|
|
+ QJsonArray num_json,num2_json; //声明QJsonArray
|
|
|
+ QJsonDocument num_document,num2_document; //将QJsonArray改为QJsonDocument类
|
|
|
+ QByteArray num_byteArray,num2_byteArray; //
|
|
|
+
|
|
|
+ int i=0;
|
|
|
+ for(i=0;i<xvectorsimpletrace.size();i++) //将数组传入压入num_json
|
|
|
+ {
|
|
|
+ num_json.append(xvectorsimpletrace[i].gps_lng);
|
|
|
+ num2_json.append(xvectorsimpletrace[i].gps_lat);
|
|
|
+ }
|
|
|
+
|
|
|
+ num_document.setArray(num_json);
|
|
|
+ num2_document.setArray(num2_json);
|
|
|
+ num_byteArray = num_document.toJson(QJsonDocument::Compact);
|
|
|
+ num2_byteArray = num2_document.toJson(QJsonDocument::Compact);
|
|
|
+ QString numJson(num_byteArray); //再转为QString
|
|
|
+ QString num2Json(num2_byteArray); //再转为QString
|
|
|
+
|
|
|
+
|
|
|
+ QString cmd = QString("settrace(\"%1\",\"%2\")").arg(numJson).arg(num2Json);
|
|
|
+ mMapview->page()->runJavaScript(cmd);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+// if(pos<xvectorsimpletrace.size())
|
|
|
+// {
|
|
|
+// if(pos == 0)
|
|
|
+// {
|
|
|
+// mMapview->page()->runJavaScript("clear()");
|
|
|
+// }
|
|
|
+
|
|
|
+// char strscript[256];
|
|
|
+// snprintf(strscript,255,"mapLocation(%11.7f,%11.7f);",xvectorsimpletrace[pos].gps_lng,xvectorsimpletrace[pos].gps_lat);
|
|
|
+// mMapview->page()->runJavaScript(strscript);
|
|
|
+// pos++;
|
|
|
+
|
|
|
+// }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onTimerUpdateView()
|
|
|
+{
|
|
|
+ static qint64 time_gps = 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(gTimeGPSIMUUpdate != time_gps)
|
|
|
+ {
|
|
|
+ time_gps = gTimeGPSIMUUpdate;
|
|
|
+ char strscript[256];
|
|
|
+ snprintf(strscript,255,"theLocation(%11.7f,%11.7f,%11.3f);",ggpsimu.lon(),ggpsimu.lat(),ggpsimu.heading());
|
|
|
+ mMapview->page()->runJavaScript(strscript);
|
|
|
+
|
|
|
+ iv::gps::gpsimu xgpsimu;
|
|
|
+ xgpsimu.CopyFrom(ggpsimu);
|
|
|
+
|
|
|
+ ui->lineEdit_gpsins->setText(QString::number(xgpsimu.ins_state()));
|
|
|
+ ui->lineEdit_gpsrtk->setText(QString::number(xgpsimu.rtk_state()));
|
|
|
+ ui->lineEdit_gpslon->setText(QString::number(xgpsimu.lon(),'f',7));
|
|
|
+ ui->lineEdit_gpslat->setText(QString::number(xgpsimu.lat(),'f',7));
|
|
|
+ ui->lineEdit_gpsheading->setText(QString::number(xgpsimu.heading(),'f',2));
|
|
|
+ ui->lineEdit_gpsheight->setText(QString::number(xgpsimu.height(),'f',2));
|
|
|
+ ui->lineEdit_gpsspeed->setText(QString::number(xgpsimu.speed(),'f',2));
|
|
|
+ ui->lineEdit_gpssat->setText(QString::number(xgpsimu.satnum1()));
|
|
|
+
|
|
|
+ mstrGPSTime = QDateTime::fromMSecsSinceEpoch(xgpsimu.msgtime()).toString("GPS: yyyy-MM-dd hh:mm:ss ");
|
|
|
+ setWindowTitle(mstrProgName + mstrVIN + mstrGPSTime + mstrPicTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::paintEvent(QPaintEvent *)
|
|
|
+{
|
|
|
+ if(!mpPicView->IsHaveNew())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QImage image = mpPicView->GetImage();
|
|
|
+ mscene->clear();
|
|
|
+ mscene->addPixmap(QPixmap::fromImage(image));
|
|
|
+ mmyview->setScene(mscene);
|
|
|
+ mmyview->show();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_pushButton_Go_clicked()
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(ui->comboBox_Station->currentIndex() < 0)return;
|
|
|
+ int index = ui->comboBox_Station->currentIndex();
|
|
|
+
|
|
|
+ if(index<0 || index>= gvectorpos.size())
|
|
|
+ {
|
|
|
+ std::cout<<"out range."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iv::pos_def xpos = gvectorpos[index];
|
|
|
+
|
|
|
+ double lon,lat;
|
|
|
+ lon = xpos.mflon;
|
|
|
+ lat = xpos.mflat;
|
|
|
+
|
|
|
+ xodrobj xo;
|
|
|
+ xo.flon = lon;
|
|
|
+ xo.flat = lat;
|
|
|
+ xo.lane = 3;
|
|
|
+
|
|
|
+ iv::modulecomm::ModuleSendMsg(mpadst,(char *)&xo,sizeof(xodrobj));
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_comboBox_Station_currentIndexChanged(int index)
|
|
|
+{
|
|
|
+ if(index<0 || index>= gvectorpos.size())
|
|
|
+ {
|
|
|
+ std::cout<<"out range."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iv::pos_def xpos = gvectorpos[index];
|
|
|
+
|
|
|
+ char strscript[256];
|
|
|
+ snprintf(strscript,255,"objLocation(%11.7f,%11.7f);",xpos.mflon,xpos.mflat);
|
|
|
+ mMapview->page()->runJavaScript(strscript);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_checkBox_Drive_stateChanged(int arg1)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_checkBox_Drive_clicked()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_checkBox_Null_clicked()
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_checkBox_Rear_clicked()
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_Drive_clicked()
|
|
|
+{
|
|
|
+ mnShift = 1;
|
|
|
+ ui->radioButton_picfront->setChecked(true);
|
|
|
+ on_radioButton_picfront_clicked();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_Null_clicked()
|
|
|
+{
|
|
|
+ mnShift = 0;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_Rear_clicked()
|
|
|
+{
|
|
|
+ mnShift = -1;
|
|
|
+ ui->radioButton_picrear->setChecked(true);
|
|
|
+ on_radioButton_picrear_clicked();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_picfront_clicked()
|
|
|
+{
|
|
|
+ mnSelPic = 0;
|
|
|
+ mpbigpicdlg->setCamera(mnSelPic);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_picrear_clicked()
|
|
|
+{
|
|
|
+ mnSelPic = 1;
|
|
|
+ mpbigpicdlg->setCamera(mnSelPic);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_picleft_clicked()
|
|
|
+{
|
|
|
+ mnSelPic = 2;
|
|
|
+ mpbigpicdlg->setCamera(mnSelPic);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_radioButton_picright_clicked()
|
|
|
+{
|
|
|
+ mnSelPic = 3;
|
|
|
+ mpbigpicdlg->setCamera(mnSelPic);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void MainWindow::on_pushButton_AllPic_clicked()
|
|
|
+{
|
|
|
+
|
|
|
+ mppicdlg->show();
|
|
|
+ mppicdlg->setRefresh(true);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onCloseDlg()
|
|
|
+{
|
|
|
+ mppicdlg->setRefresh(false);
|
|
|
+ qDebug("cloase");
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_checkBox_clicked()
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ if(ui->checkBox->isChecked())
|
|
|
+ {
|
|
|
+ for(i=0;i<4;i++)
|
|
|
+ {
|
|
|
+ mpPicSave[i]->startsave();
|
|
|
+ }
|
|
|
+ mbSavePic = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for(i=0;i<4;i++)
|
|
|
+ {
|
|
|
+ mpPicSave[i]->stopsave();
|
|
|
+ }
|
|
|
+ mbSavePic = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::saveavi(int index)
|
|
|
+{
|
|
|
+// if(mbSavePic == false)return;
|
|
|
+ gMutexPic[index].lock();
|
|
|
+ mpPicSave[index]->SetPic(grawpic[index]);
|
|
|
+ gMutexPic[index].unlock();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_pushButton_big_clicked()
|
|
|
+{
|
|
|
+ mpbigpicdlg->show();
|
|
|
+ mpbigpicdlg->setRefresh(true);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onCloseBigDlg()
|
|
|
+{
|
|
|
+ mpbigpicdlg->setRefresh(false);
|
|
|
+}
|