|
@@ -28,7 +28,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
ui(new Ui::MainWindow)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
-
|
|
|
//Start Get init param
|
|
|
QString strpath = QCoreApplication::applicationDirPath();
|
|
|
qDebug()<<strpath;
|
|
@@ -37,11 +36,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
iv::xmlparam::Xmlparam xp(strpath.toStdString());
|
|
|
|
|
|
std::string strCarVIN = xp.GetParam("carVIN","catarc001");
|
|
|
+ mscarID = QString::fromStdString(strCarVIN);
|
|
|
std::string strHostIP = xp.GetParam("hostIP","47.95.196.28");
|
|
|
std::string strHostPort = xp.GetParam("hostPort","12123");
|
|
|
std::string strStationCount = xp.GetParam("stationCount","20");
|
|
|
int count = std::stoi(strStationCount,nullptr,10);
|
|
|
- stationGps location;
|
|
|
+ StationGps location;
|
|
|
for(int i = 0; i < count; i++)
|
|
|
{
|
|
|
std::string strLatName = "lat" + std::to_string(i);
|
|
@@ -61,14 +61,37 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
ui->lineEdit_port->setText(QString::fromStdString(strHostPort));
|
|
|
ui->pushButton_connect->setEnabled(false);
|
|
|
|
|
|
- //连接信号槽
|
|
|
givlog = new iv::Ivlog("v2x");
|
|
|
connect(socket, &QTcpSocket::readyRead, this, &MainWindow::socket_Read_Data);
|
|
|
connect(socket, &QTcpSocket::disconnected, this, &MainWindow::socket_Disconnected);
|
|
|
|
|
|
- mp_v2xSend = iv::modulecomm::RegisterSend("v2x",1000,3);
|
|
|
+ /* ShareMemory Register BEGIN */
|
|
|
+ //ShareMem: v2x
|
|
|
+ mpMemV2xSend = iv::modulecomm::RegisterSend("v2x",1000,3);
|
|
|
+ //ShareMem: v2x使能状态
|
|
|
iv::modulecomm::RegisterRecv("v2xStEn", ListenV2xStEn);
|
|
|
- mp_v2xStSend = iv::modulecomm::RegisterSend("v2xStReq",1000,1);
|
|
|
+ //ShareMem: v2x使能状态请求
|
|
|
+ mpMemV2xStSend = iv::modulecomm::RegisterSend("v2xStReq",1000,1);
|
|
|
+ //ShareMem: 车辆地盘状态
|
|
|
+ ModuleFun funchassis =std::bind(&MainWindow::UpdateChassis,this,std::placeholders::_1,\
|
|
|
+ std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,\
|
|
|
+ std::placeholders::_5);
|
|
|
+ mpMemchassis = iv::modulecomm::RegisterRecvPlus("chassis",funchassis);
|
|
|
+ //ShareMem: gps
|
|
|
+ ModuleFun fungpsimu =std::bind(&MainWindow::UpdateGPSIMU,this,std::placeholders::_1, \
|
|
|
+ std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+ mpMemGps = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",fungpsimu);
|
|
|
+
|
|
|
+ ModuleFun funlidarObs =std::bind(&MainWindow::UpdateLidarObs,this,std::placeholders::_1, \
|
|
|
+ std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+ mpMemLidarObs = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",funlidarObs);
|
|
|
+
|
|
|
+ ModuleFun funRadarObs =std::bind(&MainWindow::UpdateRadarObs,this,std::placeholders::_1, \
|
|
|
+ std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
+ mpMemRadarObs = iv::modulecomm::RegisterRecvPlus("hcp2_gpsimu",funRadarObs);
|
|
|
+
|
|
|
+ /* ShareMemory Register END */
|
|
|
+
|
|
|
shareV2xStReqMsg();
|
|
|
//heart beat,jiaolili,20210207
|
|
|
m_bEnablePlatform=false;
|
|
@@ -364,7 +387,7 @@ void MainWindow::shareV2xProtoMsg(iv::v2x::v2x msgV2xProto)
|
|
|
char * strdata = new char[msgV2xProto.ByteSize()];
|
|
|
if(msgV2xProto.SerializePartialToArray(strdata,nsize))
|
|
|
{
|
|
|
- iv::modulecomm::ModuleSendMsg(mp_v2xSend,strdata,nsize);
|
|
|
+ iv::modulecomm::ModuleSendMsg(mpMemV2xSend,strdata,nsize);
|
|
|
}
|
|
|
givlog->info("v2x","share v2x controll Msg");
|
|
|
delete strdata;
|
|
@@ -378,7 +401,7 @@ void MainWindow::shareV2xStReqMsg()
|
|
|
char * str = new char[nsize];
|
|
|
if(x.SerializeToArray(str,nsize))
|
|
|
{
|
|
|
- iv::modulecomm::ModuleSendMsg(mp_v2xStSend,str,nsize);
|
|
|
+ iv::modulecomm::ModuleSendMsg(mpMemV2xStSend,str,nsize);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -401,10 +424,22 @@ void MainWindow::shareV2xStReqMsg()
|
|
|
void MainWindow::upVehicleStatus()
|
|
|
{
|
|
|
QString time_stamp=getTimeStamp();
|
|
|
- QString test="['CCFF',"+time_stamp+",'catarc001',1,0,0,100,0,0,0,0,0]";
|
|
|
+ QString test="['CCFF',"+time_stamp+mscarID+","+QString::number(micarMode)+","+QString::number(mfspeed)+","+ \
|
|
|
+ QString::number(mfsteerAngle)+","+ QString::number(miSOC)+","+ QString::number(micarError)+","+ \
|
|
|
+ QString::number(mierrorNum)+","+QString::number(mflon)+","+ QString::number(mflat)+","+ \
|
|
|
+ QString::number(mfheading)+"]";
|
|
|
//QByteArray bytes = test.toUtf8();
|
|
|
QByteArray bytes = test.toLatin1();
|
|
|
socket->write(bytes);
|
|
|
+ micarMode = 0;
|
|
|
+ mfspeed = 0;
|
|
|
+ mfsteerAngle = 0;
|
|
|
+ miSOC = 0;
|
|
|
+ micarError = 0;
|
|
|
+ mierrorNum = 0;
|
|
|
+ mflon = 0;
|
|
|
+ mflat = 0;
|
|
|
+ mfheading = 0;
|
|
|
}
|
|
|
void MainWindow::upHardwareStatus()
|
|
|
{
|
|
@@ -413,6 +448,15 @@ void MainWindow::upHardwareStatus()
|
|
|
//QByteArray bytes = test.toUtf8();
|
|
|
QByteArray bytes = test.toLatin1();
|
|
|
socket->write(bytes);
|
|
|
+ mistRadar = 1;
|
|
|
+ mistLidar = 1;
|
|
|
+ mistSonic = 0;//超声
|
|
|
+ mistCamera = 0;
|
|
|
+ mistmic = 0;
|
|
|
+ mistGPS = 1;
|
|
|
+ mistCanCar = 1;
|
|
|
+ mistCanRadar = 1;
|
|
|
+ mistlight = 0;//红绿灯
|
|
|
}
|
|
|
void MainWindow::upObstacleDataStatus()
|
|
|
{
|
|
@@ -430,3 +474,153 @@ void MainWindow::upSoftwareStatus()
|
|
|
QByteArray bytes = test.toLatin1();
|
|
|
socket->write(bytes);
|
|
|
}
|
|
|
+
|
|
|
+void MainWindow::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
|
|
|
+{
|
|
|
+ mistCanCar = 0;
|
|
|
+ iv::chassis xchassis;
|
|
|
+ static int ncount = 0;
|
|
|
+ if(!xchassis.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ std::cout<<"v2xTcpClient::UpdateChassis ParseFrom Array Error."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(xchassis.has_drivemode())
|
|
|
+ {
|
|
|
+ micarMode = xchassis.drivemode();
|
|
|
+ }
|
|
|
+ if(xchassis.has_vel())
|
|
|
+ mfspeed = xchassis.vel();
|
|
|
+ if(xchassis.has_angle_feedback())
|
|
|
+ mfsteerAngle = xchassis.angle_feedback();
|
|
|
+ if((xchassis.has_soc()))
|
|
|
+ {
|
|
|
+ miSOC = xchassis.soc();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//接收GPS数据
|
|
|
+void MainWindow::UpdateGPSIMU(const char * strdata,const unsigned int nSize,const unsigned int index,\
|
|
|
+ const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+
|
|
|
+ iv::gps::gpsimu xgpsimu;
|
|
|
+ if(!xgpsimu.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ givlog->warn("ADCIntelligentVehicle::UpdateGPSIMU parse error. nSize is %d",nSize);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mflat = xgpsimu.lat();
|
|
|
+ mflon = xgpsimu.lon();
|
|
|
+ mfheading = xgpsimu.heading();
|
|
|
+ mpdata.gps_lat = xgpsimu.lat();
|
|
|
+ mpdata.gps_lng = xgpsimu.lon();
|
|
|
+ mpdata.ins_heading_angle = xgpsimu.heading();
|
|
|
+ mpdata.rtk_status = xgpsimu.rtk_state();
|
|
|
+ mpdata.ins_status = xgpsimu.ins_state();
|
|
|
+ mpdata.vel_D = xgpsimu.vd(); //地向速度,单位(米/秒)
|
|
|
+ mpdata.vel_E = xgpsimu.ve(); //东向速度,单位(米/秒)
|
|
|
+ mpdata.vel_N = xgpsimu.vn(); //北向速度,单位(米/秒)
|
|
|
+
|
|
|
+ // mfspeed = sqrt(pow(data->vel_E,2)+pow(data->vel_N,2)) * 3.6; //double pow(double x, double y) 返回 x 的 y 次幂,即 xy。
|
|
|
+ mistGPS = 0;
|
|
|
+}
|
|
|
+
|
|
|
+int toUnicode(const char* str)
|
|
|
+{
|
|
|
+ return str[0] + (str[1] ? toUnicode(str + 1) : 0);
|
|
|
+}
|
|
|
+
|
|
|
+constexpr inline int U(const char* str)
|
|
|
+{
|
|
|
+ return str[0] + (str[1] ? U(str + 1) : 0);
|
|
|
+}
|
|
|
+int GetTypeString(const char* obsType)
|
|
|
+{
|
|
|
+ switch (toUnicode(obsType))
|
|
|
+ {
|
|
|
+ case U("unknown"):
|
|
|
+ return 0;
|
|
|
+ case U("car"):
|
|
|
+ return 1;
|
|
|
+ case U("bike"):
|
|
|
+ return 5;
|
|
|
+ case U("pedestrian"):
|
|
|
+ return 3;
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+void MainWindow::UpdateLidarObs(const char * strdata,const unsigned int nSize,const unsigned int index, \
|
|
|
+ const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+
|
|
|
+// std::vector<iv::lidar::object> lidarobjvec;
|
|
|
+// strtolidarobj(lidarobjvec,strdata,nSize);
|
|
|
+ mqLidarObsInfo.clear();
|
|
|
+ iv::lidar::objectarray lidarobjvec;
|
|
|
+ std::string in;
|
|
|
+ in.append(strdata,nSize);
|
|
|
+ lidarobjvec.ParseFromString(in);
|
|
|
+ givlog->verbose("v2xLidarObs","obj size is %d ",lidarobjvec.obj_size());
|
|
|
+ miLidarObsCount = lidarobjvec.obj_size();
|
|
|
+ ObsInfo xobsInfo;
|
|
|
+ double x,y;
|
|
|
+ iv::GPS_INS gps_ins;
|
|
|
+ for(int i = 0; i < miLidarObsCount; i++)
|
|
|
+ {
|
|
|
+ x = lidarobjvec.obj(i).centroid().x();
|
|
|
+ y = lidarobjvec.obj(i).centroid().y();
|
|
|
+ gps_ins = iv::decition::Coordinate_UnTransfer(x, y, mpdata);
|
|
|
+ GaussProjInvCal(gps_ins.gps_x, gps_ins.gps_y, &(gps_ins.gps_lng), &(gps_ins.gps_lat));
|
|
|
+ xobsInfo.lat = gps_ins.gps_lat;
|
|
|
+ xobsInfo.lon = gps_ins.gps_lng;
|
|
|
+ std::string str = lidarobjvec.obj(i).type_name();
|
|
|
+ xobsInfo.type = GetTypeString(str.data());
|
|
|
+ mqLidarObsInfo.append(xobsInfo);
|
|
|
+ }
|
|
|
+ mistLidar = 0;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::UpdateRadarObs(const char * strdata,const unsigned int nSize,const unsigned int index, \
|
|
|
+ const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ mqRadarObsInfo.clear();
|
|
|
+ static qint64 oldrecvtime;
|
|
|
+ iv::radar::radarobjectarray xradararray;
|
|
|
+ if(!xradararray.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ givlog->warn("ADCIntelligentVehicle::UpdateRADAR Parse Error.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // gIvlog->verbose("radar time is %ld",QDateTime::currentMSecsSinceEpoch());
|
|
|
+
|
|
|
+ if((QDateTime::currentMSecsSinceEpoch() - oldrecvtime)>100)
|
|
|
+ {
|
|
|
+ givlog->warn("radar interval is more than 100ms. value is %ld",QDateTime::currentMSecsSinceEpoch() - oldrecvtime);
|
|
|
+ }
|
|
|
+
|
|
|
+ oldrecvtime = QDateTime::currentMSecsSinceEpoch();
|
|
|
+
|
|
|
+ miRadarObsCount = xradararray.obj_size();
|
|
|
+ ObsInfo xobsInfo;
|
|
|
+ double x,y;
|
|
|
+ iv::GPS_INS gps_ins;
|
|
|
+ for(int i = 0; i < miRadarObsCount; i++)
|
|
|
+ {
|
|
|
+ x = xradararray.obj(i).x();
|
|
|
+ y = xradararray.obj(i).y();
|
|
|
+ gps_ins = iv::decition::Coordinate_UnTransfer(x, y, mpdata);
|
|
|
+ GaussProjInvCal(gps_ins.gps_x, gps_ins.gps_y, &(gps_ins.gps_lng), &(gps_ins.gps_lat));
|
|
|
+ xobsInfo.lat = gps_ins.gps_lat;
|
|
|
+ xobsInfo.lon = gps_ins.gps_lng;
|
|
|
+ xobsInfo.type = 0;
|
|
|
+ mqRadarObsInfo.append(xobsInfo);
|
|
|
+ }
|
|
|
+ mistRadar = 0;
|
|
|
+ mistCanRadar = 0;
|
|
|
+ mistLidar = 0;
|
|
|
+}
|