Ver Fonte

Merge branch 'master' of http://192.168.14.36:3000/adc_pilot/modularization

yuchuli há 3 anos atrás
pai
commit
3589e0783a

+ 1 - 1
src/driver/driver_cloud_grpc_client_BS/driver_cloud_grpc_client_BS.yaml

@@ -4,7 +4,7 @@ patrol_port : 10592
 control_port : 20591
 
 uploadinterval : 500 //ms
-patrolinterval : 500
+patrolinterval : 1000
 controlinterval : 100
 uploadmapinterval : 1000
 

+ 13 - 57
src/driver/driver_cloud_grpc_client_BS/main.cpp

@@ -10,7 +10,6 @@
 #include <QFile>
 #include <QString>
 #include <QStringList>
-#include <QThread>
 
 std::string gstrserverip =  "139.9.235.66";//"123.57.212.138";
 std::string gstruploadPort = "10591";//"9000";
@@ -23,54 +22,6 @@ std::string gstruploadMapInterval = "500";
 std::string gstrid = "1234567890123456789H";
 std::string gstrplateNumber = "津A123456";
 
-//class mainloop : public QThread
-//{
-////    Q_OBJECT
-//public:
-//    mainloop(VehicleControlClient *pCC,DataExchangeClient *pUC);
-//    void run();
-//private:
-//    VehicleControlClient *pControlClient;
-//    DataExchangeClient *pUploadClient;
-//};
-
-//mainloop::mainloop(VehicleControlClient *pCC,DataExchangeClient *pUC)
-//{
-//    pControlClient = pCC;
-//    pUploadClient = pUC;
-//}
-
-//void mainloop::run()
-//{
-//    while (1) {
-////        msleep(100);
-//        if(pControlClient->get_isNeedMap() == true)
-//        {
-//            std::cout<<"patrol path calculating"<<std::endl;
-//            QFile mapfile("/home/samuel/Documents/path1.txt");
-//            QVector<org::jeecg::defsDetails::grpc::MapPoint> somePoints;
-//            if(mapfile.open(QIODevice::ReadOnly | QIODevice::Text))
-//            {
-//                while(!mapfile.atEnd())
-//                {
-//                    QByteArray line = mapfile.readLine();
-//                    QString map_str(line);
-//                    QStringList oneline = map_str.split(",");
-//                    org::jeecg::defsDetails::grpc::MapPoint onePoint;
-//                    onePoint.set_index(oneline.at(0).toInt());
-//                    onePoint.mutable_mappoint()->set_longitude(oneline.at(1).toDouble());
-//                    onePoint.mutable_mappoint()->set_latitude(oneline.at(2).toDouble());
-//                    onePoint.mutable_mappoint()->set_height(oneline.at(3).toDouble());
-//                    somePoints.append(onePoint);
-//                }
-//            }
-//            pUploadClient->updatePath(pControlClient->get_patrolPathID(),somePoints);
-//            pUploadClient->uploadPath();
-//            pControlClient->set_isNeedMap(false);
-//        }
-//    }
-//}
-
 void dec_yaml(const char * stryamlpath)
 {
 
@@ -81,7 +32,7 @@ void dec_yaml(const char * stryamlpath)
     }
     catch(...)
     {
-        qDebug("yaml file has some unknown code or load fail.");
+        qDebug("yaml file has some unknown characters or load fail.");
         return;
     }
 
@@ -155,17 +106,22 @@ int main(int argc, char *argv[])
     std::string upload_str = gstrserverip+":";
     upload_str = upload_str + gstruploadPort ;
 
-    DataExchangeClient *vehicleupload = new DataExchangeClient(grpc::CreateChannel(upload_str, grpc::InsecureChannelCredentials()));
+    DataExchangeClient *vehicleuploaddata = new DataExchangeClient(grpc::CreateChannel(upload_str, grpc::InsecureChannelCredentials()));
+    vehicleuploaddata->start();
 
+    VehicleChangeCtrlModeClient *vehiclechangectrlmode = new VehicleChangeCtrlModeClient(grpc::CreateChannel(control_str, grpc::InsecureChannelCredentials()));
     VehicleControlClient *vehiclecontrol = new VehicleControlClient(grpc::CreateChannel(control_str, grpc::InsecureChannelCredentials()));
