|
@@ -231,26 +231,40 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
|
|
|
ServiceCarStatus.lidar_y_offset = atof(xp.GetParam("lidar_y_offset","0").data());
|
|
|
|
|
|
|
|
|
-
|
|
|
ui->listWidget->setIconSize(QSize(40,40));
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
|
|
// QObject::connect(ui->listWidget,SIGNAL(currentRowChanged(int)),ui->stackedWidget,SLOT(on_listWidget_clicked()));//信号与槽
|
|
|
QObject::connect(ui->listWidget,SIGNAL(currentRowChanged(int)),this,SLOT(on_listWidget_clicked()));//信号与槽
|
|
|
|
|
|
+// /********************************** 百度地图显示 ********************************/
|
|
|
+// mMapview = new QWebEngineView(ui->stackedWidget->widget(0));
|
|
|
+//// qDebug((QDir::currentPath()).toLatin1().data());
|
|
|
+// mMapview->load(QUrl(QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("BaiDuMap.html")));
|
|
|
+// mMapview->setGeometry(750,250,400,400);
|
|
|
+// /********************************************************************************/
|
|
|
+
|
|
|
ui->listWidget->setCurrentRow(1); //apollo_fu debug 20200409
|
|
|
|
|
|
myview = new MyView(ui->stackedWidget->widget(1));
|
|
|
myview->setObjectName(QStringLiteral("graphicsView"));
|
|
|
myview->setGeometry(QRect(0, 100, 900, 900)); //从屏幕上(0,100)位置开始(即为最左上角的点),显示一个900*900的界面(宽900,高900)
|
|
|
|
|
|
+#if 0
|
|
|
myview_small = new MyView(ui->stackedWidget->widget(1));
|
|
|
myview_small->setObjectName(QStringLiteral("graphicsView_small"));
|
|
|
myview_small->setGeometry(QRect(1000,100,500,500));
|
|
|
myview_small->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
+#endif
|
|
|
// myview_small->scale(0.7,0.7);
|
|
|
//myview_small->centerOn(-200,-200);
|
|
|
|
|
|
+ /********************************** 百度地图显示 ********************************/
|
|
|
+ mMapview = new QWebEngineView(ui->stackedWidget->widget(1));
|
|
|
+// qDebug((QDir::currentPath()).toLatin1().data());
|
|
|
+ mMapview->load(QUrl(QString("file:///%1/%2").arg(QApplication::applicationDirPath()).arg("BaiDuMap.html")));
|
|
|
+ mMapview->setGeometry(1000,100,500,500);
|
|
|
+ /********************************************************************************/
|
|
|
|
|
|
image = new QImage(900 * 2, 900 * 2, QImage::Format_RGB32);//画布的初始化大小设为600*500,使用32位颜色
|
|
|
//QImage的32、24、8位图。 图像格式:QImage::Format_RGB32 ,QImage::Format_RGB888,QImage::Format_Indexed8。
|
|
@@ -258,8 +272,9 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
|
|
|
image_small = new QImage(1800,1800,QImage::Format_RGB32);
|
|
|
|
|
|
myview->setCacheMode(myview->CacheBackground);
|
|
|
+#if 0
|
|
|
myview_small->setCacheMode(myview_small->CacheBackground);
|
|
|
-
|
|
|
+#endif
|
|
|
painter = new QPainter(image); //创建QPainter对象
|
|
|
painter_small = new QPainter(image_small); //创建QPainter对象
|
|
|
scene = new QGraphicsScene;
|
|
@@ -291,6 +306,10 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
|
|
|
connect(&mTimerState,SIGNAL(timeout()),this,SLOT(onStateTimer()));//广播发送UDP数据报
|
|
|
mTimerState.start(100); //定时100ms
|
|
|
|
|
|
+ mTimerStateMap.setTimerType(Qt::PreciseTimer); //
|
|
|
+ connect(&mTimerStateMap,SIGNAL(timeout()),this,SLOT(onStateTimerMap()));//
|
|
|
+ mTimerStateMap.start(500); //定时500ms
|
|
|
+
|
|
|
is_show_enable = true;
|
|
|
|
|
|
#ifdef USE_PAD_CTRL
|
|
@@ -306,6 +325,8 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
|
|
|
ModuleFun funplantrace_right = std::bind(&ADCIntelligentVehicle::UpdatePlanTrace_right,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
mpaplantrace_right = iv::modulecomm::RegisterRecvPlus("obstraceright",funplantrace_right);
|
|
|
|
|
|
+ ModuleFun funfusion = std::bind(&ADCIntelligentVehicle::UpdateFusion,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+ mpafusion = iv::modulecomm::RegisterRecvPlus("li_ra_fusion",funfusion);
|
|
|
|
|
|
|
|
|
ModuleFun funmap = std::bind(&ADCIntelligentVehicle::UpdateMap,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
@@ -752,6 +773,20 @@ void ADCIntelligentVehicle::onStateTimer()
|
|
|
// multicast, 224.0.0.1~224.0.0.255 is multicast address of LAN
|
|
|
|
|
|
// _udp->writeDatagram(str.toUtf8(), QHostAddress("224.0.0.131"), 10002);
|
|
|
+
|
|
|
+}
|
|
|
+void ADCIntelligentVehicle::onStateTimerMap()
|
|
|
+{
|
|
|
+ /*******************************更新百度地图******************************/
|
|
|
+
|
|
|
+ double flat = ServiceCarStatus.location->gps_lat;
|
|
|
+ double flon = ServiceCarStatus.location->gps_lng;
|
|
|
+ double fang = ServiceCarStatus.location->ins_heading_angle;
|
|
|
+
|
|
|
+ char strscript[256];
|
|
|
+ snprintf(strscript,255,"theLocation(%11.7f,%11.7f,%11.7f);",flon,flat,fang);
|
|
|
+ mMapview->page()->runJavaScript(strscript);
|
|
|
+ /************************************************************************/
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -922,7 +957,7 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
mnTimeLastUpdatePaint = mTime.elapsed();
|
|
|
// qDebug("enter paint. time is %d",mTime.elapsed());
|
|
|
painter->begin(image);
|
|
|
- painter_small->begin(image_small);
|
|
|
+// painter_small->begin(image_small);
|
|
|
|
|
|
// image->fill(QColor(60, 60, 60));//对画布进行填充
|
|
|
image->fill(QColor(220, 220, 220));//对画布进行填充
|
|
@@ -954,7 +989,7 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
|
|
|
|
|
|
int pointx = 450, pointy = 700;//确定坐标轴起点坐标,这里定义(35,280)
|
|
|
- int pointx_small = 450, pointy_small = 700;
|
|
|
+// int pointx_small = 450, pointy_small = 700;
|
|
|
// double x0[22000], y0[22000], lng[22000], x1[22000], y1[22000], x2[22000], y2[22000];
|
|
|
|
|
|
double * x0, * y0, * lng, * x1, * y1, * x2, * y2;
|
|
@@ -987,19 +1022,19 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
//先绘制车位置点及框图
|
|
|
static const QPointF points1[2] = { QPointF(300, 700), QPointF(600, 700) };
|
|
|
static const QPointF points2[2] = { QPointF(450, 0), QPointF(450, 900) };
|
|
|
- static const QPointF points1_small[2] = { QPointF(300, 700), QPointF(600, 700) };
|
|
|
- static const QPointF points2_small[2] = { QPointF(450, 0), QPointF(450, 900) };
|
|
|
+// static const QPointF points1_small[2] = { QPointF(300, 700), QPointF(600, 700) };
|
|
|
+// static const QPointF points2_small[2] = { QPointF(450, 0), QPointF(450, 900) };
|
|
|
|
|
|
penPoint.setColor(Qt::red);
|
|
|
penPoint.setWidth(2);
|
|
|
painter->setPen(penPoint);
|
|
|
- painter_small->setPen(penPoint);
|
|
|
+// painter_small->setPen(penPoint);
|
|
|
painter->drawPoint(pointx, pointy);
|
|
|
- painter_small->drawPoint(pointx_small,pointy_small);
|
|
|
+// painter_small->drawPoint(pointx_small,pointy_small);
|
|
|
painter->drawPolyline(points1, 2);
|
|
|
painter->drawPolyline(points2, 2);
|
|
|
- painter_small->drawPolyline(points1_small, 2);
|
|
|
- painter_small->drawPolyline(points2_small, 2);
|
|
|
+// painter_small->drawPolyline(points1_small, 2);
|
|
|
+// painter_small->drawPolyline(points2_small, 2);
|
|
|
|
|
|
//路径点的预处理
|
|
|
for (int i = 0; i < sizeN; i++)
|
|
@@ -1034,7 +1069,7 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
if (ServiceCarStatus.location->gps_x == 0)
|
|
|
{
|
|
|
painter->drawText(rect(), Qt::AlignLeft, QString::fromLocal8Bit("等待车辆实时GPS位置信息"));
|
|
|
- painter_small->drawText(rect(), Qt::AlignLeft, QString::fromLocal8Bit("等待车辆实时GPS位置信息"));
|
|
|
+// painter_small->drawText(rect(), Qt::AlignLeft, QString::fromLocal8Bit("等待车辆实时GPS位置信息"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1068,8 +1103,8 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
- double kx_small = (double)(1200) / (abs(y_max - y_min));//x轴的系数
|
|
|
- double ky_small = (double)(1200) / (abs(y_max - y_min));//y方向的比例系数
|
|
|
+// double kx_small = (double)(1200) / (abs(y_max - y_min));//x轴的系数
|
|
|
+// double ky_small = (double)(1200) / (abs(y_max - y_min));//y方向的比例系数
|
|
|
|
|
|
double kx = 10;
|
|
|
double ky = 10;
|
|
@@ -1085,22 +1120,22 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
for (int i = 1; i < sizeN - 1; i++)
|
|
|
{
|
|
|
painter->setPen(penPoint);//蓝色的笔,用于标记各个点
|
|
|
- painter_small->setPen(penPoint);//蓝色的笔,用于标记各个点
|
|
|
+// painter_small->setPen(penPoint);//蓝色的笔,用于标记各个点
|
|
|
painter->drawPoint(pointx + x0[i] * kx, pointy - y0[i] * ky);
|
|
|
- painter_small->drawPoint(pointx_small + x0[i] * kx_small, pointy_small - y0[i] * ky_small);
|
|
|
+// painter_small->drawPoint(pointx_small + x0[i] * kx_small, pointy_small - y0[i] * ky_small);
|
|
|
painter->drawPoint(pointx + x1[i] * kx, pointy - y1[i] * ky);
|
|
|
- painter_small->drawPoint(pointx_small + x1[i] * kx_small, pointy_small - y1[i] * ky_small);
|
|
|
+// painter_small->drawPoint(pointx_small + x1[i] * kx_small, pointy_small - y1[i] * ky_small);
|
|
|
painter->drawPoint(pointx + x2[i] * kx, pointy - y2[i] * ky);
|
|
|
- painter_small->drawPoint(pointx_small + x2[i] * kx_small, pointy_small - y2[i] * ky_small);
|
|
|
+// painter_small->drawPoint(pointx_small + x2[i] * kx_small, pointy_small - y2[i] * ky_small);
|
|
|
}
|
|
|
painter->drawPoint(pointx + x0[sizeN - 1] * kx, pointy - y0[sizeN - 1] * ky);//绘制最后一个点
|
|
|
- painter_small->drawPoint(pointx_small + x0[sizeN - 1] * kx_small, pointy_small - y0[sizeN - 1] * ky_small);//绘制最后一个点
|
|
|
+// painter_small->drawPoint(pointx_small + x0[sizeN - 1] * kx_small, pointy_small - y0[sizeN - 1] * ky_small);//绘制最后一个点
|
|
|
|
|
|
penPoint.setColor(Qt::red);
|
|
|
penPoint.setWidth(2);
|
|
|
|
|
|
painter->drawPoint(pointx + x0[0] * kx, pointy - y0[0] * ky);
|
|
|
- painter_small->drawPoint(pointx_small + x0[0] * kx_small, pointy_small - y0[0] * ky_small);
|
|
|
+// painter_small->drawPoint(pointx_small + x0[0] * kx_small, pointy_small - y0[0] * ky_small);
|
|
|
|
|
|
#if 0
|
|
|
// draw plan trace
|
|
@@ -1158,7 +1193,7 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
//pix.load("car.png");
|
|
|
pix.load(":/ADCIntelligentVehicle/car1.png");
|
|
|
painter->drawPixmap(435,667,30,67,pix);
|
|
|
- painter_small->drawPixmap(442,683,16,34,pix);
|
|
|
+// painter_small->drawPixmap(442,683,16,34,pix);
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
@@ -1178,56 +1213,89 @@ void ADCIntelligentVehicle::paintEvent(QPaintEvent *)
|
|
|
// //
|
|
|
//////////////////////////////////////
|
|
|
|
|
|
- painter->setPen(QPen(Qt::black, 2));
|
|
|
- painter->setBrush(Qt::blue);
|
|
|
- QFont esr_font("Microsoft YaHei", 10, 75); //第一个属性是字体(微软雅黑),第二个是大小,第三个是加粗(权重是75)
|
|
|
- painter->setFont(esr_font);
|
|
|
- char coordinate_ear[100];
|
|
|
- iv::radar::radarobjectarray xradararray;
|
|
|
- if(mbradarUpdate)
|
|
|
+ if(ui->checkBox_8->isChecked())
|
|
|
{
|
|
|
- mMutexRadar.lock();
|
|
|
- xradararray.CopyFrom(mradararray);
|
|
|
- mMutexRadar.unlock();
|
|
|
- for (int a = 0; a < xradararray.obj_size(); a++)
|
|
|
+ painter->setPen(QPen(Qt::black, 2));
|
|
|
+ painter->setBrush(Qt::blue);
|
|
|
+ QFont esr_font("Microsoft YaHei", 10, 75); //第一个属性是字体(微软雅黑),第二个是大小,第三个是加粗(权重是75)
|
|
|
+ painter->setFont(esr_font);
|
|
|
+ char coordinate_ear[100];
|
|
|
+ iv::radar::radarobjectarray xradararray;
|
|
|
+ if(mbradarUpdate)
|
|
|
{
|
|
|
- if (xradararray.obj(a).bvalid())
|
|
|
+ mMutexRadar.lock();
|
|
|
+ xradararray.CopyFrom(mradararray);
|
|
|
+ mMutexRadar.unlock();
|
|
|
+ for (int a = 0; a < xradararray.obj_size(); a++)
|
|
|
{
|
|
|
- painter->drawEllipse(xradararray.obj(a).x() * 10 + 450, -((xradararray.obj(a).y() + ServiceCarStatus.esr_y_offset) * 10) + 700, 10, 10);
|
|
|
- sprintf(coordinate_ear, "(%d, %d)", (int)xradararray.obj(a).x(), (int)xradararray.obj(a).y());
|
|
|
- painter->drawText(xradararray.obj(a).x() * 10 + 450, -((xradararray.obj(a).y() + ServiceCarStatus.esr_y_offset ) * 10) + 700, QString(coordinate_ear));
|
|
|
+ if (xradararray.obj(a).bvalid())
|
|
|
+ {
|
|
|
+ painter->drawEllipse(xradararray.obj(a).x() * 10 + 450, -((xradararray.obj(a).y() + ServiceCarStatus.esr_y_offset) * 10) + 700, 10, 10);
|
|
|
+ sprintf(coordinate_ear, "(%d, %d)", (int)xradararray.obj(a).x(), (int)xradararray.obj(a).y());
|
|
|
+ painter->drawText(xradararray.obj(a).x() * 10 + 450, -((xradararray.obj(a).y() + ServiceCarStatus.esr_y_offset ) * 10) + 700, QString(coordinate_ear));
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+ // mbradarUpdate = false;
|
|
|
}
|
|
|
- // mbradarUpdate = false;
|
|
|
}
|
|
|
|
|
|
|
|
|
- ServiceLidar.copylidarto(Lidar_read); //激光雷达障碍物
|
|
|
- ServiceLidar.copylidarobsto(Lidar_obsread);
|
|
|
- painter->setPen(QColor(255, 0, 0));
|
|
|
- for (unsigned int x = 0; x < Lidar_read->size(); x++)
|
|
|
+ if(ui->checkBox_9->isChecked())
|
|
|
{
|
|
|
- //painter->drawPoint(((*Lidar_read)[x].nomal_x) * 10 + 450, -(*Lidar_read)[x].nomal_y * 10 + 700);
|
|
|
+ ServiceLidar.copylidarto(Lidar_read); //激光雷达障碍物
|
|
|
+ ServiceLidar.copylidarobsto(Lidar_obsread);
|
|
|
+ painter->setPen(QColor(255, 0, 0));
|
|
|
+ for (unsigned int x = 0; x < Lidar_read->size(); x++)
|
|
|
+ {
|
|
|
+ //painter->drawPoint(((*Lidar_read)[x].nomal_x) * 10 + 450, -(*Lidar_read)[x].nomal_y * 10 + 700);
|
|
|
+ }
|
|
|
+ painter->setPen(QColor(255,0,0));
|
|
|
+ for (unsigned int x = 0; x < Lidar_obsread->size(); x++)
|
|
|
+ {
|
|
|
+ painter->drawPoint(((*Lidar_obsread)[x].nomal_x) * 10 + 450, -((*Lidar_obsread)[x].nomal_y + ServiceCarStatus.lidar_y_offset) * 10 + 700);
|
|
|
+ }
|
|
|
}
|
|
|
- painter->setPen(QColor(255,0,0));
|
|
|
- for (unsigned int x = 0; x < Lidar_obsread->size(); x++)
|
|
|
+
|
|
|
+
|
|
|
+ //////////////////////////////////////
|
|
|
+ // //
|
|
|
+ // 显示融合的信息 //
|
|
|
+ // //
|
|
|
+ //////////////////////////////////////
|
|
|
+
|
|
|
+ if(ui->checkBox_10->isChecked())
|
|
|
{
|
|
|
- painter->drawPoint(((*Lidar_obsread)[x].nomal_x) * 10 + 450, -((*Lidar_obsread)[x].nomal_y + ServiceCarStatus.lidar_y_offset) * 10 + 700);
|
|
|
- }
|
|
|
+ painter->setPen(QColor(0,255,0));
|
|
|
+ iv::fusion::fusionobjectarray xfusionarray;
|
|
|
+ if(mbfusionUpdate)
|
|
|
+ {
|
|
|
+ mMutexFusion.lock();
|
|
|
+ xfusionarray.CopyFrom(mfusionarray);
|
|
|
+ mMutexFusion.unlock();
|
|
|
+ for(int a = 0; a < xfusionarray.obj_size(); a++)
|
|
|
+ {
|
|
|
+ for(int b = 0; b < xfusionarray.obj(a).nomal_centroid_size(); b++)
|
|
|
+ {
|
|
|
+ painter->drawPoint((xfusionarray.obj(a).nomal_centroid(b).nomal_x())*10 + 450, -(xfusionarray.obj(a).nomal_centroid(b).nomal_y())*10 + 700);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
painter->end();
|
|
|
- painter_small->end();
|
|
|
+// painter_small->end();
|
|
|
scene->clear();
|
|
|
- scene_small->clear();
|
|
|
+// scene_small->clear();
|
|
|
scene->addPixmap(QPixmap::fromImage(*image));
|
|
|
- scene_small->addPixmap(QPixmap::fromImage(*image_small));
|
|
|
+// scene_small->addPixmap(QPixmap::fromImage(*image_small));
|
|
|
myview->setScene(scene);
|
|
|
- myview_small->setScene(scene_small);
|
|
|
+// myview_small->setScene(scene_small);
|
|
|
myview->show();
|
|
|
- myview_small->show();
|
|
|
+// myview_small->show();
|
|
|
navigation_data.clear();
|
|
|
|
|
|
if(mfSOC != 0.0)
|
|
@@ -1478,6 +1546,22 @@ void ADCIntelligentVehicle::UpdatePlanTrace_right(const char * strdata,const uns
|
|
|
}
|
|
|
|
|
|
|
|
|
+void ADCIntelligentVehicle::UpdateFusion(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ iv::fusion::fusionobjectarray xfusionarray;
|
|
|
+ if(!xfusionarray.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ gIvlog->warn("ADCIntelligentVehicle::UpdateFusion Parse Error.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mMutexFusion.lock();
|
|
|
+ mfusionarray.CopyFrom(xfusionarray);
|
|
|
+ mbfusionUpdate = true;
|
|
|
+ mMutexFusion.unlock();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @brief ADCIntelligentVehicle::UpdateMap
|
|
|
* @param strdata
|