|
@@ -15,6 +15,17 @@
|
|
|
#include <QMessageBox>
|
|
|
#include <QFile>
|
|
|
|
|
|
+
|
|
|
+#include <functional>
|
|
|
+
|
|
|
+using namespace std;
|
|
|
+
|
|
|
+using std::placeholders::_1;
|
|
|
+using std::placeholders::_2;
|
|
|
+using std::placeholders::_3;
|
|
|
+using std::placeholders::_4;
|
|
|
+using std::placeholders::_5;
|
|
|
+
|
|
|
static pose gCurPose;
|
|
|
|
|
|
static double gView_Z = 100.0;
|
|
@@ -120,6 +131,13 @@ void ShowXODR(pcl::visualization::PCLVisualizer& viewer)
|
|
|
|
|
|
pcl::visualization::PCLVisualizer *gpviewer;
|
|
|
|
|
|
+static bool mbsetstart = false;
|
|
|
+static bool mbdrawstart = false;
|
|
|
+static bool mbsetend = false;
|
|
|
+static bool mbdrawend = false;
|
|
|
+static double mfstartx,mfstarty;
|
|
|
+static double mfendx,mfendy;
|
|
|
+
|
|
|
#include <vtkRenderer.h>
|
|
|
#include <vtkRenderWindow.h>
|
|
|
|
|
@@ -215,6 +233,12 @@ void viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
|
|
|
{
|
|
|
// std::cout<<std::chrono::system_clock::now().time_since_epoch().count()/1000000<<" psycho."<<std::endl;
|
|
|
|
|
|
+ static double lastx,lasty,lastz,lastyaw;
|
|
|
+ lastx = 0.0;lasty = 0.0; lastz = 0.0; lastyaw = 0.0;
|
|
|
+
|
|
|
+// int64_t ntime1 = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
+
|
|
|
+ static int64_t nlastcamup = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
|
|
|
if(gbCarModelLoad)
|
|
|
{
|
|
@@ -268,6 +292,8 @@ void viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
viewer.removeShape("car");
|
|
|
|
|
|
Eigen::Vector3f trans;
|
|
@@ -284,13 +310,17 @@ void viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
|
|
|
viewer.addCube(Eigen::Vector3f(gCurPose.x,gCurPose.y,gCurPose.z-1.15),
|
|
|
Eigen::Quaternionf(rotation_vector), 4.6, 2.3, 1.5, "car");
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
double yaw_calc = M_PI/2.0 - gCurPose.yaw;
|
|
|
|
|
|
- if(gbAutoCam)
|
|
|
+ int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
+
|
|
|
+ int64_t nupdiff = nnow - nlastcamup;
|
|
|
+
|
|
|
+ if(gbAutoCam && (abs(nupdiff)> 1e8))
|
|
|
{
|
|
|
+ nlastcamup = nnow;
|
|
|
if(gnViewMode == 0)
|
|
|
viewer.setCameraPosition(gCurPose.x,gCurPose.y,gView_Z,gCurPose.x,gCurPose.y,gCurPose.z,sin(yaw_calc),cos(yaw_calc),0);
|
|
|
|
|
@@ -368,6 +398,33 @@ void viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
|
|
|
|
|
|
}
|
|
|
|
|
|
+ double fsesize = 0.5;
|
|
|
+ if(mbsetstart)
|
|
|
+ {
|
|
|
+ if(mbdrawstart)viewer.removeShape("start");
|
|
|
+
|
|
|
+ viewer.addCube(mfstartx -0.5* fsesize,mfstartx + 0.5* fsesize, mfstarty - 0.5* fsesize, mfstarty + 0.5* fsesize,
|
|
|
+ 0,1.5,0.0,1.0,0.0,"start",0);
|
|
|
+
|
|
|
+ mbsetstart = false;
|
|
|
+ mbdrawstart = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(mbsetend)
|
|
|
+ {
|
|
|
+ if(mbdrawend)viewer.removeShape("end");
|
|
|
+
|
|
|
+ viewer.addCube(mfendx -0.5* fsesize,mfendx + 0.5* fsesize, mfendy - 0.5* fsesize, mfendy + 0.5* fsesize,
|
|
|
+ 0,1.5,1.0,0.0,0.0,"end",0);
|
|
|
+
|
|
|
+ mbsetend = false;
|
|
|
+ mbdrawend = true;
|
|
|
+ }
|
|
|
+
|
|
|
+// int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
+
|
|
|
+// std::cout<<"view show use: "<<(nnow - ntime1)/1e6<<" ms."<<std::endl;
|
|
|
+
|
|
|
std::stringstream ss;
|
|
|
// viewer.setCameraPosition(mpos_x,0,30,mpos_x + 20,0,0,0,0,0);
|
|
|
// ss << "Once per viewer loop: " << count++;
|
|
@@ -430,6 +487,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
ModuleFun funcnndetect =std::bind(&MainWindow::Updatelidarcnndetect,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
mpacnndetect = iv::modulecomm::RegisterRecvPlus("lidar_track",funcnndetect);
|
|
|
|
|
|
+ mpamap = iv::modulecomm::RegisterRecvPlus("tracemap",std::bind(&MainWindow::UpdateMap,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,
|
|
|
+ std::placeholders::_4,std::placeholders::_5));
|
|
|
+
|
|
|
+
|
|
|
connect(this,SIGNAL(ndtposupdate()),this,SLOT(onndtposupdate()));
|
|
|
connect(this,SIGNAL(updatedst(double,double)),this,SLOT(onUpdateDst(double,double)));
|
|
|
|
|
@@ -912,3 +973,60 @@ void MainWindow::onUpdateDst(double w_x, double w_y)
|
|
|
ui->lineEdit_Lon->setText(QString::number(lon,'f',7));
|
|
|
ui->lineEdit_Lat->setText(QString::number(lat,'f',7));
|
|
|
}
|
|
|
+
|
|
|
+void MainWindow::UpdateMap(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ (void)index;
|
|
|
+ (void)dt;
|
|
|
+ (void)strmemname;
|
|
|
+
|
|
|
+ if(nSize<sizeof(iv::GPS_INS))
|
|
|
+ {
|
|
|
+ std::cout<<" no map data."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int nPointSize = static_cast<int>(nSize/sizeof(iv::GPS_INS));
|
|
|
+ iv::GPS_INS * pmap = (iv::GPS_INS * )strdata;
|
|
|
+
|
|
|
+ double x0,y0;
|
|
|
+ double x,y;
|
|
|
+
|
|
|
+
|
|
|
+ double lon0,lat0;
|
|
|
+ lon0 = mflon0;
|
|
|
+ lat0 = mflat0;
|
|
|
+ GaussProjCal(lon0,lat0,&x0,&y0);
|
|
|
+ GaussProjCal(pmap[0].gps_lng,pmap[0].gps_lat,&x,&y);
|
|
|
+ x = x - x0;
|
|
|
+ y = y - y0;
|
|
|
+ mfstartx = x;
|
|
|
+ mfstarty = y;
|
|
|
+ mbsetstart = true;
|
|
|
+
|
|
|
+// emit signalSetStartPos(x,y);
|
|
|
+
|
|
|
+
|
|
|
+ GaussProjCal(pmap[nPointSize -1].gps_lng,pmap[nPointSize -1].gps_lat,&x,&y);
|
|
|
+ x = x - x0;
|
|
|
+ y = y - y0;
|
|
|
+ mfendx = x;
|
|
|
+ mfendy = y;
|
|
|
+ mbsetend = true;
|
|
|
+
|
|
|
+// emit signalSetDstPos(x,y);
|
|
|
+
|
|
|
+// mmutexmap.lock();
|
|
|
+// mvectormap.clear();
|
|
|
+// int i;
|
|
|
+// for(i=0;i<nPointSize;i++)
|
|
|
+// {
|
|
|
+// mvectormap.push_back(pmap[i]);
|
|
|
+// }
|
|
|
+// mmutexmap.unlock();
|
|
|
+
|
|
|
+// emit signalUpdateTraceMap();
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|