+    QObject::connect(vehiclechangectrlmode,&VehicleChangeCtrlModeClient::ctrlMode_Changed,vehiclecontrol,&VehicleControlClient::ctrlMode_Changed_Slot);
+    vehiclechangectrlmode->start();
+    vehiclecontrol->start();
 
-    VehiclePatrolExceptionClient vehiclepatrol(grpc::CreateChannel(patrol_str, grpc::InsecureChannelCredentials()));
-
-    QObject::connect(vehiclecontrol,&VehicleControlClient::patrolPOI_Recieved,vehicleupload,&DataExchangeClient::patrolPOI_Recieved_Slot);
-    QObject::connect(vehicleupload,&DataExchangeClient::uploadPath_Finished,vehiclecontrol,&VehicleControlClient::uploadPath_Finished_Slot);
+    VehicleUploadMapClient *vehicleuploadmap = new VehicleUploadMapClient(grpc::CreateChannel(control_str, grpc::InsecureChannelCredentials()));
+    QObject::connect(vehicleuploadmap,&VehicleUploadMapClient::patrolPOI_Recieved,vehicleuploaddata,&DataExchangeClient::patrolPOI_Recieved_Slot);
+    QObject::connect(vehicleuploaddata,&DataExchangeClient::uploadPath_Finished,vehicleuploadmap,&VehicleUploadMapClient::uploadPath_Finished_Slot);
+    vehicleuploadmap->start();
 
-//    mainloop loop(vehiclecontrol,vehicleupload);
-//    loop.start();
+    VehiclePatrolExceptionClient vehiclepatrol(grpc::CreateChannel(patrol_str, grpc::InsecureChannelCredentials()));
+    vehiclepatrol.start();
 
     return a.exec();
 }

+ 127 - 89
src/driver/driver_cloud_grpc_client_BS/vehicle_control.cpp

@@ -17,20 +17,11 @@ using org::jeecg::defsControl::grpc::ShiftStatus;
 VehicleControlClient::VehicleControlClient(std::shared_ptr<Channel> channel)
 {
     stub_ = VehicleControl::NewStub(channel);
-
-    controlTimer = new QTimer();
-    connect(controlTimer,&QTimer::timeout,this,&VehicleControlClient::controlTimeout);
-    controlTimer->start(std::atoi(gstrcontrolInterval.c_str()));
-
-    uploadMapTimer = new QTimer();
-    connect(uploadMapTimer,&QTimer::timeout,this,&VehicleControlClient::uploadMapTimeout);
-    uploadMapTimer->start(std::atoi(gstruploadMapInterval.c_str()));
 }
 
 VehicleControlClient::~VehicleControlClient(void)
 {
-    delete controlTimer;
-    delete uploadMapTimer;
+
 }
 
 std::string VehicleControlClient::vehicleControl(void)
@@ -84,47 +75,78 @@ std::string VehicleControlClient::vehicleControl(void)
     }
 }
 
