Explorar o código

change driver_radar_4d_ars548, add modulecomm. add view_radar4d_3d, use modulecomm show radar4d data in 3d.

yuchuli hai 9 meses
pai
achega
941a20ebc3

+ 10 - 4
src/driver/driver_radar_4d_ars548/ars548recv.cpp

@@ -3,8 +3,13 @@
 #include <string>
 #include <memory>
 
-ars548recv::ars548recv()
+ars548recv::ars548recv(const char * strethip ,const char * strcastip ,const unsigned nport)
 {
+
+    strncpy(mstrethip,strethip,256);
+    strncpy(mstrcastip,strcastip,256);
+    mnport = nport;
+
     InitSock();
 
     std::thread * pthread = new std::thread(&ars548recv::threadrecv,this);
@@ -23,9 +28,10 @@ ars548recv::~ars548recv()
 
 void ars548recv::InitSock()
 {
-     std::string mcast_ip("224.0.2.2");
-     uint16_t mcast_port = 42102;
-     const char * streth0ip = "192.168.1.11";
+     std::string mcast_ip(mstrcastip);
+     uint16_t mcast_port = mnport;
+     char streth0ip[256];
+     strncpy(streth0ip,mstrethip,256);
 
 
      notify_fd_ = socket(AF_INET, SOCK_DGRAM, 0);

+ 8 - 2
src/driver/driver_radar_4d_ars548/ars548recv.h

@@ -35,8 +35,8 @@ struct ars548recv_pac
 class ars548recv
 {
 public:
-    ars548recv();
-    void InitSock();
+    ars548recv(const char * strethip = "192.168.1.11",const char * strcastip = "224.0.2.2",const unsigned nport = 42102);
+
 
     ~ars548recv();
 
@@ -48,6 +48,12 @@ private:
     std::mutex mmutexcv;
     std::condition_variable mcv;
 
+    void InitSock();
+
+    char mstrethip[256];
+    char mstrcastip[256];
+    unsigned short mnport;
+
 private:
     bool mbRun = false;
 

+ 6 - 1
src/driver/driver_radar_4d_ars548/driver_radar_4d_ars548.pro

@@ -12,6 +12,7 @@ SOURCES += \
         ../../include/msgtype/radar4dobject.pb.cc \
         ../../include/msgtype/radar4dobjectarray.pb.cc \
         ar548pac.cpp \
+        ars548recv.cpp \
         main.cpp
 
 # Default rules for deployment.
@@ -24,8 +25,12 @@ HEADERS += \
     ../../include/msgtype/radar4ddetectarray.pb.h \
     ../../include/msgtype/radar4dobject.pb.h \
     ../../include/msgtype/radar4dobjectarray.pb.h \
-    ar548pac.h
+    ar548pac.h \
+    ars548recv.h
 
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
 
 !include(../../../include/ivprotobuf.pri ) {
     error( "Couldn't find the ivprotobuf.pri file!" )

+ 8 - 0
src/driver/driver_radar_4d_ars548/driver_radar_4d_ars548.xml

@@ -0,0 +1,8 @@
+<xml>	
+	<node name="driver_radar_4d_ars548">
+		<param name="ethip" value="192.168.1.11" />
+		<param name="multicastip" value="224.0.2.2" />
+		<param name="port" value="42102" />
+		<param name="outdebug" value="false" />
+	</node>
+</xml>

+ 129 - 0
src/driver/driver_radar_4d_ars548/main.cpp

@@ -1,8 +1,137 @@
 #include <QCoreApplication>
+#include <thread>
+#include <memory>
+
+#include "ars548recv.h"
+
+#include <google/protobuf/port_def.inc>
+#if PROTOBUF_VERSION > 3000000
+    #define PROTOBUF_300
+#endif
+#include <google/protobuf/port_undef.inc>
+#include "modulecomm.h"
+
+
+#include "xmlparam.h"
+
+static ars548recv * gprecv;
+
+static void * gpadet;
+static void * gpaobj;
+
+static std::thread * gpthreaddet;
+static std::thread * gpthreadobj;
+
+static bool  mbthreadrun = true;
+
+static std::string gstrethip;
+static std::string gstrmulticastip;
+static int gnport;
+bool gboutdebug = false;
+
+void threaddet()
+{
+    int nnodata = 0;
+    while(mbthreadrun)
+    {
+        iv::radar::radar4ddetectarray xdetarray;
+        if(gprecv->GetDetect(10,xdetarray) == 1){
+#ifdef PROTOBUF_300
+            int nsize = static_cast<int>(xdetarray.ByteSizeLong());
+#else
+            int nsize = xdetarray.ByteSize();
+#endif
+            std::shared_ptr<char> pstr_data = std::shared_ptr<char>(new char[nsize]);
+            if(xdetarray.SerializeToArray(pstr_data.get(),nsize))
+            {
+                iv::modulecomm::ModuleSendMsg(gpadet,pstr_data.get(),nsize);
+                if(gboutdebug)std::cout<<" time: "<<std::chrono::system_clock::now().time_since_epoch().count()<<" share det msg. size: "<<nsize<<std::endl;
+            }
+            else
+            {
+                std::cout<<" detarray serialize fail."<<std::endl;
+            }
+            nnodata = 0;
+
+        }
+        else{
+            nnodata++;
+            if(nnodata>=100){
+                nnodata = 0;
+                std::cout<<" time: "<<std::chrono::system_clock::now().time_since_epoch().count()<<" last 1 seconds no detect data. Please check config. "<<std::endl;
+            }
+
+        }
+    }
+}
+
+void threadobj()
+{
+    int nnodata = 0;
+    while(mbthreadrun)
+    {
+        iv::radar::radar4dobjectarray xobjarray;
+        if(gprecv->GetObj(10,xobjarray) == 1)
+        {
+#ifdef PROTOBUF_300
+            int nsize = static_cast<int>(xobjarray.ByteSizeLong());
+#else
+            int nsize = xobjarray.ByteSize();
+#endif
+            std::shared_ptr<char> pstr_data = std::shared_ptr<char>(new char[nsize]);
+            if(xobjarray.SerializeToArray(pstr_data.get(),nsize))
+            {
+                iv::modulecomm::ModuleSendMsg(gpaobj,pstr_data.get(),nsize);
+                if(gboutdebug)std::cout<<" time: "<<std::chrono::system_clock::now().time_since_epoch().count()<<" share obj msg. size: "<<nsize<<std::endl;
+            }
+            else
+            {
+                std::cout<<" objarray serialize fail."<<std::endl;
+            }
+            nnodata = 0;
+
+        }
+        else{
+            nnodata++;
+            if(nnodata>=100){
+                nnodata = 0;
+                std::cout<<" time: "<<std::chrono::system_clock::now().time_since_epoch().count()<<" last 1 seconds no object data. Please check config."<<std::endl;
+            }
+
+        }
+    }
+}
+
+
+void LoadXML(const char * strxmlpath)
+{
+    iv::xmlparam::Xmlparam xp(strxmlpath);
+    gstrethip = xp.GetParam("ethip","192.168.1.11");
+    gstrmulticastip = xp.GetParam("multicastip","224.0.2.2");
+    gnport = xp.GetParam("port",42102);
+    gboutdebug = xp.GetParam("outdebug",false);
+}
 
 int main(int argc, char *argv[])
 {
     QCoreApplication a(argc, argv);
 
+    if(argc <2)
+    {
+        LoadXML("driver_radar_4d_ars548.xml");
+    }
+    else
+        LoadXML(argv[1]);
+
+    gpadet = iv::modulecomm::RegisterSend("radar4ddet",100000,1);
+    gpaobj = iv::modulecomm::RegisterSend("radar4dobj",100000,1);
+
+    gprecv = new ars548recv(gstrethip.data(),gstrmulticastip.data(),(unsigned short)gnport);
+
+    gpthreaddet = new std::thread(&threaddet);
+    gpthreadobj = new std::thread(&threadobj);
+
+
+
     return a.exec();
 }

+ 73 - 0
src/tool/view_radar4d_3d/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

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

+ 606 - 0
src/tool/view_radar4d_3d/mainwindow.cpp

@@ -0,0 +1,606 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <iostream>
+
+#include <QFileDialog>
+#include <QTimer>
+
+#include <functional>
+
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+
+    ui->actionNoClassification->setChecked(true);
+    ui->actionNoise->setChecked(true);
+    ui->actionGround->setChecked(true);
+    ui->actionTraversableUnder->setChecked(true);
+    ui->actionObstacle->setChecked(true);
+    ui->actionInvalid->setChecked(true);
+
+    ui->actionCar->setChecked(true);
+    ui->actionTruck->setChecked(true);
+    ui->actionMotorcycle->setChecked(true);
+    ui->actionBicycle->setChecked(true);
+    ui->actionPedestrian->setChecked(true);
+    ui->actionAnimal->setChecked(true);
+    ui->actionHazard->setChecked(true);
+    ui->actionUnknown->setChecked(true);
+
+    vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
+    vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
+    renderWindow->AddRenderer(renderer);
+    view.reset(new pcl::visualization::PCLVisualizer(renderer,renderWindow,"viewer",false));
+
+
+
+#if VTK890
+    view->setupInteractor(ui->vtk->interactor(),ui->vtk->renderWindow());
+#else
+    view->setupInteractor(ui->vtk->GetInteractor(),ui->vtk->GetRenderWindow());
+#endif
+
+#if VTK890
+  this->ui->vtk->setRenderWindow(renderWindow);
+#else
+  this->ui->vtk->SetRenderWindow(renderWindow);
+#endif
+
+    DrawAxis();
+
+    // Create a sphere.
+
+    int i;
+    for(i=0;i<NUM_DET_MAX;i++){
+      detSource[i]->SetBounds(-0.001,-0.001,-0.001,0.001,0.001,0.001);
+      detSource[i]->Update();
+
+      detmapper[i]->SetInputData(detSource[i]->GetOutput());
+
+      // Create an actor.
+      vtkNew<vtkActor> actor;
+      vtkNew<vtkNamedColors> colors;
+      actor->GetProperty()->SetColor(colors->GetColor3d("Yellow").GetData());
+      actor->SetMapper(detmapper[i]);
+
+      renderer->AddActor(actor);
+     }
+
+    for(i=0;i<NUM_OBJ_MAX;i++){
+      sphereSource[i]->SetCenter(0,0,0);
+      sphereSource[i]->SetRadius(0.001);
+      sphereSource[i]->Update();
+
+      mapper[i]->SetInputData(sphereSource[i]->GetOutput());
+
+      // Create an actor.
+      vtkNew<vtkActor> actor;
+      vtkNew<vtkNamedColors> colors;
+      actor->GetProperty()->SetColor(colors->GetColor3d("Red").GetData());
+      actor->SetMapper(mapper[i]);
+
+      renderer->AddActor(actor);
+     }
+
+    QTimer * timer1 = new QTimer();
+    connect(timer1,SIGNAL(timeout()),this,SLOT(onTimer()));
+//    timer1->start(100);
+
+    connect(this,SIGNAL(detupdate()),this,SLOT(onDetUpdate()));
+
+#ifdef USE_MODULECOMM
+    ModuleFun fundetect = std::bind(&MainWindow::UpdateDet,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpadet = iv::modulecomm::RegisterRecvPlus("radar4ddet",fundetect);
+    ModuleFun funojbect = std::bind(&MainWindow::UpdateObj,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    mpaobj = iv::modulecomm::RegisterRecvPlus("radar4dobj",funojbect);
+#else
+    mprecv = new ars548recv();
+    mpthreaddet =  new std::thread(&MainWindow::threaddet,this);
+    mpthreadobj =  new std::thread(&MainWindow::threadobj,this);
+#endif
+
+    setWindowTitle("radar4d 3d Viewer");
+
+}
+
+MainWindow::~MainWindow()
+{
+    mbThreadRun = false;
+#ifdef USE_MODULECOMM
+    iv::modulecomm::Unregister(mpaobj);
+    iv::modulecomm::Unregister(mpadet);
+#else
+    mpthreadobj->join();
+    mpthreaddet->join();
+    delete mprecv;
+#endif
+    delete ui;
+}
+
+void MainWindow::DrawAxis()
+{
+
+    bool bGrid = false;
+
+    pcl::PointXYZ p1(-300,0,0);
+    pcl::PointXYZ p2(300,0,0);
+    view->addLine(p1,p2,1.0f,1.0f,1.0f,"axis_x");
+
+    p1.x = 0;p1.y = -300;
+    p2.x=  0;p2.y = 300;
+    view->addLine(p1,p2,1.0f,1.0f,1.0f,"axis_y");
+
+    int i;
+
+    if(bGrid)
+    {
+        for(i=-30;i<=30;i++)
+        {
+            if(i==0)continue;
+            p1.x = -300;p1.y = i*10;
+            p2.x = 300; p2.y = i*10;
+            char strname[256];
+            snprintf(strname,256,"axisgx_%d",i);
+            view->addLine(p1,p2,1.0f,1.0f,1.0f,strname);
+
+
+            p1.x = i*10;p1.y = -300;
+            p2.x = i*10; p2.y = 300;
+            snprintf(strname,256,"axisgy_%d",i);
+            view->addLine(p1,p2,1.0f,1.0f,1.0f,strname);
+        }
+    }
+    else
+    {
+        for(i=-30;i<=30;i++)
+        {
+            if(i==0)continue;
+            p1.x = 0;p1.y = i*10;
+            p2.x = 1; p2.y = i*10;
+            char strname[256];
+            snprintf(strname,256,"axisgx_%d",i);
+            view->addLine(p1,p2,1.0f,1.0f,1.0f,strname);
+
+
+            p1.x = i*10;p1.y = 0;
+            p2.x = i*10; p2.y = 1;
+            snprintf(strname,256,"axisgy_%d",i);
+            view->addLine(p1,p2,1.0f,1.0f,1.0f,strname);
+        }
+    }
+
+
+
+
+    for(i=-6;i<=6;i++)
+    {
+        char strname[256];
+        char strtext[256];
+        double orientation[3];
+        orientation[0] = 1.0;orientation[1] = 0.0;orientation[2] = 0.0;
+        p1.x = i*50;p1.y = 1;
+        snprintf(strname,256,"textx_%d",i);
+        snprintf(strtext,256,"%d",i*50);
+        if(i%2 == 0)
+            view->addText3D(strtext,p1,orientation,1.0,1.0,1.0,1.0,strname);
+        else
+            view->addText3D(strtext,p1,orientation,0.5,1.0,1.0,1.0,strname);
+
+        if(i== 0)continue;
+
+        orientation[0] = 1.0;orientation[1] =0.0;orientation[2] = 0.0;
+        p1.x = 1;p1.y = i*50+1;
+        snprintf(strname,256,"texty_%d",i);
+        snprintf(strtext,256,"%d",i*50);
+        if(i%2 == 0)
+            view->addText3D(strtext,p1,orientation,1.0,1.0,1.0,1.0,strname);
+        else
+            view->addText3D(strtext,p1,orientation,0.5,1.0,1.0,1.0,strname);
+    }
+
+//    double base_size = 0.2;
+//    double base_height = 0.2;
+//    double sigx = 15;
+//    double sigy = 15;
+//    double sigz = 1.0;
+//    view->addCube(sigx-base_size/2.0,sigx + base_size/2.0,sigy-base_size/2.0,sigy+base_size/2.0,sigz-base_height/2.0,sigz + base_height/2.0,1.0,0.0,0.0,"cube1");
+
+    view->setCameraPosition(0,0,100,0,0,0,0,1,0);
+    view->resetCamera();    //视角
+//    view->addText("300",300,5,10,1.0f,0.0f,0.0f,"txt1");
+
+
+}
+
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+
+    (void)event;
+    QSize sizemain = ui->centralwidget->size();
+
+    ui->vtk->setGeometry(0,0,sizemain.width()-0,sizemain.height()-0);
+
+
+
+}
+
+
+void MainWindow::onTimer()
+{
+
+    int64_t nstart = std::chrono::system_clock::now().time_since_epoch().count();
+    static bool bSetCam = false;
+    if(bSetCam == false)
+    {
+        bSetCam = true;
+        view->setCameraPosition(0,30,130,0,30,0,0,1,0);
+//        view->resetCamera();    //视角
+    }
+    static int nindex = 0;
+    nindex++;
+    if(nindex>1000)nindex = 0;
+    double base_size = 0.5;
+    double base_height = 0.5;
+    double sigx = 15;
+    double sigy = 15 + nindex * 0.01;
+    double sigz = 1.0;
+    (void)base_size;
+    (void)base_height;
+    (void)sigx;
+    (void)sigz;
+//    view->removeShape("cube1");
+//    view->addCube(sigx-base_size/2.0,sigx + base_size/2.0,sigy-base_size/2.0,sigy+base_size/2.0,sigz-base_height/2.0,sigz + base_height/2.0,1.0,0.0,0.0,"cube1");
+
+
+
+    int i;
+    for(i=0;i<100;i++){
+    sphereSource[i]->SetCenter(i, sigy, 0.0);
+    sphereSource[i]->Update();
+    }
+
+
+    // Create a mapper.
+
+//    mapper->SetInputData(sphereSource->GetOutput());
+
+#if VTK890
+    ui->vtk->renderWindow()->Render();
+#else
+    ui->vtk->GetRenderWindow()->Render();
+#endif
+
+    int64_t nend = std::chrono::system_clock::now().time_since_epoch().count();
+    std::cout<<" update use : "<<(nend -nstart)/1e6<<std::endl;
+}
+
+void MainWindow::onDetUpdate()
+{
+    static int64_t nlastup = 0;
+
+    int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
+    int64_t ndiff = (nnow - nlastup)/1e6;
+    if(abs(ndiff)<10)
+    {
+//        nlastup = nnow;
+        return;
+    }
+
+    bool bdetupdate = false;
+    bool bobjupdate = false;
+
+    int64_t nstart = std::chrono::system_clock::now().time_since_epoch().count();
+    iv::radar::radar4ddetectarray xdetarray;
+    mmutexdet.lock();
+    if(mbdetupdate){
+        xdetarray.CopyFrom(mdetarray);
+        mbdetupdate = false;
+        bdetupdate = true;
+    }
+    mmutexdet.unlock();
+
+    iv::radar::radar4dobjectarray xobjarray;
+    mmutexobj.lock();
+    if(mbobjupdate){
+        xobjarray.CopyFrom(mobjarray);
+        mbobjupdate = false;
+        bobjupdate = true;
+    }
+    mmutexobj.unlock();
+
+//    static int nskip = 0;
+//    nskip++;
+//    if(nskip <2)
+//    {
+//        return;
+//    }
+//    nskip = 0;
+
+
+
+    static bool bSetCam = false;
+    if(bSetCam == false)
+    {
+        bSetCam = true;
+        view->setCameraPosition(0,30,130,0,30,0,0,1,0);
+//        view->resetCamera();    //视角
+    }
+
+    int i;
+
+
+
+
+    double base_size = 0.2;
+    double obj_size = 0.5;
+    double sigx = 15;
+    double sigy = 15 ;
+    double sigz = 1.0;
+    int nsize;
+
+    if(bdetupdate){
+        nsize = static_cast<int>(xdetarray.mdet_size());
+
+        if(nsize > NUM_DET_MAX){
+            nsize = NUM_DET_MAX;
+        }
+
+        for(i=0;i<nsize;i++)
+        {
+            iv::radar::radar4ddetect * pdet = xdetarray.mutable_mdet(i);
+
+
+            if((pdet->detection_radial_distance()<0.001) || (pdet->detection_classification() != iv::radar::radar4ddetect::Obstacle))
+            {
+                detSource[i]->SetBounds(1000.0,1000.1,-0.001,0.001,0.001,0.001);
+                detSource[i]->Update();
+                continue;
+            }
+            bool bshow = false;
+            if(ui->actionAll->isChecked())bshow = true;
+            if((ui->actionNoClassification->isChecked())&&(pdet->detection_classification() == iv::radar::radar4ddetect::NoClassification))bshow = true;
+            if((ui->actionNoise->isChecked())&&(pdet->detection_classification() == iv::radar::radar4ddetect::Noise))bshow = true;
+            if((ui->actionGround->isChecked())&&(pdet->detection_classification() == iv::radar::radar4ddetect::Ground))bshow = true;
+            if((ui->actionTraversableUnder->isChecked())&&(pdet->detection_classification() == iv::radar::radar4ddetect::TraversableUnder))bshow = true;
+            if((ui->actionObstacle->isChecked())&&(pdet->detection_classification() == iv::radar::radar4ddetect::Obstacle))bshow = true;
+            if((ui->actionInvalid->isChecked())&&(pdet->detection_classification() == iv::radar::radar4ddetect::Invalid))bshow = true;
+            if(bshow == true){
+                sigx = pdet->detection_radial_distance() * cos(pdet->unaligned_detection_elevation_angle()) * cos(pdet->unaligned_detection_azimuth_angle() + M_PI/2.0);
+                sigy = pdet->detection_radial_distance() * cos(pdet->unaligned_detection_elevation_angle()) * sin(pdet->unaligned_detection_azimuth_angle() + M_PI/2.0);
+                sigz = pdet->detection_radial_distance() * sin(pdet->unaligned_detection_elevation_angle());
+                detSource[i]->SetBounds(sigx-base_size/2.0,sigx+base_size/2.0,sigy - base_size/2.0,sigy + base_size/2.0, sigz - base_size/2.0,
+                                        sigz + base_size/2.0);
+                detSource[i]->Update();
+            }
+            else {
+                detSource[i]->SetBounds(1000.0,1000.1,-0.001,0.001,0.001,0.001);
+                detSource[i]->Update();
+            }
+        }
+    }
+
+    if(bobjupdate){
+        nsize = static_cast<int>(xobjarray.mobj_size());
+
+        if(nsize > NUM_OBJ_MAX){
+            nsize = NUM_OBJ_MAX;
+        }
+
+        for(i=0;i<nsize;i++)
+        {
+            iv::radar::radar4dobject * pobj = xobjarray.mutable_mobj(i);
+
+//            std::cout<<" i: "<<i<<" unkown: "<<pobj->u_classification_unknown()<<" car: "<<pobj->u_classification_car()
+//                       <<" truck: "<<pobj->u_classification_truck()
+//                         <<" motocycle: "<<pobj->u_classification_motorcycle()
+//                           <<" bycycle: "<<pobj->u_classification_bicycle()
+//                             <<" ped: "<<pobj->u_classification_pedestrian()
+//                     <<" animal: "<<pobj->u_classification_animal()
+//                     <<" hazard: "<<pobj->u_classification_hazard()
+//                    <<"exist: "<<pobj->u_existence_probability()<<std::endl;
+            sigx = pobj->u_position_y() * (-1);
+            sigy = pobj->u_position_x();
+            sigz = pobj->u_position_z();
+            bool bShow = false;
+            unsigned int nMinProb = 30;
+            if(ui->actionObjectAll->isChecked())bShow = true;
+            if((ui->actionCar->isChecked())&&(pobj->u_classification_car()>=nMinProb))bShow = true;
+            if((ui->actionTruck->isChecked())&&(pobj->u_classification_truck()>=nMinProb))bShow = true;
+            if((ui->actionMotorcycle->isChecked())&&(pobj->u_classification_motorcycle()>=nMinProb))bShow = true;
+            if((ui->actionBicycle->isChecked())&&(pobj->u_classification_bicycle()>=nMinProb))bShow = true;
+            if((ui->actionPedestrian->isChecked())&&(pobj->u_classification_pedestrian()>=nMinProb))bShow = true;
+            if((ui->actionAnimal->isChecked())&&(pobj->u_classification_animal()>=nMinProb))bShow = true;
+            if((ui->actionHazard->isChecked())&&(pobj->u_classification_hazard()>=nMinProb))bShow = true;
+            if((ui->actionUnknown->isChecked())&&(pobj->u_classification_unknown()>=nMinProb))bShow = true;
+            if((pobj->u_existence_probability() >0)&&bShow){
+
+                sphereSource[i]->SetCenter(sigx,sigy,sigz);
+                sphereSource[i]->SetRadius(obj_size/2.0);
+            }
+            else{
+                sphereSource[i]->SetCenter(0.0,0.0,0.0);
+                sphereSource[i]->SetRadius(0.001);
+            }
+
+            sphereSource[i]->Update();
+        }
+    }
+
+
+//    std::cout<<"update det."<<std::endl;
+
+#if VTK890
+    ui->vtk->renderWindow()->Render();
+#else
+    ui->vtk->GetRenderWindow()->Render();
+#endif
+
+    int64_t nend = std::chrono::system_clock::now().time_since_epoch().count();
+
+    int64_t nuse = nend- nstart;
+    std::cout<<" draw use : "<<nuse/1e6<<std::endl;
+
+
+    nlastup = std::chrono::system_clock::now().time_since_epoch().count();
+
+}
+
+void MainWindow::on_actionReset_Camera_triggered()
+{
+    view->setCameraPosition(0,0,100,0,0,0,0,1,0);
+    view->resetCamera();    //视角
+}
+
+
+void MainWindow::on_actionFull_Screem_triggered()
+{
+    showFullScreen();
+    ui->menubar->setVisible(false);
+    ui->statusbar->setVisible(false);
+    ui->toolBar->setVisible(false);
+    mbFull = true;
+}
+
+
+void MainWindow::keyReleaseEvent(QKeyEvent *event)
+{
+    if((event->key() == Qt::Key_Escape)||(event->key() == Qt::Key_F11))
+    {
+        if(mbFull)
+        {
+            showNormal();
+            ui->menubar->setVisible(true);
+            ui->statusbar->setVisible(true);
+            ui->toolBar->setVisible(true);
+            mbFull = false;
+        }
+    }
+}
+
+
+#ifdef USE_MODULECOMM
+void MainWindow::UpdateDet(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    (void)index;
+    (void)dt;
+    (void)strmemname;
+    iv::radar::radar4ddetectarray xdetarray;
+    if(xdetarray.ParseFromArray(strdata,(int)nSize))
+    {
+        mmutexdet.lock();
+        mdetarray.CopyFrom(xdetarray);
+        mbdetupdate = true;
+        mmutexdet.unlock();
+        emit detupdate();
+    }
+    else
+    {
+        std::cout<<"detection parse fail."<<std::endl;
+    }
+}
+
+void MainWindow::UpdateObj(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+    (void)index;
+    (void)dt;
+    (void)strmemname;
+    iv::radar::radar4dobjectarray xobjarray;
+    if(xobjarray.ParseFromArray(strdata,(int)nSize))
+    {
+        mmutexobj.lock();
+        mobjarray.CopyFrom(xobjarray);
+        mbobjupdate = true;
+        mmutexobj.unlock();
+        emit detupdate();
+    }
+    else
+    {
+        std::cout<<"object parse fail."<<std::endl;
+    }
+}
+#else
+void MainWindow::threaddet()
+{
+    while(mbThreadRun)
+    {
+        iv::radar::radar4ddetectarray xdetarray;
+        if(mprecv->GetDetect(10,xdetarray) == 1)
+        {
+            mmutexdet.lock();
+            mdetarray.CopyFrom(xdetarray);
+            mbdetupdate = true;
+            mmutexdet.unlock();
+            emit detupdate();
+        }
+    }
+}
+
+void MainWindow::threadobj()
+{
+    while(mbThreadRun)
+    {
+        iv::radar::radar4dobjectarray xobjarray;
+        if(mprecv->GetObj(10,xobjarray) == 1)
+        {
+            mmutexobj.lock();
+            mobjarray.CopyFrom(xobjarray);
+            mbobjupdate = true;
+            mmutexobj.unlock();
+            emit detupdate();
+        }
+    }
+}
+#endif
+
+
+
+void MainWindow::on_actionAll_triggered()
+{
+    if(ui->actionAll->isChecked()){
+        ui->actionNoClassification->setChecked(true);
+        ui->actionNoise->setChecked(true);
+        ui->actionGround->setChecked(true);
+        ui->actionTraversableUnder->setChecked(true);
+        ui->actionObstacle->setChecked(true);
+        ui->actionInvalid->setChecked(true);
+    }
+    else
+    {
+        ui->actionNoClassification->setChecked(false);
+        ui->actionNoise->setChecked(false);
+        ui->actionGround->setChecked(false);
+        ui->actionTraversableUnder->setChecked(false);
+        ui->actionObstacle->setChecked(false);
+        ui->actionInvalid->setChecked(false);
+    }
+}
+
+
+void MainWindow::on_actionObjectAll_triggered()
+{
+    if(ui->actionObjectAll->isChecked()){
+        ui->actionCar->setChecked(true);
+        ui->actionTruck->setChecked(true);
+        ui->actionMotorcycle->setChecked(true);
+        ui->actionBicycle->setChecked(true);
+        ui->actionPedestrian->setChecked(true);
+        ui->actionAnimal->setChecked(true);
+        ui->actionHazard->setChecked(true);
+        ui->actionUnknown->setChecked(true);
+    }
+    else{
+        ui->actionCar->setChecked(false);
+        ui->actionTruck->setChecked(false);
+        ui->actionMotorcycle->setChecked(false);
+        ui->actionBicycle->setChecked(false);
+        ui->actionPedestrian->setChecked(false);
+        ui->actionAnimal->setChecked(false);
+        ui->actionHazard->setChecked(false);
+        ui->actionUnknown->setChecked(false);
+    }
+}
+

+ 140 - 0
src/tool/view_radar4d_3d/mainwindow.h

@@ -0,0 +1,140 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+
+
+#include <vtkActor.h>
+#include <vtkGenericOpenGLRenderWindow.h>
+#include <vtkLookupTable.h>
+#include <vtkNamedColors.h>
+#include <vtkNew.h>
+#include <vtkPlatonicSolidSource.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderer.h>
+#include <vtkVersion.h>
+
+
+#include <QSurfaceFormat>
+#include <QVTKOpenGLNativeWidget.h>
+
+
+#include <pcl/visualization/pcl_visualizer.h>
+#include <pcl/point_types.h>//各种格式的点的头文件
+#include <pcl/io/pcd_io.h>
+#include  <QKeyEvent>
+
+#ifdef USE_MODULECOMM
+
+#include <mutex>
+#include <condition_variable>
+#include "radar4ddetectarray.pb.h"
+#include "radar4dobjectarray.pb.h"
+#include "modulecomm.h"
+
+
+#else
+#include "ars548recv.h"
+
+#endif
+
+#include "vtkCubeSource.h"
+
+#if VTK_VERSION_NUMBER >= 89000000000ULL
+#define VTK890 1
+#endif
+
+
+#define NUM_DET_MAX 800
+#define NUM_OBJ_MAX 50
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+}
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+public:
+     void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
+     void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
+
+signals:
+     void detupdate();
+
+private slots:
+
+    void onTimer();
+
+    void on_actionReset_Camera_triggered();
+
+    void on_actionFull_Screem_triggered();
+
+    void onDetUpdate();
+
+    void on_actionAll_triggered();
+
+    void on_actionObjectAll_triggered();
+
+private:
+    Ui::MainWindow *ui;
+
+    boost::shared_ptr< pcl::visualization::PCLVisualizer > view;
+
+    void DrawAxis();
+
+    bool mbFull = false;
+
+    bool mbThreadRun = true;
+
+
+
+private:
+
+#ifdef USE_MODULECOMM
+    void * mpadet;
+    void * mpaobj;
+
+    void UpdateDet(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+    void UpdateObj(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
+
+
+
+#else
+    ars548recv * mprecv;
+    void threaddet();
+    void threadobj();
+
+    std::thread * mpthreaddet;
+    std::thread * mpthreadobj;
+
+#endif
+
+
+    iv::radar::radar4ddetectarray mdetarray;
+    std::mutex mmutexdet;
+    bool mbdetupdate = false;
+    iv::radar::radar4dobjectarray mobjarray;
+    bool mbobjupdate = false;
+    std::mutex mmutexobj;
+
+    std::vector<std::string> mvectordetname;
+
+    vtkNew<vtkSphereSource> sphereSource[NUM_OBJ_MAX];
+    vtkNew<vtkPolyDataMapper> mapper[NUM_OBJ_MAX];
+
+    vtkNew<vtkCubeSource> detSource[NUM_DET_MAX];
+    vtkNew<vtkPolyDataMapper> detmapper[NUM_DET_MAX];
+
+};
+#endif // MAINWINDOW_H

+ 244 - 0
src/tool/view_radar4d_3d/mainwindow.ui

@@ -0,0 +1,244 @@
+<?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>1280</width>
+    <height>800</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QVTKOpenGLNativeWidget" name="vtk">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>30</y>
+      <width>531</width>
+      <height>391</height>
+     </rect>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>1280</width>
+     <height>22</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="menuView">
+    <property name="title">
+     <string>View</string>
+    </property>
+    <addaction name="actionFull_Screem"/>
+    <addaction name="actionReset_Camera"/>
+   </widget>
+   <widget class="QMenu" name="menuDetect">
+    <property name="title">
+     <string>Detect</string>
+    </property>
+    <addaction name="actionAll"/>
+    <addaction name="separator"/>
+    <addaction name="separator"/>
+    <addaction name="actionNoClassification"/>
+    <addaction name="actionNoise"/>
+    <addaction name="actionGround"/>
+    <addaction name="actionTraversableUnder"/>
+    <addaction name="actionObstacle"/>
+    <addaction name="actionInvalid"/>
+   </widget>
+   <widget class="QMenu" name="menuObject">
+    <property name="title">
+     <string>Object</string>
+    </property>
+    <addaction name="actionObjectAll"/>
+    <addaction name="separator"/>
+    <addaction name="separator"/>
+    <addaction name="actionCar"/>
+    <addaction name="actionTruck"/>
+    <addaction name="actionMotorcycle"/>
+    <addaction name="actionBicycle"/>
+    <addaction name="actionPedestrian"/>
+    <addaction name="actionAnimal"/>
+    <addaction name="actionHazard"/>
+    <addaction name="actionUnknown"/>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuView"/>
+   <addaction name="menuDetect"/>
+   <addaction name="menuObject"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <widget class="QToolBar" name="toolBar">
+   <property name="windowTitle">
+    <string>toolBar</string>
+   </property>
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <action name="actionFull_Screem">
+   <property name="text">
+    <string>Full Screem</string>
+   </property>
+  </action>
+  <action name="actionReset_Camera">
+   <property name="text">
+    <string>Reset Camera</string>
+   </property>
+  </action>
+  <action name="actionAll">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>All</string>
+   </property>
+  </action>
+  <action name="actionNoClassification">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>NoClassification</string>
+   </property>
+  </action>
+  <action name="actionNoise">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Noise</string>
+   </property>
+  </action>
+  <action name="actionGround">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Ground</string>
+   </property>
+  </action>
+  <action name="actionTraversableUnder">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>TraversableUnder</string>
+   </property>
+  </action>
+  <action name="actionObstacle">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Obstacle</string>
+   </property>
+  </action>
+  <action name="actionInvalid">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Invalid</string>
+   </property>
+  </action>
+  <action name="actionObjectAll">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>All</string>
+   </property>
+  </action>
+  <action name="actionCar">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Car</string>
+   </property>
+  </action>
+  <action name="actionTruck">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Truck</string>
+   </property>
+  </action>
+  <action name="actionMotorcycle">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Motorcycle</string>
+   </property>
+  </action>
+  <action name="actionBicycle">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Bicycle</string>
+   </property>
+  </action>
+  <action name="actionPedestrian">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Pedestrian</string>
+   </property>
+  </action>
+  <action name="actionAnimal">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Animal</string>
+   </property>
+  </action>
+  <action name="actionHazard">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Hazard</string>
+   </property>
+  </action>
+  <action name="actionUnknown">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Unknown</string>
+   </property>
+  </action>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QVTKOpenGLNativeWidget</class>
+   <extends>QOpenGLWidget</extends>
+   <header location="global">QVTKOpenGLNativeWidget.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 74 - 0
src/tool/view_radar4d_3d/view_radar4d_3d.pro

@@ -0,0 +1,74 @@
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++1z
+
+DEFINES += USE_MODULECOMM
+
+# You can make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    ../../include/msgtype/radar4ddetect.pb.cc \
+    ../../include/msgtype/radar4ddetectarray.pb.cc \
+    ../../include/msgtype/radar4dobject.pb.cc \
+    ../../include/msgtype/radar4dobjectarray.pb.cc \
+    main.cpp \
+    mainwindow.cpp
+
+HEADERS += \
+    ../../include/msgtype/radar4ddetect.pb.h \
+    ../../include/msgtype/radar4ddetectarray.pb.h \
+    ../../include/msgtype/radar4dobject.pb.h \
+    ../../include/msgtype/radar4dobjectarray.pb.h \
+    mainwindow.h
+
+FORMS += \
+    mainwindow.ui
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+
+INCLUDEPATH += /usr/include/eigen3
+INCLUDEPATH += /usr/include/pcl-1.12
+INCLUDEPATH += /usr/include/vtk-9.1
+INCLUDEPATH += /usr/include/vtk-6.3
+INCLUDEPATH += /usr/include/vtk-7.1
+INCLUDEPATH += /usr/include/pcl-1.8
+INCLUDEPATH += /usr/include/pcl-1.10
+INCLUDEPATH += /usr/include/pcl-1.7
+
+
+!include(../../../include/common.pri ) {
+    error( "Couldn't find the common.pri file!" )
+}
+
+!include(../../../include/ivprotobuf.pri ) {
+    error( "Couldn't find the ivprotobuf.pri file!" )
+}
+
+unix:LIBS +=  -lpcl_common\
+        -lpcl_features\
+        -lpcl_filters\
+        -lpcl_io\
+        -lpcl_io_ply\
+        -lpcl_kdtree\
+        -lpcl_keypoints\
+        -lpcl_octree\
+        -lpcl_outofcore\
+        -lpcl_people\
+        -lpcl_recognition\
+        -lpcl_registration\
+        -lpcl_sample_consensus\
+        -lpcl_search\
+        -lpcl_segmentation\
+        -lpcl_surface\
+        -lpcl_tracking\
+        -lpcl_visualization
+
+LIBS += /usr/lib/aarch64-linux-gnu/libvtk*.so