Forráskód Böngészése

update clamp safety code

wk 1 éve
szülő
commit
5b827a85f6

+ 19 - 6
Modules/ClampSafety/CMakeLists.txt

@@ -1,18 +1,24 @@
+if(MeasureTest)
+	add_definitions(-DETC_PATH="${CMAKE_CURRENT_LIST_DIR}")
+endif ()
+
 set(Target_Name
 		clamp_safety
 		)
 
-option(OPTION_ENABLE_COMMUNICATION_PLC "启用和plc通信" ON)
-
 include_directories(
 	/usr/local/include/snap7
 )
 
+find_package(gRPC CONFIG REQUIRED)
+
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/lidar LIDAR_SRC)
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/detect DETECT_SRC)
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/plc PLC_SRC)
+aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/grpc grpc)
 
 set(Target_source
+		${grpc}
 		${PLC_SRC}
 		${LIDAR_SRC}
 		${DETECT_SRC}
@@ -22,6 +28,8 @@ set(Target_source
 set(Target_libary
 		zx
 		snap7
+		protobuf::libprotobuf
+		gRPC::grpc++_reflection
 		-lpthread
 )
 
@@ -29,7 +37,11 @@ message(${Target_Name} ":" ${Target_libary})
 
 add_executable(${Target_Name} ${Target_source})
 target_link_libraries(${Target_Name} ${Target_libary})
-target_compile_definitions(${Target_Name} PRIVATE __VIEW__PCL=0)
+
+#add_executable(${Target_Name}_viewer ${Target_source})
+#target_link_libraries(${Target_Name}_viewer ${Target_libary})
+#target_compile_definitions(${Target_Name}_viewer PRIVATE __VIEW__PCL=1)
+
 # 将库文件,可执行文件,头文件安装到指定目录
 install(TARGETS ${Target_Name}
 		LIBRARY DESTINATION lib  # 动态库安装路径
@@ -38,6 +50,7 @@ install(TARGETS ${Target_Name}
 		PUBLIC_HEADER DESTINATION include  # 头文件安装路径
 		)
 
-#install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/etc
-#		DESTINATION ${CMAKE_INSTALL_PREFIX}
-#		)
+		
+install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/etc
+		DESTINATION ${CMAKE_INSTALL_PREFIX}
+		)

+ 3 - 3
Modules/ClampSafety/detect/clamp_safety_detect.cpp

@@ -235,8 +235,8 @@ bool clamp_safety_detect::check_wheel_line(const Line &line, Safety_status &safe
     pcl::PointXYZ minp, maxp;
     pcl::getMinMax3D(*line.cloud, minp, maxp);
     float length = maxp.x - minp.x;
-    if (line.cov < 0.03 && fabs(line.theta_by_x) < 10.
-        && (length > 0.1 && length < 0.5)) {
+    if (/*line.cov < 0.13 && fabs(line.theta_by_x) < 10.
+        && (length > 0.1 && length < 0.5*/ true) {
         //前方直线是轮胎,判断中心是否居中、直线长度是否在范围内
 
         safety.cx = line.cx;
@@ -326,4 +326,4 @@ bool clamp_safety_detect::detect(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, Safe
         return true;
     }
     return false;
-}
+}

+ 82 - 0
Modules/ClampSafety/etc/clamp_safety_lidars.json

@@ -0,0 +1,82 @@
+[
+    {
+        "enable": true,
+        "angle_min": -2.35619449,
+        "angle_max": 2.35619449,
+        "angle_increment": 0.00582,
+        "time_increment": 0.000062,
+        "range_min": 0,
+        "range_max": 30,
+        "net_config": {
+            "ip_address": "10.211.32.150",
+            "port": 2110
+        },
+        "scan_box_limit": {
+            "dist_limit": 8,
+            "minx": -0.35,
+            "maxx": 0.35,
+            "miny": 0.05,
+            "maxy": 0.5
+        }
+    },
+    {
+        "enable": true,
+        "angle_min": -2.35619449,
+        "angle_max": 2.35619449,
+        "angle_increment": 0.00582,
+        "time_increment": 0.000062,
+        "range_min": 0,
+        "range_max": 30,
+        "net_config": {
+            "ip_address": "10.211.32.151",
+            "port": 2110
+        },
+        "scan_box_limit": {
+            "dist_limit": 8,
+            "minx": -0.35,
+            "maxx": 0.35,
+            "miny": 0.05,
+            "maxy": 0.5
+        }
+    },
+    {
+        "enable": true,
+        "angle_min": -2.35619449,
+        "angle_max": 2.35619449,
+        "angle_increment": 0.00582,
+        "time_increment": 0.000062,
+        "range_min": 0,
+        "range_max": 30,
+        "net_config": {
+            "ip_address": "10.211.32.152",
+            "port": 2110
+        },
+        "scan_box_limit": {
+            "dist_limit": 8,
+            "minx": -0.35,
+            "maxx": 0.35,
+            "miny": 0.05,
+            "maxy": 0.5
+        }
+    },
+    {
+        "enable": true,
+        "angle_min": -2.35619449,
+        "angle_max": 2.35619449,
+        "angle_increment": 0.00582,
+        "time_increment": 0.000062,
+        "range_min": 0,
+        "range_max": 30,
+        "net_config": {
+            "ip_address": "10.211.32.153",
+            "port": 2110
+        },
+        "scan_box_limit": {
+            "dist_limit": 8,
+            "minx": -0.35,
+            "maxx": 0.35,
+            "miny": 0.05,
+            "maxy": 0.5
+        }
+    }
+]

+ 3 - 0
Modules/ClampSafety/etc/plc.json

@@ -0,0 +1,3 @@
+{
+    "ip": "10.211.32.1"
+}

+ 23 - 0
Modules/ClampSafety/grpc/def.grpc.proto

@@ -0,0 +1,23 @@
+syntax = "proto2";
+
+message PointXY {
+    required float x = 1;
+    required float y = 2;
+}
+
+message clouds {
+    repeated PointXY clamp_1 = 1;
+    repeated PointXY clamp_2 = 2;
+    repeated PointXY clamp_3 = 3;
+    repeated PointXY clamp_4 = 4;
+}
+
+message RequestCmd {
+    optional bool start = 1;
+}
+
+service StreamServer{
+  rpc OpenStream(RequestCmd) returns(stream clouds){}
+  rpc CloseStream(RequestCmd) returns(stream clouds){}
+}
+

+ 101 - 0
Modules/ClampSafety/grpc/service.cpp

@@ -0,0 +1,101 @@
+
+#include "service.h"
+#include <unistd.h>
+
+CustomServer::CustomServer() {
+}
+
+CustomServer::~CustomServer() {
+}
+
+::grpc::Status CustomServer::OpenStream(::grpc::ServerContext* context, const ::RequestCmd* request, ::grpc::ServerWriter< ::clouds>* writer) {
+////////////////////////////////
+    streamStatu = true;
+    printf("%s\n", __FUNCTION__);
+    while (streamStatu) {
+        clouds clamp_clouds;
+        pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_cloud(new pcl::PointCloud<pcl::PointXYZ>);
+        TransitData::get_instance_pointer()->getCloud(0, pcl_cloud);
+        // printf("get point num: %ld\n", pcl_cloud->size());
+        for(auto &pt: pcl_cloud->points) {
+            PointXY point;
+            point.set_x(pt.x);
+            point.set_y(pt.y);
+            clamp_clouds.add_clamp_1()->CopyFrom(point);
+        }
+        TransitData::get_instance_pointer()->getCloud(1, pcl_cloud);
+        for(auto &pt: pcl_cloud->points) {
+            PointXY point;
+            point.set_x(pt.x);
+            point.set_y(pt.y);
+            clamp_clouds.add_clamp_2()->CopyFrom(point);
+        }
+        TransitData::get_instance_pointer()->getCloud(2, pcl_cloud);
+        for(auto &pt: pcl_cloud->points) {
+            PointXY point;
+            point.set_x(pt.x);
+            point.set_y(pt.y);
+            clamp_clouds.add_clamp_3()->CopyFrom(point);
+        }
+        TransitData::get_instance_pointer()->getCloud(3, pcl_cloud);
+        for(auto &pt: pcl_cloud->points) {
+            PointXY point;
+            point.set_x(pt.x);
+            point.set_y(pt.y);
+            clamp_clouds.add_clamp_4()->CopyFrom(point);
+        }
+        writer->Write(clamp_clouds);
+        if (context->IsCancelled()) {
+            printf("Data Stream canceled\n");
+            streamStatu = false;
+            return ::grpc::Status::OK;
+        }
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    }
+////////////////////////////////
+    return ::grpc::Status::OK;
+
+}
+
+::grpc::Status CustomServer::CloseStream(::grpc::ServerContext* context, const ::RequestCmd* request, ::grpc::ServerWriter< ::clouds>* writer) {
+////////////////////////////////
+    streamStatu = false;
+    printf("%s\n", __FUNCTION__);
+////////////////////////////////
+    return ::grpc::Status::OK;
+
+}
+
+StreamRpcServer::StreamRpcServer() {
+    thread_ = nullptr;
+}
+
+StreamRpcServer::~StreamRpcServer() {
+
+    if (thread_ != nullptr) {
+        server_->Shutdown();
+        if (thread_->joinable()) {
+            thread_->join();
+            delete thread_;
+        }
+    }
+}
+
+void StreamRpcServer::Listenning(std::string ip, int port) {
+    char ipport[64] = {0};
+    printf("listenning grpc %s ", ip.c_str());
+    sprintf(ipport, "%s:%d", ip.c_str(), port);
+    builder_.AddListeningPort(ipport, grpc::InsecureServerCredentials());
+    builder_.RegisterService(&service_);
+
+    server_ = builder_.BuildAndStart();
+    thread_ = new std::thread(&StreamRpcServer::WaitThread, this);
+}
+
+void StreamRpcServer::WaitThread(void *p) {
+    StreamRpcServer *server = (StreamRpcServer *) p;
+    printf(" listenning ........\n");
+    server->server_->Wait();
+    printf(" server closesd.....\n");
+}
+

+ 49 - 0
Modules/ClampSafety/grpc/service.h

@@ -0,0 +1,49 @@
+#ifndef __SERVER__GRPC__STREAM__HH_H_
+#define __SERVER__GRPC__STREAM__HH_H_
+
+#include <pcl/point_cloud.h>
+#include <pcl/point_types.h>
+#include <thread>
+#include <grpcpp/grpcpp.h>
+#include "def.grpc.grpc.pb.h"
+#include "def.grpc.pb.h"
+#include "transitData.h"
+
+class CustomServer : public StreamServer::Service {
+private:
+
+    bool streamStatu = false;
+    
+public:
+    CustomServer();
+
+    ~CustomServer();
+
+    virtual ::grpc::Status OpenStream(::grpc::ServerContext* context, const ::RequestCmd* request, ::grpc::ServerWriter< ::clouds>* writer);
+    virtual ::grpc::Status CloseStream(::grpc::ServerContext* context, const ::RequestCmd* request, ::grpc::ServerWriter< ::clouds>* writer);
+protected:
+
+};
+
+
+class StreamRpcServer {
+
+private:
+    grpc::ServerBuilder builder_;
+    CustomServer service_;
+    std::unique_ptr<grpc::Server> server_;
+    std::thread *thread_;
+
+public:
+    StreamRpcServer();
+
+    ~StreamRpcServer();
+
+    void Listenning(std::string ip, int port);
+
+
+protected:
+    static void WaitThread(void *p);
+};
+
+#endif

+ 27 - 0
Modules/ClampSafety/grpc/transitData.cpp

@@ -0,0 +1,27 @@
+//
+// Created by zx on 23-11-28.
+//
+
+#include "transitData.h"
+
+TransitData::TransitData() {
+    for (int i = 0; i < 4; i++) {
+        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
+        m_clouds_vct.emplace_back(cloud);
+    }
+}
+
+#include <pcl/io/pcd_io.h>
+void TransitData::setCloud(int id, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud) {
+    m_mutex_clouds_vct[id].lock();
+    m_clouds_vct[id]->clear();
+    pcl::copyPointCloud(*cloud, *m_clouds_vct[id]);
+    m_mutex_clouds_vct[id].unlock();
+}
+
+void TransitData::getCloud(int id, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud) {
+    m_mutex_clouds_vct[id].lock();
+    cloud->clear();
+    pcl::copyPointCloud(*m_clouds_vct[id], *cloud);
+    m_mutex_clouds_vct[id].unlock();
+}

+ 27 - 0
Modules/ClampSafety/grpc/transitData.h

@@ -0,0 +1,27 @@
+//
+// Created by zx on 23-11-28.
+//
+
+#ifndef CERES_TEST_TransitData_H
+#define CERES_TEST_TransitData_H
+
+#include <pcl/point_types.h>
+#include <pcl/point_cloud.h>
+#include "tool/timedlockdata.hpp"
+#include "tool/singleton.hpp"
+#include <mutex>
+#include <vector>
+
+class TransitData : public Singleton<TransitData> {
+    friend Singleton<TransitData>;
+public:
+    void setCloud(int id, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
+
+    void getCloud(int id, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
+private:
+    TransitData();
+    std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> m_clouds_vct;
+    std::mutex m_mutex_clouds_vct[4];
+};
+
+#endif //CERES_TEST_TransitData_H

+ 1 - 1
Modules/ClampSafety/lidar/wanji_716N_device.cpp

@@ -171,7 +171,7 @@ Error_manager Wanji_716N_lidar_device::get_last_cloud(std::mutex *p_mutex, pcl::
 //注:函数内部不加锁, 由外部统一加锁.
 Error_manager Wanji_716N_lidar_device::get_last_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr p_cloud,
                                                       std::chrono::system_clock::time_point command_time) {
-    if (p_cloud.get() == nullptr) {
+    if (p_cloud.get() == NULL) {
         return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
                              "  POINTER IS NULL ");
     }

+ 28 - 21
Modules/ClampSafety/main.cpp

@@ -18,9 +18,9 @@
 #include "tool/pathcreator.h"
 #include "lidar/lidarsJsonConfig.h"
 #include "defines.hpp"
+#include "grpc/service.h"
 
 #if __VIEW__PCL
-pcl::visualization::PCLVisualizer g_viewer;
 #endif
 
 void shut_down_logging(const char *data, size_t size) {
@@ -97,6 +97,7 @@ bool run(Wanji_716N_lidar_device *device, clamp_safety_detect *pdetector, Safety
 }
 
 void thread_func(Clamp *clamp) {
+    clamp->last_cloud = static_cast<boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ>>>(new pcl::PointCloud<pcl::PointXYZ>());
     while (true) {
         clamp->mutex.lock();
 
@@ -104,15 +105,12 @@ void thread_func(Clamp *clamp) {
         clamp->lidar.get_last_cloud(clamp->last_cloud, std::chrono::system_clock::now());
 
         if (clamp->last_cloud->size() < 150) {
-            continue;
+            // continue;
+        } else {
+            clamp->safety_statu.time_point = std::chrono::steady_clock::now();
+            clamp->detector.detect(clamp->last_cloud, clamp->safety_statu);
         }
 
-        clamp->detector.detect(clamp->last_cloud, clamp->safety_statu);
-
-//        Safety_status safety_t;
-//        if (run(&(clamp->lidar), &(clamp->detector), &safety_t)) {
-//            clamp->safety_statu = safety_t;
-//        }
         clamp->mutex.unlock();
 
         usleep(100 * 1000);
@@ -120,16 +118,22 @@ void thread_func(Clamp *clamp) {
 }
 
 int main() {
+#if __VIEW__PCL
+// return 1;
+pcl::visualization::PCLVisualizer g_viewer;
+#endif
     //初始化日志
     init_glog();
-
+    StreamRpcServer *m_grpc_server = new StreamRpcServer;
+    m_grpc_server->Listenning("0.0.0.0", 9876);
     // 雷达数量
     const int CLAMP_SIZE = 4;
     //调试模式下,先打开调试窗口
 #if __VIEW__PCL
+return 1;
     int v1,v2,v3,v4;
     //窗口参数分别对应 x_min, y_min, x_max, y_max, viewport
-    g_viewer.createViewPort(0.0, 0.5, 0.5, 1, v1);
+    /*g_viewer.createViewPort(0.0, 0.5, 0.5, 1, v1);
     g_viewer.createViewPort(0.5, 0.5, 1.0, 1, v2);
     g_viewer.createViewPort(0.0, 0, 0.5, 0.5, v3);
     g_viewer.createViewPort(0.5, 0, 1.0, 0.5, v4);
@@ -141,13 +145,13 @@ int main() {
     g_viewer.addCoordinateSystem(0.2,"v1_axis",v1);
     g_viewer.addCoordinateSystem(0.2,"v2_axis",v2);
     g_viewer.addCoordinateSystem(0.2,"v3_axis",v3);
-    g_viewer.addCoordinateSystem(0.2,"v4_axis",v4);
+    g_viewer.addCoordinateSystem(0.2,"v4_axis",v4);*/
 #endif
     //雷达
     Clamp clamps[CLAMP_SIZE];
 
-    LOG(INFO) << "load etc file from " << ETC_PATH"ClampSafety/clamp_safety_lidars.json";
-    lidarsJsonConfig config(ETC_PATH"ClampSafety/clamp_safety_lidars.json");
+    LOG(INFO) << "load etc file from " << ETC_PATH"/etc/clamp_safety_lidars.json";
+    lidarsJsonConfig config(ETC_PATH"/etc/clamp_safety_lidars.json");
     for (int i = 0; i < CLAMP_SIZE; ++i) {
         lidarsJsonConfig::LidarConfig lidar;
         config.getLidarConfig(i, lidar);
@@ -220,26 +224,29 @@ int main() {
     while (true) {
         usleep(100 * 1000);
         heart = (heart + 1) % 255;
-//        snap7_client->plcData.pingpong = heart;
+        snap7_client->plcData.pingpong = heart;
 
         for (int i = 0; i < 4; i++) {
             std::unique_lock<std::mutex> t_lock(clamps[i].mutex);
-//            std::unique_lock<std::mutex> t_lock1(snap7_client->m_data_lock);
+            std::unique_lock<std::mutex> t_lock1(snap7_client->m_data_lock);
             if (!clamps[i].safety_statu.is_timeout()) {
-//                LOG(WARNING) << "id: " << i << ", we: " << clamps[i].safety_statu.wheel_exist << ", cx: " << clamps[i].safety_statu.cx * 1000;
+               // LOG(WARNING) << "id: " << i << ", we: " << clamps[i].safety_statu.wheel_exist << ", cx: " << clamps[i].safety_statu.cx * 1000;
 //                LOG(INFO) << "orid " << i;
 //                LOG(INFO) << "wheel_exist " << clamps[i].safety_statu.wheel_exist;
 //                LOG(INFO) << "cx " << clamps[i].safety_statu.cx * 1000;
 //                LOG(INFO) << "gap " << clamps[i].safety_statu.gap * 1000;
 //                LOG(INFO) << "clamp_completed " << clamps[i].safety_statu.clamp_completed;
-                snap7_client->plcData.wheels[i].wheel_exist = clamps[i].safety_statu.wheel_exist;
-                snap7_client->plcData.wheels[i].offset = clamps[i].safety_statu.cx * 1000;
-                snap7_client->plcData.wheels[i].gap = clamps[i].safety_statu.gap * 1000;
-                snap7_client->plcData.wheels[i].clamp_completed = clamps[i].safety_statu.clamp_completed;
-                snap7_client->setCloudData(1 << i, clamps[i].last_cloud);
+               snap7_client->plcData.wheels[i].wheel_exist = clamps[i].safety_statu.wheel_exist;
+//                snap7_client->plcData.wheels[i].offset = heart;
+//                snap7_client->plcData.wheels[i].gap = 255 - heart;
+               snap7_client->plcData.wheels[i].offset = clamps[i].safety_statu.cx * 1000;
+               snap7_client->plcData.wheels[i].gap = clamps[i].safety_statu.gap * 1000;
+               snap7_client->plcData.wheels[i].clamp_completed = clamps[i].safety_statu.clamp_completed;
             } else {
 //                snap7_client->plcData.clear();
             }
+            snap7_client->setCloudData(1 << i, clamps[i].last_cloud);
+            TransitData::get_instance_pointer()->setCloud(i, clamps[i].last_cloud);
         }
     }
 

+ 0 - 0
Modules/ClampSafety/plc/.snap7_clamp.h.swp


+ 21 - 12
Modules/ClampSafety/plc/snap7_clamp.cpp

@@ -63,12 +63,15 @@ Error_manager Snap7Clamp::communication_init()
 
     t_index = 0;
     t_variable_information_vector.clear();
-    t_variable_information_vector.push_back(Snap7_buf::Variable_information{"warning", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
+    t_variable_information_vector.push_back(Snap7_buf::Variable_information{"warn", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 
-    t_snap7_buf.init(CLAMP_SAFETY_HEART_DBNUMBER , 0, sizeof(unsigned short), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
+    t_snap7_buf.init(CLAMP_SAFETY_WARNING_DBNUMBER , 0, sizeof(unsigned char), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
     m_receive_buf_map[0] = t_snap7_buf;
-
-    plcJsonConfig config(ETC_PATH"ClampSafety/plc.json");
+    
+    
+    m_save_cloud_flag = 0;
+    
+    plcJsonConfig config(ETC_PATH"/etc/plc.json");
     return Snap7_communication_base::communication_init(config.ip());
     return SUCCESS;
 }
@@ -83,11 +86,13 @@ Error_manager Snap7Clamp::setCloudData(const unsigned char &device, pcl::PointCl
     if ((m_save_cloud_flag & device) == 0) {
         return {};
     } else {
-        m_save_cloud_flag & (~device);
+        m_save_cloud_flag = m_save_cloud_flag & (~device);
     }
 
     std::string file = "./log/save_cloud/" + std::to_string(device) + "/" +
                         std::to_string(std::chrono::system_clock::now().time_since_epoch().count()) + ".txt";
+    LOG(INFO) << "save cloud to " << file;
+                        
     FILE* pf=fopen(file.c_str(),"w");
     for (auto &point: cloud->points) {
         fprintf(pf,"%.3f %.3f %.3f\n",point.x,point.y,point.z);
@@ -100,18 +105,22 @@ Error_manager Snap7Clamp::setCloudData(const unsigned char &device, pcl::PointCl
 //更新数据
 Error_manager Snap7Clamp::updata_receive_buf()
 {
-	std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
-	std::unique_lock<std::mutex> t_lock2(m_data_lock);
-    unsigned char warn;
+    std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
+    std::unique_lock<std::mutex> t_lock2(m_data_lock);
+    unsigned char warn = 0;
     memcpy(&warn, m_receive_buf_map[0].mp_buf_obverse, m_receive_buf_map[0].m_size);
-
-    m_save_cloud_flag = (~m_warn_record) & warn;
+/*
+    m_warn_record = 0;
+    warn = 0x4;
+    */
+    m_save_cloud_flag = m_save_cloud_flag | (~m_warn_record) & warn;
     m_warn_record = warn;
     if (warn > 0) {
-        LOG(WARNING) << "Get warning: " << warn;
+        //printf("---- %d\n", warn);
+        //LOG(WARNING) << "Get warning: " << int(warn);
     }
 
-	return {};
+    return {};
 }
 
 Error_manager Snap7Clamp::updata_send_buf()

+ 5 - 5
Modules/ClampSafety/plc/snap7_clamp.h

@@ -24,8 +24,9 @@ public:
 
 
 #pragma pack(push, 1)	//struct按照1个byte对齐
+#define CLAMP_SAFETY_HEART_DBNUMBER		9070
 #define CLAMP_SAFETY_PLC_DBNUMBER		9070
-#define CLAMP_SAFETY_HEART_DBNUMBER		9075
+#define CLAMP_SAFETY_WARNING_DBNUMBER		9075
     struct WheeLData {
         unsigned short wheel_exist;
         float offset;
@@ -36,7 +37,7 @@ public:
             if (wheel_exist == 0) {
                 return;
             }
-            LOG(INFO) << "wheel_exist = " << wheel_exist
+            DLOG(INFO) << "wheel_exist = " << wheel_exist
                        << ", offset = " << offset
                        << ", gap = " << gap
                        << ", clamp_completed = " << clamp_completed;
@@ -56,7 +57,7 @@ public:
         struct WheeLData wheels[4];
 
         void info() {
-            LOG(INFO) << "pingdong = " << pingpong;
+            DLOG(INFO) << "pingdong = " << pingpong;
             wheels[0].info();
             wheels[1].info();
             wheels[2].info();
@@ -91,7 +92,7 @@ public://API functions
 	//反初始化 通信 模块。
 	Error_manager communication_uninit() override;
 
-    Error_manager setCloudData(const unsigned char &device, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
+	Error_manager setCloudData(const unsigned char &device, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
 protected://member functions
 	//更新数据
     Error_manager updata_receive_buf() override;
@@ -106,5 +107,4 @@ public:
 private:
     unsigned char m_warn_record;
     unsigned char m_save_cloud_flag;
-
 };

+ 1 - 1
Modules/ClampSafety/plc/snap7_communication_base.cpp

@@ -16,7 +16,7 @@ Snap7_communication_base::~Snap7_communication_base() {
 
 //初始化 通信 模块。如下三选一
 Error_manager Snap7_communication_base::communication_init() {
-    plcJsonConfig config(ETC_PATH"ClampSafety/plc.json");
+    plcJsonConfig config(ETC_PATH"/etc/plc.json");
     return communication_init(config.ip());
 }