-std::string VehicleControlClient::uploadMap(void)
+void VehicleControlClient::updateControlData(void)
+{
+    std::cout<<"shift:"<<shiftCMD<<std::endl;
+    std::cout<<"steeringWheelAngle:"<<steeringWheelAngleCMD<<std::endl;
+    std::cout<<"throttle:"<<throttleCMD<<std::endl;
+    std::cout<<"brake:"<<brakeCMD<<std::endl;
+}
+
+void VehicleControlClient::run()
+{
+    QTime xTime;
+    xTime.start();
+    uint64_t lastTime = xTime.elapsed();
+    uint64_t interval = std::atoi(gstrcontrolInterval.c_str());
+    while (true)
+    {
+        if((xTime.elapsed() - lastTime)>=interval)
+        {
+            std::string reply = vehicleControl();
+        //    std::cout<< reply <<std::endl;
+            if(modeCMD == CtrlMode::CMD_REMOTE || modeCMD == CtrlMode::CMD_CLOUD_PLATFORM)
+            {
+                updateControlData();
+            }
+            lastTime = xTime.elapsed();
+        }
+    }
+}
+
+void VehicleControlClient::ctrlMode_Changed_Slot(org::jeecg::defsControl::grpc::CtrlMode ctrlMode)
+{
+    modeCMD = ctrlMode;
+}
+
+VehicleChangeCtrlModeClient::VehicleChangeCtrlModeClient(std::shared_ptr<Channel> channel)
+{
+    stub_ = VehicleControl::NewStub(channel);
+}
+
+VehicleChangeCtrlModeClient::~VehicleChangeCtrlModeClient(void)
+{
+
+}
+
+std::string VehicleChangeCtrlModeClient::changeCtrlMode(void)
 {
     // Data we are sending to the server.
     Empty request;
     request.set_id(gstrid);
 
     // Container for the data we expect from the server.
-    UploadMapReply reply;
+    CtrlModeReply reply;
 
     // Context for the client. It could be used to convey extra information to
-    // the server and/or tweak certain RPC behaviors.
+    // the server and/or tweastd::cout<<"shift:"<<shiftCMD<<std::endl;k certain RPC behaviors.
     ClientContext context;
     gpr_timespec timespec;
-    timespec.tv_sec = 2;
+    timespec.tv_sec = 1;
     timespec.tv_nsec = 0;
     timespec.clock_type = GPR_TIMESPAN;
     context.set_deadline(timespec);
 
     // The actual RPC.
-    Status status = stub_ -> UploadMap(&context,request,&reply);
+    Status status = stub_ -> changeCtrlMode(&context,request,&reply);
 
     // Act upon its status.
     if (status.ok()) {
         if(reply.id() == gstrid)
         {
-//            std::cout<<reply.id()<<std::endl;
-            isNeedMap = false;
-            patrolPathID = "noPath";
-            POIPoints.clear();
-
-            isNeedMap = reply.isneedmap();
-//            std::cout<<reply.isneedmap()<<std::endl;
-            patrolPathID = reply.patrolpathid();
-//            std::cout<<reply.patrolpathid()<<std::endl;
-            for(int i = 0;i < reply.mappoints_size();i++)
-            {
-                POIPoints.append(reply.mappoints(i));
-//                std::cout<<reply.mappoints(i).index()<<std::endl;
-            }
+            modeCMD = reply.modecmd();
         }
-        return "UploadMap RPC successed";
+        return "changeCtrlMode RPC successed";
     } else {
         std::cout << status.error_code() << ": " << status.error_message()
                   << std::endl;
@@ -132,38 +154,85 @@ std::string VehicleControlClient::uploadMap(void)
         {
             std::cout << "vehicleControl RPC connect timeout" << std::endl;
         }
-        return "UploadMap RPC failed";
+        return "changeCtrlMode RPC failed";
     }
 }
 
-std::string VehicleControlClient::changeCtrlMode(void)
+void VehicleChangeCtrlModeClient::updateCtrolMode(void)
+{
+//    std::cout<<"modeCMD:"<<modeCMD<<std::endl;
+    emit ctrlMode_Changed(modeCMD);
+}
+
+void VehicleChangeCtrlModeClient::run()
+{
+    QTime xTime;
+    xTime.start();
+    uint64_t lastTime = xTime.elapsed();
+    uint64_t interval = std::atoi(gstrcontrolInterval.c_str());
+    while (true)
+    {
+        if((xTime.elapsed() - lastTime)>=interval)
+        {
+            std::string reply = changeCtrlMode();
+        //    std::cout<< reply <<std::endl;
+            updateCtrolMode();
+            lastTime = xTime.elapsed();
+        }
+    }
+}
+
+VehicleUploadMapClient::VehicleUploadMapClient(std::shared_ptr<Channel> channel)
+{
+    stub_ = VehicleControl::NewStub(channel);
+}
+
+VehicleUploadMapClient::~VehicleUploadMapClient(void)
+{
+
+}
+
+std::string VehicleUploadMapClient::uploadMap(void)
 {
     // Data we are sending to the server.
     Empty request;
     request.set_id(gstrid);
 
     // Container for the data we expect from the server.
-    CtrlModeReply reply;
+    UploadMapReply reply;
 
     // Context for the client. It could be used to convey extra information to
-    // the server and/or tweastd::cout<<"shift:"<<shiftCMD<<std::endl;k certain RPC behaviors.
+    // the server and/or tweak certain RPC behaviors.
     ClientContext context;
     gpr_timespec timespec;
-    timespec.tv_sec = 1;
+    timespec.tv_sec = 2;
     timespec.tv_nsec = 0;
     timespec.clock_type = GPR_TIMESPAN;
     context.set_deadline(timespec);
 
     // The actual RPC.
-    Status status = stub_ -> changeCtrlMode(&context,request,&reply);
+    Status status = stub_ -> UploadMap(&context,request,&reply);
 
     // Act upon its status.
     if (status.ok()) {
         if(reply.id() == gstrid)
         {
-            modeCMD = reply.modecmd();
+//            std::cout<<reply.id()<<std::endl;
+            isNeedMap = false;
+            patrolPathID = "noPath";
+            POIPoints.clear();
+
+            isNeedMap = reply.isneedmap();
+//            std::cout<<reply.isneedmap()<<std::endl;
+            patrolPathID = reply.patrolpathid();
+//            std::cout<<reply.patrolpathid()<<std::endl;
+            for(int i = 0;i < reply.mappoints_size();i++)
+            {
+                POIPoints.append(reply.mappoints(i));
+//                std::cout<<reply.mappoints(i).index()<<std::endl;
+            }
         }
-        return "changeCtrlMode RPC successed";
+        return "UploadMap RPC successed";
     } else {
         std::cout << status.error_code() << ": " << status.error_message()
                   << std::endl;
@@ -171,73 +240,42 @@ std::string VehicleControlClient::changeCtrlMode(void)
         {
             std::cout << "vehicleControl RPC connect timeout" << std::endl;
         }
-        return "changeCtrlMode RPC failed";
+        return "UploadMap RPC failed";
     }
 }
 
-void VehicleControlClient::updateControlData(void)
-{
-    std::cout<<"shift:"<<shiftCMD<<std::endl;
-    std::cout<<"steeringWheelAngle:"<<steeringWheelAngleCMD<<std::endl;
-    std::cout<<"throttle:"<<throttleCMD<<std::endl;
-    std::cout<<"brake:"<<brakeCMD<<std::endl;
-}
-
-void VehicleControlClient::updateMapPOIData(void)
+void VehicleUploadMapClient::updateMapPOIData(void)
 {
     std::cout<<"isNeedMap:"<<isNeedMap<<std::endl;
     std::cout<<"patrolPathID:"<<patrolPathID<<std::endl;
     emit patrolPOI_Recieved(patrolPathID);
 }
 
-void VehicleControlClient::updateCtrolMode(void)
-{
-//    std::cout<<"modeCMD:"<<modeCMD<<std::endl;
-}
-
-void VehicleControlClient::controlTimeout(void)
+void VehicleUploadMapClient::run()
 {
-    std::string reply = changeCtrlMode();
-//    std::cout<< reply <<std::endl;
-    updateCtrolMode();
-
-    reply = vehicleControl();
-//    std::cout<< reply <<std::endl;
-    if(modeCMD == CtrlMode::CMD_REMOTE || modeCMD == CtrlMode::CMD_CLOUD_PLATFORM)
+    QTime xTime;
+    xTime.start();
+    uint64_t lastTime = xTime.elapsed();
+    uint64_t interval = std::atoi(gstrcontrolInterval.c_str());
+    while (true)
     {
-        updateControlData();
-    }
-}
-
-void VehicleControlClient::uploadMapTimeout(void)
-{
-    if(isNeedMap == false)
-    {
-        std::string reply = uploadMap();
-//        std::cout<< reply <<std::endl;
-        if(isNeedMap == true)
+        if((xTime.elapsed() - lastTime)>=interval)
         {
-            updateMapPOIData();
+            if(isNeedMap == false)
+            {
+                std::string reply = uploadMap();
+        //        std::cout<< reply <<std::endl;
+                if(isNeedMap == true)
+                {
+                    updateMapPOIData();
+                }
+            }
+            lastTime = xTime.elapsed();
         }
     }
 }
 
-std::string VehicleControlClient::get_patrolPathID(void)
-{
-    return patrolPathID;
-}
-
-bool VehicleControlClient::get_isNeedMap(void)
-{
-    return isNeedMap;
-}
-
-void VehicleControlClient::set_isNeedMap(bool needMapStatus)
-{
-    isNeedMap = needMapStatus;
-}
-
-void VehicleControlClient::uploadPath_Finished_Slot(std::string pathID)
+void VehicleUploadMapClient::uploadPath_Finished_Slot(std::string pathID)
 {
     std::cout<<"Path ID:"<<pathID<<" upload finished"<<std::endl;
     if(isNeedMap == true)

+ 52 - 17
src/driver/driver_cloud_grpc_client_BS/vehicle_control.h

@@ -3,7 +3,9 @@
 
 #include <QObject>
 #include <QTimer>
+#include <QDateTime>
 #include <QVector>
+#include <QThread>
 
 #include <iostream>
 #include <memory>
@@ -24,7 +26,7 @@ using org::jeecg::defsControl::grpc::ControlReply; ///< rpc fuction parameter an
 using org::jeecg::defsControl::grpc::UploadMapReply;
 using org::jeecg::defsControl::grpc::CtrlModeReply;
 
-class VehicleControlClient : public QObject{
+class VehicleControlClient : public QThread{
     Q_OBJECT
 
 public:
@@ -33,14 +35,10 @@ public:
     ~VehicleControlClient(void);
 
     std::string vehicleControl(void);
-    std::string uploadMap(void);
-    std::string changeCtrlMode(void);
     void updateControlData(void);
-    void updateMapPOIData(void);
-    void updateCtrolMode(void);
-    std::string get_patrolPathID(void);
-    bool get_isNeedMap(void);
-    void set_isNeedMap(bool needMapStatus);
+
+protected:
+    void run();
 
 private:
     std::unique_ptr<VehicleControl::Stub> stub_;
@@ -50,24 +48,61 @@ private:
     double throttleCMD = 0;
     double brakeCMD = 0;
 
-    bool isNeedMap = false;
-    std::string patrolPathID;
-    QVector<org::jeecg::defsControl::grpc::MapPoint> POIPoints;
+    org::jeecg::defsControl::grpc::CtrlMode modeCMD; ///< update by slot function
+
+public slots:
+    void ctrlMode_Changed_Slot(org::jeecg::defsControl::grpc::CtrlMode ctrlMode);
+};
+
+class VehicleChangeCtrlModeClient : public QThread{
+    Q_OBJECT
+
+public:
+    VehicleChangeCtrlModeClient(std::shared_ptr<Channel> channel);
+
+    ~VehicleChangeCtrlModeClient(void);
+
+    std::string changeCtrlMode(void);
+    void updateCtrolMode(void);
+
+protected:
+    void run();
+
+private:
+    std::unique_ptr<VehicleControl::Stub> stub_;
 
     org::jeecg::defsControl::grpc::CtrlMode modeCMD;
 
-    QTimer *controlTimer;
-    QTimer *uploadMapTimer;
+signals:
+    void ctrlMode_Changed(org::jeecg::defsControl::grpc::CtrlMode ctrlMode);
+};
+
+class VehicleUploadMapClient : public QThread{
+    Q_OBJECT
+
+public:
+    VehicleUploadMapClient(std::shared_ptr<Channel> channel);
+
+    ~VehicleUploadMapClient(void);
+
+    std::string uploadMap(void);
+    void updateMapPOIData(void);
+
+protected:
+    void run();
+
+private:
+    std::unique_ptr<VehicleControl::Stub> stub_;
+
+    bool isNeedMap = false;
+    std::string patrolPathID;
+    QVector<org::jeecg::defsControl::grpc::MapPoint> POIPoints;
 
 signals:
     void patrolPOI_Recieved(std::string pathID);
 
 public slots:
     void uploadPath_Finished_Slot(std::string pathID);
-
-private slots:
-    void controlTimeout(void);
-    void uploadMapTimeout(void);
 };
 
 #endif // VEHICLE_CONTROL_H

+ 18 - 11
src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.cpp

@@ -1,5 +1,5 @@
 #include "vehicle_patrol.h"
-#include <QDateTime>
+
 #include <QFile>
 
 extern std::string gstrserverip;
@@ -14,15 +14,11 @@ using org::jeecg::defsPatrol::grpc::GPSPoint;
 VehiclePatrolExceptionClient::VehiclePatrolExceptionClient(std::shared_ptr<Channel> channel)
 {
     stub_ = VehiclePatrolException::NewStub(channel);
-
-    patrolTimer = new QTimer();
-    connect(patrolTimer,&QTimer::timeout,this,&VehiclePatrolExceptionClient::patrolTimeout);
-//    patrolTimer->start(std::atoi(gstrpatrolInterval.c_str()));
 }
 
 VehiclePatrolExceptionClient::~VehiclePatrolExceptionClient(void)
 {
-    delete patrolTimer;
+
 }
 
 std::string VehiclePatrolExceptionClient::uploadVehiclePatrolInfo(void)
@@ -58,7 +54,7 @@ std::string VehiclePatrolExceptionClient::uploadVehiclePatrolInfo(void)
     // the server and/or tweak certain RPC behaviors.
     ClientContext context;
     gpr_timespec timespec;
-    timespec.tv_sec = 1;
+    timespec.tv_sec = 5;
     timespec.tv_nsec = 0;
     timespec.clock_type = GPR_TIMESPAN;
     context.set_deadline(timespec);
@@ -134,9 +130,20 @@ void VehiclePatrolExceptionClient::updatePatrolData(void)
     plateNumber = gstrplateNumber;
 }
 
-void VehiclePatrolExceptionClient::patrolTimeout(void)
+void VehiclePatrolExceptionClient::run()
 {
-    updatePatrolData();
-    std::string reply = uploadVehiclePatrolInfo();
-    std::cout<< reply <<std::endl;
+    QTime xTime;
+    xTime.start();
+    uint64_t lastTime = xTime.elapsed();
+    uint64_t interval = std::atoi(gstrpatrolInterval.c_str());
+    while (true)
+    {
+        if((xTime.elapsed() - lastTime)>=interval)
+        {
+            updatePatrolData();
+            std::string reply = uploadVehiclePatrolInfo();
+            std::cout<< reply <<std::endl;
+            lastTime = xTime.elapsed();
+        }
+    }
 }

+ 6 - 6
src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.h

@@ -3,7 +3,9 @@
 
 #include <QObject>
 #include <QTimer>
+#include <QDateTime>
 #include <QVector>
+#include <QThread>
 
 #include <iostream>
 #include <memory>
@@ -22,7 +24,7 @@ using org::jeecg::defsPatrol::grpc::VehiclePatrolException; ///< service name
 
 using org::jeecg::defsPatrol::grpc::PatrolRequest;
 
-class VehiclePatrolExceptionClient : public QObject{
+class VehiclePatrolExceptionClient : public QThread{
     Q_OBJECT
 
 public:
@@ -33,6 +35,9 @@ public:
     std::string uploadVehiclePatrolInfo(void);
     void updatePatrolData(void);
 
+protected:
+    void run();
+
 private:
     std::unique_ptr<VehiclePatrolException::Stub> stub_;
 
@@ -58,11 +63,6 @@ private:
     org::jeecg::defsPatrol::grpc::GPSPoint gatePosition; //positon when get gateImage
 
     std::string plateNumber;
-
-    QTimer *patrolTimer;
-
-private slots:
-    void patrolTimeout(void);
 };
 
 #endif // VEHICLE_PATROL_H

+ 17 - 11
src/driver/driver_cloud_grpc_client_BS/vehicle_upload.cpp

@@ -1,9 +1,8 @@
 #include "vehicle_upload.h"
-#include <QDateTime>
+
 #include <QFile>
 #include <QString>
 #include <QStringList>
-#include <QThread>
 
 extern std::string gstrserverip;
 extern std::string gstruploadPort;
@@ -22,15 +21,11 @@ using org::jeecg::defsDetails::grpc::CtrlMode;
 DataExchangeClient::DataExchangeClient(std::shared_ptr<Channel> channel)
 {
     stub_ = DataExchange::NewStub(channel);
-
-    uploadTimer = new QTimer();
-    connect(uploadTimer,&QTimer::timeout,this,&DataExchangeClient::uploadTimeout);
-    uploadTimer->start(std::atoi(gstruploadInterval.c_str()));
 }
 
 DataExchangeClient::~DataExchangeClient(void)
 {
-    delete uploadTimer;
+
 }
 
 std::string DataExchangeClient::uploadVehicleInfo(void)
@@ -221,11 +216,22 @@ void DataExchangeClient::updatePath(std::string pathID, QVector<MapPoint> points
     }
 }
 
-void DataExchangeClient::uploadTimeout(void)
+void DataExchangeClient::run()
 {
-    updateData();
-    std::string reply = uploadVehicleInfo();
-//    std::cout<< reply <<std::endl;
+    QTime xTime;
+    xTime.start();
+    uint64_t lastTime = xTime.elapsed();
+    uint64_t interval = std::atoi(gstruploadInterval.c_str());
+    while (true)
+    {
+        if((xTime.elapsed() - lastTime)>=interval)
+        {
+            updateData();
+            std::string reply = uploadVehicleInfo();
+            std::cout<< reply <<std::endl;
+            lastTime = xTime.elapsed();
+        }
+    }
 }
 
 void DataExchangeClient::patrolPOI_Recieved_Slot(std::string pathID)

+ 6 - 6
src/driver/driver_cloud_grpc_client_BS/vehicle_upload.h

@@ -3,7 +3,9 @@
 
 #include <QObject>
 #include <QTimer>
+#include <QDateTime>
 #include <QVector>
+#include <QThread>
 
 #include <iostream>
 #include <memory>
@@ -26,7 +28,7 @@ using org::jeecg::defsDetails::grpc::UploadPathRequest;
 
 using org::jeecg::defsDetails::grpc::VehicleStatus; ///< other enum
 
-class DataExchangeClient : public QObject{
+class DataExchangeClient : public QThread{
     Q_OBJECT
 
 public:
@@ -39,6 +41,9 @@ public:
     void updateData(void);
     void updatePath(std::string pathID,QVector<org::jeecg::defsDetails::grpc::MapPoint> points);
 
+protected:
+    void run();
+
 private:
     std::unique_ptr<DataExchange::Stub> stub_;
 
@@ -82,16 +87,11 @@ private:
     std::string patrolPathID;
     QVector<org::jeecg::defsDetails::grpc::MapPoint> pathPoints;
 
-    QTimer *uploadTimer;
-
 signals:
     void uploadPath_Finished(std::string pathID);
 
 public slots:
     void patrolPOI_Recieved_Slot(std::string pathID);
-
-private slots:
-    void uploadTimeout(void);
 };
 
 #endif // VEHICLE_UPLOAD_H

+ 19 - 4
src/driver/driver_lidar_hesaipandarqt64/lidar_driver_hesaipandarqt64.cpp

@@ -44,9 +44,24 @@ static std::thread * g_phesaipandar64ProcThread;
 
 //float gV_theta[16] =  {-15,1,-13,3,-11,5,-9,7,-7,9,-5,11,-3,13,-1,15};   //16 Angles
 //static float gV_theta[64] =  {14.7,10.85,7.877,4.875,2.858,1.846,1.678,1.506,1.34,1.169,1.002,0.831,0.664,0.493,0.326,0.155,-0.013,-0.182,-0.351,-0.519,-0.69,-0.857,-1.027,-1.195,-1.366,-1.533,-1.704,-1.87,-2.042,-2.21,-2.38,-2.547,-2.718,-2.882,-3.055,-3.222,-3.392,-3.557,-3.73,-3.894,-4.066,-4.232,-4.403,-4.567,-4.74,-4.902,-5.074,-5.239,-5.411,-5.573,-5.747,-5.908,-6.08,-6.243,-7.245,-8.241,-9.242,-10.227,-11.214,-12.188,-13.156,-14.112,-19.071,-25.079};   //64 Angles
-static float gV_theta[64] = {8.736,8.314,7.964,7.669,7.417,7.198,7.007,6.838,6.688,6.554,6.434,6.326,6.228,6.14,6.059,5.987,-5.27,-5.216,-5.167,-5.123,-5.083,-5.047,-5.016,-4.988,-4.963,-4.942,-4.924,-4.91,-4.898,-4.889,-4.884,-4.881,5.493,5.496,5.502,5.512,5.525,5.541,5.561,5.584,5.611,5.642,5.676,5.716,5.759,5.808,5.862,5.921,-5.33,-5.396,-5.469,-5.55,-5.64,-5.74,-5.85,-5.974,-6.113,-6.269,-6.447,-6.651,-6.887,-7.163,-7.493,-7.892};
+static float gV_theta[64] = {-52.121,-49.785,-47.577,-45.477,-43.465,-41.528,-39.653,-37.831,
+                             -36.055,-34.32,-32.619,-30.95,-29.308,-27.69,-26.094,-24.517,
+                             -22.964,-21.42,-19.889,-18.372,-16.865,-15.368,-13.88,-12.399,
+                             -10.925,-9.457,-7.994,-6.535,-5.079,-3.626,-2.175,-0.725,
+                             0.725,2.175,3.626,5.079,6.534,7.993,9.456,10.923,
+                             12.397,13.877,15.365,16.861,18.368,19.885,21.415,22.959,
+                             24.524,26.101,27.697,29.315,30.957,32.627,34.328,36.064,
+                             37.84,39.662,41.537,43.475,45.487,47.587,49.795,52.133};
+static float gH_theta[64] = {8.736,8.314,7.964,7.669,7.417,7.198,7.007,6.838,
+                             6.688,6.554,6.434,6.326,6.228,6.14,6.059,5.987,
+                             -5.27,-5.216,-5.167,-5.123,-5.083,-5.047,-5.016,-4.988,
+                             -4.963,-4.942,-4.924,-4.91,-4.898,-4.889,-4.884,-4.881,
+                             5.493,5.496,5.502,5.512,5.525,5.541,5.561,5.584,
+                             5.611,5.642,5.676,5.716,5.759,5.808,5.862,5.921,
+                             -5.33,-5.396,-5.469,-5.55,-5.64,-5.74,-5.85,-5.974,
+                             -6.113,-6.269,-6.447,-6.651,-6.887,-7.163,-7.493,-7.892};
 //static float gH_theta[64] = {-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,1.042,3.125,5.208,-5.208,-3.125,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042,-1.042};
-static float gH_theta[64] = {-52.121,-49.785,-47.577,-45.477,-43.465,-41.528,-39.653,-37.831,-36.055,-34.32,-32.619,-30.95,-29.308,-27.69,-26.094,-24.517,-22.964,-21.42,-19.889,-18.372,-16.865,-15.368,-13.88,-12.399,-10.925,-9.457,-7.994,-6.535,-5.079,-3.626,-2.175,-0.725,0.725,2.175,3.626,5.079,6.534,7.993,9.456,10.923,12.397,13.877,15.365,16.861,18.368,19.885,21.415,22.959,24.524,26.101,27.697,29.315,30.957,32.627,34.328,36.064,37.84,39.662,41.537,43.475,45.487,47.587,49.795,52.133};
+
 static float gV_theta_cos[64],gV_theta_sin[64];
 
 //static void * g_hesaipandar64_raw;
@@ -379,9 +394,9 @@ static void process_hesaipandar64obs(char * strdata,int nLen)
             {
                 Ang = (0 - wt-gH_theta[pointi]) / 180.0 * Lidar_Pi;
 //                Range = ((pstr[bag*npacsize + Group * 194 + 11 + 3 * pointi] << 8) + pstr[bag*npacsize+Group * 194 + 10 + 3 * pointi]);
-                Range = ((pstr[bag*npacsize + Group * 258 + 15 + 3 * pointi] << 8) + pstr[bag*npacsize+Group * 258 + 14 + 3 * pointi]);
+                Range = ((pstr[bag*npacsize + Group * 258 + 15 + 4 * pointi] << 8) + pstr[bag*npacsize+Group * 258 + 14 + 4 * pointi]);
 //                unsigned char intensity = pstr[bag*npacsize + Group * 194 + 12 + 3 * pointi];
-                unsigned char intensity = pstr[bag*npacsize + Group * 258 + 16 + 3 * pointi];
+                unsigned char intensity = pstr[bag*npacsize + Group * 258 + 16 + 4 * pointi];
                 Range=Range* 0.004;
 
 

+ 3 - 3
src/driver/driver_lidar_hesaipandarqt64/main.cpp

@@ -195,14 +195,14 @@ int main(int argc, char *argv[])
     QCoreApplication a(argc, argv);
 
     snprintf(gstr_memname,255,"lidar_pc");
-    snprintf(gstr_rollang,255,"270.0");
+    snprintf(gstr_rollang,255,"200");
     snprintf(gstr_inclinationang_xaxis,255,"0.0");
     snprintf(gstr_inclinationang_yaxis,255,"0");
 //    snprintf(gstr_hostip,255,"192.168.1.102");
     snprintf(gstr_port,255,"2368");
     snprintf(gstr_yaml,255,"");
     snprintf(gstr_modulename,255,"driver_lidar_hesaipandarqt64");
-    snprintf(gstr_calibfile,255,"5.PA6439CE509739CE56-correction.csv");
+    snprintf(gstr_calibfile,255,"PandarQT_Correction_file.csv");
 
     int nRtn = GetOptLong(argc,argv);
     if(nRtn == 1)  //show help,so exit.
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
     gIvfault = new  iv::Ivfault(gstr_modulename);
     gIvlog = new iv::Ivlog(gstr_modulename);
     gIvfault->SetFaultState(0,0,"Initial State");
-    gIvlog->info("driver_lidar_hesaipandar64 starting.");
+    gIvlog->info("driver_lidar_hesaipandarqt64 starting.");
 
     StartLidar_hesaipandar64();
     return a.exec();