Parcourir la source

plc read door status and work in boundary detector and obstacle detector when door is open and closed respectively. fix minor bug of plc door status offset.

youchen il y a 5 ans
Parent
commit
0ccb3e952a

+ 63 - 0
src/verify/Railing.cpp

@@ -0,0 +1,63 @@
+//
+// Created by zx on 2020/1/10.
+//
+
+#include "Railing.h"
+
+/*
+     * 构造函数
+     * a,b,c代表栏杆所在直线方程, ax+by+c=0
+     * width:表示栏杆的宽
+     */
+Railing::Railing(float a,float b,float c,float width)
+{
+    m_a=a;
+    m_b=b;
+    m_c=c;
+    m_width=width;
+}
+/*
+ * 检验结果框,是否会与栏杆冲突
+ */
+Error_manager Railing::verify(cv::RotatedRect rotate_rect)
+{
+    //检验内部参数是否合法
+    if(m_a==0 && m_b==0)
+    {
+        return Error_manager(HARDWARE_LIMIT_RAILING_PARAMETER_ERROR,NORMAL,"railing parameter a&b = 0");
+    }
+    //第一步,获取旋转矩形四个顶角
+    cv::Point2f vertice[4];
+    rotate_rect.points(vertice);
+    //第二步.判断四个顶点是否在栏杆不同侧面,且与直线距离<m_width
+    bool limit_left=false;
+    bool limit_right=false;
+    for(int i=0;i<4;++i)
+    {
+        //计算顶点与直线的距离
+        cv::Point2f point=vertice[i];
+        float x=point.x;
+        float y=point.y;
+        float distance=fabs(m_a*x+m_b*y+m_c)/sqrt(m_a*m_a+m_b*m_b);
+        if(distance<m_width)
+        {
+            //顶点在栏杆上,必定会碰撞
+            return Error_manager(HARDWARE_LIMIT_RAILING_ERROR,NORMAL,"railing error");
+        }
+        else
+        {
+            //顶点在直线右边
+            if(m_a*x+m_b*y+m_c>0)
+                limit_right=true;
+            else if(m_a*x+m_b*y+m_c<0)
+                limit_left=true;
+
+        }
+    }
+    //如果左右都有顶点, 则与栏杆碰撞
+    if(limit_left==true && limit_right==true)
+    {
+        return Error_manager(HARDWARE_LIMIT_RAILING_ERROR,NORMAL,"railing error");
+    }
+    return SUCCESS;
+}

+ 33 - 0
src/verify/Railing.h

@@ -0,0 +1,33 @@
+//
+// Created by zx on 2020/1/10.
+//
+
+#ifndef RAILING_H
+#define RAILING_H
+#include "../error_code/error_code.h"
+#include <opencv2/opencv.hpp>
+/*
+ * 栏杆类, 用于判断旋转矩形是否与栏杆有重叠区域
+ */
+class Railing
+{
+public:
+    /*
+     * 构造函数
+     * a,b,c代表栏杆所在直线方程, ax+by+c=0
+     * width:表示栏杆的宽
+     */
+    Railing(float a,float b,float c,float width);
+    /*
+     * 检验结果框,是否会与栏杆冲突
+     */
+    Error_manager verify(cv::RotatedRect rotate_rect);
+private:
+    float m_a;
+    float m_b;
+    float m_c;
+    float m_width;
+};
+
+
+#endif //RAILING_H

+ 104 - 0
src/verify/Verify_result.cpp

@@ -0,0 +1,104 @@
+//
+// Created by zx on 2020/1/10.
+//
+
+#include "Verify_result.h"
+
+
+/*
+     * 构造函数
+     * parameter:硬件限制配置参数
+     */
+Verify_result::Verify_result(Hardware_limit::Hardware_parameter parameter)
+{
+    m_hardware_parameter=parameter;
+}
+/*
+ * 检验硬件限制
+ * rotate_rect:待检验的旋转矩形
+ */
+Error_manager Verify_result::verify(cv::RotatedRect rotate_rect,float height,bool verify_vertex)
+{
+    //第一步,检验边界
+    float minx=m_hardware_parameter.min_x();
+    float maxx=m_hardware_parameter.max_x();
+    float miny=m_hardware_parameter.min_y();
+    float maxy=m_hardware_parameter.max_y();
+    float center_x=rotate_rect.center.x;
+    float center_y=rotate_rect.center.y;
+    //左超界
+    if(center_x<minx)
+    {
+        return Error_manager(HARDWARE_LIMIT_CENTER_X_LEFT,NORMAL,"left limit");
+    }
+    //右超界
+    if(center_x>maxx)
+    {
+        return Error_manager(HARDWARE_LIMIT_CENTER_X_RIGHT,NORMAL,"right limit");
+    }
+    //上超界
+    if(center_y>maxy)
+    {
+        return Error_manager(HARDWARE_LIMIT_CENTER_Y_TOP,NORMAL,"top limit");
+    }
+    //下超界
+    if(center_y>maxy)
+    {
+        return Error_manager(HARDWARE_LIMIT_CENTER_Y_BOTTOM,NORMAL,"bottom limit");
+    }
+    //第二步,检验高度
+    if(height>m_hardware_parameter.height())
+    {
+        char description[255]={0};
+        sprintf(description,"locate height is out of range(%.2f),height:%.2f",m_hardware_parameter.height(),height);
+        return Error_manager(HARDWARE_LIMIT_HEIGHT_OUT_RANGE,NORMAL,description);
+    }
+    //第三步,检验角度
+    bool tb_theta_verify=false;
+    float angle_x=rotate_rect.angle;
+    for(int i=0;i<m_hardware_parameter.theta_range_size();++i)
+    {
+        Hardware_limit::Theta_range theta_range=m_hardware_parameter.theta_range(i);
+        float min_theta=theta_range.min_theta();
+        float max_theta=theta_range.max_theta();
+        //角度检验, 根据plc限制
+        if( angle_x>=min_theta&&angle_x<=max_theta)
+        {
+            tb_theta_verify = true;
+        }
+    }
+    if(tb_theta_verify==false)
+    {
+        char description[255]={0};
+        sprintf(description,"locate theta is out of range,theta:%.2f",angle_x);
+        return Error_manager(HARDWARE_LIMIT_ANGLE_OUT_RANGE,NORMAL,description);
+    }
+    //是否检验顶点与栏杆的碰撞
+    if(verify_vertex==false)
+    {
+        return SUCCESS;
+    }
+    //第二步,检验栏杆是否碰撞
+    //创建栏杆
+    const int railing_count=m_hardware_parameter.railing_parameter_size();
+    if(railing_count==0)
+        return SUCCESS;
+
+    for(int i=0;i<railing_count;++i)
+    {
+        Hardware_limit::Railing railing_parameter=m_hardware_parameter.railing_parameter(i);
+        Railing* tp_railing=new Railing(railing_parameter.pa(),railing_parameter.pb(),railing_parameter.pc(),
+            railing_parameter.railing_width());
+        if(tp_railing!=NULL)
+        {
+            Error_manager code;
+            code=tp_railing->verify(rotate_rect);
+            delete tp_railing;
+            if(code!=SUCCESS)
+            {
+                return code;
+            }
+        }
+    }
+    return SUCCESS;
+}

+ 35 - 0
src/verify/Verify_result.h

@@ -0,0 +1,35 @@
+//
+// Created by zx on 2020/1/10.
+//
+
+#ifndef VERIFY_RESULT_H
+#define VERIFY_RESULT_H
+#include "hardware_limit.pb.h"
+#include "Railing.h"
+
+/*
+ * 硬件限制检验
+ * 包括旋转矩形是否会碰撞栏杆,旋转矩形中心是否在plc运动范围内
+ */
+class Verify_result
+{
+public:
+    /*
+     * 构造函数
+     * parameter:硬件限制配置参数
+     */
+    Verify_result(Hardware_limit::Hardware_parameter parameter);
+    /*
+     * 检验硬件限制
+     * rotate_rect:待检验的旋转矩形
+     * height:输入高度
+     * center_only:只检验中心点,不检验顶角
+     */
+    Error_manager verify(cv::RotatedRect rotate_rect,float height,bool verify_vertex=true);
+
+private:
+    Hardware_limit::Hardware_parameter          m_hardware_parameter;
+};
+
+
+#endif //VERIFY_RESULT_H

Fichier diff supprimé car celui-ci est trop grand
+ 1400 - 0
src/verify/hardware_limit.pb.cc


+ 872 - 0
src/verify/hardware_limit.pb.h

@@ -0,0 +1,872 @@
+// Generated by the protocol buffer compiler.  DO NOT EDIT!
+// source: hardware_limit.proto
+
+#ifndef PROTOBUF_hardware_5flimit_2eproto__INCLUDED
+#define PROTOBUF_hardware_5flimit_2eproto__INCLUDED
+
+#include <string>
+
+#include <google/protobuf/stubs/common.h>
+
+#if GOOGLE_PROTOBUF_VERSION < 3005000
+#error This file was generated by a newer version of protoc which is
+#error incompatible with your Protocol Buffer headers.  Please update
+#error your headers.
+#endif
+#if 3005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#error This file was generated by an older version of protoc which is
+#error incompatible with your Protocol Buffer headers.  Please
+#error regenerate this file with a newer version of protoc.
+#endif
+
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/generated_message_table_driven.h>
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/metadata.h>
+#include <google/protobuf/message.h>
+#include <google/protobuf/repeated_field.h>  // IWYU pragma: export
+#include <google/protobuf/extension_set.h>  // IWYU pragma: export
+#include <google/protobuf/unknown_field_set.h>
+// @@protoc_insertion_point(includes)
+
+namespace protobuf_hardware_5flimit_2eproto {
+// Internal implementation detail -- do not use these members.
+struct TableStruct {
+  static const ::google::protobuf::internal::ParseTableField entries[];
+  static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
+  static const ::google::protobuf::internal::ParseTable schema[3];
+  static const ::google::protobuf::internal::FieldMetadata field_metadata[];
+  static const ::google::protobuf::internal::SerializationTable serialization_table[];
+  static const ::google::protobuf::uint32 offsets[];
+};
+void AddDescriptors();
+void InitDefaultsRailingImpl();
+void InitDefaultsRailing();
+void InitDefaultsTheta_rangeImpl();
+void InitDefaultsTheta_range();
+void InitDefaultsHardware_parameterImpl();
+void InitDefaultsHardware_parameter();
+inline void InitDefaults() {
+  InitDefaultsRailing();
+  InitDefaultsTheta_range();
+  InitDefaultsHardware_parameter();
+}
+}  // namespace protobuf_hardware_5flimit_2eproto
+namespace Hardware_limit {
+class Hardware_parameter;
+class Hardware_parameterDefaultTypeInternal;
+extern Hardware_parameterDefaultTypeInternal _Hardware_parameter_default_instance_;
+class Railing;
+class RailingDefaultTypeInternal;
+extern RailingDefaultTypeInternal _Railing_default_instance_;
+class Theta_range;
+class Theta_rangeDefaultTypeInternal;
+extern Theta_rangeDefaultTypeInternal _Theta_range_default_instance_;
+}  // namespace Hardware_limit
+namespace Hardware_limit {
+
+// ===================================================================
+
+class Railing : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:Hardware_limit.Railing) */ {
+ public:
+  Railing();
+  virtual ~Railing();
+
+  Railing(const Railing& from);
+
+  inline Railing& operator=(const Railing& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  Railing(Railing&& from) noexcept
+    : Railing() {
+    *this = ::std::move(from);
+  }
+
+  inline Railing& operator=(Railing&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+    return _internal_metadata_.unknown_fields();
+  }
+  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+    return _internal_metadata_.mutable_unknown_fields();
+  }
+
+  static const ::google::protobuf::Descriptor* descriptor();
+  static const Railing& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const Railing* internal_default_instance() {
+    return reinterpret_cast<const Railing*>(
+               &_Railing_default_instance_);
+  }
+  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+    0;
+
+  void Swap(Railing* other);
+  friend void swap(Railing& a, Railing& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline Railing* New() const PROTOBUF_FINAL { return New(NULL); }
+
+  Railing* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void CopyFrom(const Railing& from);
+  void MergeFrom(const Railing& from);
+  void Clear() PROTOBUF_FINAL;
+  bool IsInitialized() const PROTOBUF_FINAL;
+
+  size_t ByteSizeLong() const PROTOBUF_FINAL;
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const PROTOBUF_FINAL;
+  void InternalSwap(Railing* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return NULL;
+  }
+  inline void* MaybeArenaPtr() const {
+    return NULL;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // required float pa = 1;
+  bool has_pa() const;
+  void clear_pa();
+  static const int kPaFieldNumber = 1;
+  float pa() const;
+  void set_pa(float value);
+
+  // required float pb = 2;
+  bool has_pb() const;
+  void clear_pb();
+  static const int kPbFieldNumber = 2;
+  float pb() const;
+  void set_pb(float value);
+
+  // required float pc = 3;
+  bool has_pc() const;
+  void clear_pc();
+  static const int kPcFieldNumber = 3;
+  float pc() const;
+  void set_pc(float value);
+
+  // optional float railing_width = 4 [default = 0];
+  bool has_railing_width() const;
+  void clear_railing_width();
+  static const int kRailingWidthFieldNumber = 4;
+  float railing_width() const;
+  void set_railing_width(float value);
+
+  // @@protoc_insertion_point(class_scope:Hardware_limit.Railing)
+ private:
+  void set_has_pa();
+  void clear_has_pa();
+  void set_has_pb();
+  void clear_has_pb();
+  void set_has_pc();
+  void clear_has_pc();
+  void set_has_railing_width();
+  void clear_has_railing_width();
+
+  // helper for ByteSizeLong()
+  size_t RequiredFieldsByteSizeFallback() const;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::HasBits<1> _has_bits_;
+  mutable int _cached_size_;
+  float pa_;
+  float pb_;
+  float pc_;
+  float railing_width_;
+  friend struct ::protobuf_hardware_5flimit_2eproto::TableStruct;
+  friend void ::protobuf_hardware_5flimit_2eproto::InitDefaultsRailingImpl();
+};
+// -------------------------------------------------------------------
+
+class Theta_range : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:Hardware_limit.Theta_range) */ {
+ public:
+  Theta_range();
+  virtual ~Theta_range();
+
+  Theta_range(const Theta_range& from);
+
+  inline Theta_range& operator=(const Theta_range& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  Theta_range(Theta_range&& from) noexcept
+    : Theta_range() {
+    *this = ::std::move(from);
+  }
+
+  inline Theta_range& operator=(Theta_range&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+    return _internal_metadata_.unknown_fields();
+  }
+  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+    return _internal_metadata_.mutable_unknown_fields();
+  }
+
+  static const ::google::protobuf::Descriptor* descriptor();
+  static const Theta_range& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const Theta_range* internal_default_instance() {
+    return reinterpret_cast<const Theta_range*>(
+               &_Theta_range_default_instance_);
+  }
+  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+    1;
+
+  void Swap(Theta_range* other);
+  friend void swap(Theta_range& a, Theta_range& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline Theta_range* New() const PROTOBUF_FINAL { return New(NULL); }
+
+  Theta_range* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void CopyFrom(const Theta_range& from);
+  void MergeFrom(const Theta_range& from);
+  void Clear() PROTOBUF_FINAL;
+  bool IsInitialized() const PROTOBUF_FINAL;
+
+  size_t ByteSizeLong() const PROTOBUF_FINAL;
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const PROTOBUF_FINAL;
+  void InternalSwap(Theta_range* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return NULL;
+  }
+  inline void* MaybeArenaPtr() const {
+    return NULL;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // required float min_theta = 1;
+  bool has_min_theta() const;
+  void clear_min_theta();
+  static const int kMinThetaFieldNumber = 1;
+  float min_theta() const;
+  void set_min_theta(float value);
+
+  // required float max_theta = 2;
+  bool has_max_theta() const;
+  void clear_max_theta();
+  static const int kMaxThetaFieldNumber = 2;
+  float max_theta() const;
+  void set_max_theta(float value);
+
+  // @@protoc_insertion_point(class_scope:Hardware_limit.Theta_range)
+ private:
+  void set_has_min_theta();
+  void clear_has_min_theta();
+  void set_has_max_theta();
+  void clear_has_max_theta();
+
+  // helper for ByteSizeLong()
+  size_t RequiredFieldsByteSizeFallback() const;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::HasBits<1> _has_bits_;
+  mutable int _cached_size_;
+  float min_theta_;
+  float max_theta_;
+  friend struct ::protobuf_hardware_5flimit_2eproto::TableStruct;
+  friend void ::protobuf_hardware_5flimit_2eproto::InitDefaultsTheta_rangeImpl();
+};
+// -------------------------------------------------------------------
+
+class Hardware_parameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:Hardware_limit.Hardware_parameter) */ {
+ public:
+  Hardware_parameter();
+  virtual ~Hardware_parameter();
+
+  Hardware_parameter(const Hardware_parameter& from);
+
+  inline Hardware_parameter& operator=(const Hardware_parameter& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  Hardware_parameter(Hardware_parameter&& from) noexcept
+    : Hardware_parameter() {
+    *this = ::std::move(from);
+  }
+
+  inline Hardware_parameter& operator=(Hardware_parameter&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+    return _internal_metadata_.unknown_fields();
+  }
+  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+    return _internal_metadata_.mutable_unknown_fields();
+  }
+
+  static const ::google::protobuf::Descriptor* descriptor();
+  static const Hardware_parameter& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const Hardware_parameter* internal_default_instance() {
+    return reinterpret_cast<const Hardware_parameter*>(
+               &_Hardware_parameter_default_instance_);
+  }
+  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
+    2;
+
+  void Swap(Hardware_parameter* other);
+  friend void swap(Hardware_parameter& a, Hardware_parameter& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline Hardware_parameter* New() const PROTOBUF_FINAL { return New(NULL); }
+
+  Hardware_parameter* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
+  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
+  void CopyFrom(const Hardware_parameter& from);
+  void MergeFrom(const Hardware_parameter& from);
+  void Clear() PROTOBUF_FINAL;
+  bool IsInitialized() const PROTOBUF_FINAL;
+
+  size_t ByteSizeLong() const PROTOBUF_FINAL;
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
+  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const PROTOBUF_FINAL;
+  void InternalSwap(Hardware_parameter* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return NULL;
+  }
+  inline void* MaybeArenaPtr() const {
+    return NULL;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // repeated .Hardware_limit.Railing railing_parameter = 1;
+  int railing_parameter_size() const;
+  void clear_railing_parameter();
+  static const int kRailingParameterFieldNumber = 1;
+  const ::Hardware_limit::Railing& railing_parameter(int index) const;
+  ::Hardware_limit::Railing* mutable_railing_parameter(int index);
+  ::Hardware_limit::Railing* add_railing_parameter();
+  ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Railing >*
+      mutable_railing_parameter();
+  const ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Railing >&
+      railing_parameter() const;
+
+  // repeated .Hardware_limit.Theta_range theta_range = 6;
+  int theta_range_size() const;
+  void clear_theta_range();
+  static const int kThetaRangeFieldNumber = 6;
+  const ::Hardware_limit::Theta_range& theta_range(int index) const;
+  ::Hardware_limit::Theta_range* mutable_theta_range(int index);
+  ::Hardware_limit::Theta_range* add_theta_range();
+  ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Theta_range >*
+      mutable_theta_range();
+  const ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Theta_range >&
+      theta_range() const;
+
+  // required float min_y = 2;
+  bool has_min_y() const;
+  void clear_min_y();
+  static const int kMinYFieldNumber = 2;
+  float min_y() const;
+  void set_min_y(float value);
+
+  // required float max_y = 3;
+  bool has_max_y() const;
+  void clear_max_y();
+  static const int kMaxYFieldNumber = 3;
+  float max_y() const;
+  void set_max_y(float value);
+
+  // required float min_x = 4;
+  bool has_min_x() const;
+  void clear_min_x();
+  static const int kMinXFieldNumber = 4;
+  float min_x() const;
+  void set_min_x(float value);
+
+  // required float max_x = 5;
+  bool has_max_x() const;
+  void clear_max_x();
+  static const int kMaxXFieldNumber = 5;
+  float max_x() const;
+  void set_max_x(float value);
+
+  // required float height = 7;
+  bool has_height() const;
+  void clear_height();
+  static const int kHeightFieldNumber = 7;
+  float height() const;
+  void set_height(float value);
+
+  // @@protoc_insertion_point(class_scope:Hardware_limit.Hardware_parameter)
+ private:
+  void set_has_min_y();
+  void clear_has_min_y();
+  void set_has_max_y();
+  void clear_has_max_y();
+  void set_has_min_x();
+  void clear_has_min_x();
+  void set_has_max_x();
+  void clear_has_max_x();
+  void set_has_height();
+  void clear_has_height();
+
+  // helper for ByteSizeLong()
+  size_t RequiredFieldsByteSizeFallback() const;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::HasBits<1> _has_bits_;
+  mutable int _cached_size_;
+  ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Railing > railing_parameter_;
+  ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Theta_range > theta_range_;
+  float min_y_;
+  float max_y_;
+  float min_x_;
+  float max_x_;
+  float height_;
+  friend struct ::protobuf_hardware_5flimit_2eproto::TableStruct;
+  friend void ::protobuf_hardware_5flimit_2eproto::InitDefaultsHardware_parameterImpl();
+};
+// ===================================================================
+
+
+// ===================================================================
+
+#ifdef __GNUC__
+  #pragma GCC diagnostic push
+  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif  // __GNUC__
+// Railing
+
+// required float pa = 1;
+inline bool Railing::has_pa() const {
+  return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void Railing::set_has_pa() {
+  _has_bits_[0] |= 0x00000001u;
+}
+inline void Railing::clear_has_pa() {
+  _has_bits_[0] &= ~0x00000001u;
+}
+inline void Railing::clear_pa() {
+  pa_ = 0;
+  clear_has_pa();
+}
+inline float Railing::pa() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Railing.pa)
+  return pa_;
+}
+inline void Railing::set_pa(float value) {
+  set_has_pa();
+  pa_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Railing.pa)
+}
+
+// required float pb = 2;
+inline bool Railing::has_pb() const {
+  return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void Railing::set_has_pb() {
+  _has_bits_[0] |= 0x00000002u;
+}
+inline void Railing::clear_has_pb() {
+  _has_bits_[0] &= ~0x00000002u;
+}
+inline void Railing::clear_pb() {
+  pb_ = 0;
+  clear_has_pb();
+}
+inline float Railing::pb() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Railing.pb)
+  return pb_;
+}
+inline void Railing::set_pb(float value) {
+  set_has_pb();
+  pb_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Railing.pb)
+}
+
+// required float pc = 3;
+inline bool Railing::has_pc() const {
+  return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void Railing::set_has_pc() {
+  _has_bits_[0] |= 0x00000004u;
+}
+inline void Railing::clear_has_pc() {
+  _has_bits_[0] &= ~0x00000004u;
+}
+inline void Railing::clear_pc() {
+  pc_ = 0;
+  clear_has_pc();
+}
+inline float Railing::pc() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Railing.pc)
+  return pc_;
+}
+inline void Railing::set_pc(float value) {
+  set_has_pc();
+  pc_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Railing.pc)
+}
+
+// optional float railing_width = 4 [default = 0];
+inline bool Railing::has_railing_width() const {
+  return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void Railing::set_has_railing_width() {
+  _has_bits_[0] |= 0x00000008u;
+}
+inline void Railing::clear_has_railing_width() {
+  _has_bits_[0] &= ~0x00000008u;
+}
+inline void Railing::clear_railing_width() {
+  railing_width_ = 0;
+  clear_has_railing_width();
+}
+inline float Railing::railing_width() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Railing.railing_width)
+  return railing_width_;
+}
+inline void Railing::set_railing_width(float value) {
+  set_has_railing_width();
+  railing_width_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Railing.railing_width)
+}
+
+// -------------------------------------------------------------------
+
+// Theta_range
+
+// required float min_theta = 1;
+inline bool Theta_range::has_min_theta() const {
+  return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void Theta_range::set_has_min_theta() {
+  _has_bits_[0] |= 0x00000001u;
+}
+inline void Theta_range::clear_has_min_theta() {
+  _has_bits_[0] &= ~0x00000001u;
+}
+inline void Theta_range::clear_min_theta() {
+  min_theta_ = 0;
+  clear_has_min_theta();
+}
+inline float Theta_range::min_theta() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Theta_range.min_theta)
+  return min_theta_;
+}
+inline void Theta_range::set_min_theta(float value) {
+  set_has_min_theta();
+  min_theta_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Theta_range.min_theta)
+}
+
+// required float max_theta = 2;
+inline bool Theta_range::has_max_theta() const {
+  return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void Theta_range::set_has_max_theta() {
+  _has_bits_[0] |= 0x00000002u;
+}
+inline void Theta_range::clear_has_max_theta() {
+  _has_bits_[0] &= ~0x00000002u;
+}
+inline void Theta_range::clear_max_theta() {
+  max_theta_ = 0;
+  clear_has_max_theta();
+}
+inline float Theta_range::max_theta() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Theta_range.max_theta)
+  return max_theta_;
+}
+inline void Theta_range::set_max_theta(float value) {
+  set_has_max_theta();
+  max_theta_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Theta_range.max_theta)
+}
+
+// -------------------------------------------------------------------
+
+// Hardware_parameter
+
+// repeated .Hardware_limit.Railing railing_parameter = 1;
+inline int Hardware_parameter::railing_parameter_size() const {
+  return railing_parameter_.size();
+}
+inline void Hardware_parameter::clear_railing_parameter() {
+  railing_parameter_.Clear();
+}
+inline const ::Hardware_limit::Railing& Hardware_parameter::railing_parameter(int index) const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.railing_parameter)
+  return railing_parameter_.Get(index);
+}
+inline ::Hardware_limit::Railing* Hardware_parameter::mutable_railing_parameter(int index) {
+  // @@protoc_insertion_point(field_mutable:Hardware_limit.Hardware_parameter.railing_parameter)
+  return railing_parameter_.Mutable(index);
+}
+inline ::Hardware_limit::Railing* Hardware_parameter::add_railing_parameter() {
+  // @@protoc_insertion_point(field_add:Hardware_limit.Hardware_parameter.railing_parameter)
+  return railing_parameter_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Railing >*
+Hardware_parameter::mutable_railing_parameter() {
+  // @@protoc_insertion_point(field_mutable_list:Hardware_limit.Hardware_parameter.railing_parameter)
+  return &railing_parameter_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Railing >&
+Hardware_parameter::railing_parameter() const {
+  // @@protoc_insertion_point(field_list:Hardware_limit.Hardware_parameter.railing_parameter)
+  return railing_parameter_;
+}
+
+// required float min_y = 2;
+inline bool Hardware_parameter::has_min_y() const {
+  return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void Hardware_parameter::set_has_min_y() {
+  _has_bits_[0] |= 0x00000001u;
+}
+inline void Hardware_parameter::clear_has_min_y() {
+  _has_bits_[0] &= ~0x00000001u;
+}
+inline void Hardware_parameter::clear_min_y() {
+  min_y_ = 0;
+  clear_has_min_y();
+}
+inline float Hardware_parameter::min_y() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.min_y)
+  return min_y_;
+}
+inline void Hardware_parameter::set_min_y(float value) {
+  set_has_min_y();
+  min_y_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Hardware_parameter.min_y)
+}
+
+// required float max_y = 3;
+inline bool Hardware_parameter::has_max_y() const {
+  return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void Hardware_parameter::set_has_max_y() {
+  _has_bits_[0] |= 0x00000002u;
+}
+inline void Hardware_parameter::clear_has_max_y() {
+  _has_bits_[0] &= ~0x00000002u;
+}
+inline void Hardware_parameter::clear_max_y() {
+  max_y_ = 0;
+  clear_has_max_y();
+}
+inline float Hardware_parameter::max_y() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.max_y)
+  return max_y_;
+}
+inline void Hardware_parameter::set_max_y(float value) {
+  set_has_max_y();
+  max_y_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Hardware_parameter.max_y)
+}
+
+// required float min_x = 4;
+inline bool Hardware_parameter::has_min_x() const {
+  return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void Hardware_parameter::set_has_min_x() {
+  _has_bits_[0] |= 0x00000004u;
+}
+inline void Hardware_parameter::clear_has_min_x() {
+  _has_bits_[0] &= ~0x00000004u;
+}
+inline void Hardware_parameter::clear_min_x() {
+  min_x_ = 0;
+  clear_has_min_x();
+}
+inline float Hardware_parameter::min_x() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.min_x)
+  return min_x_;
+}
+inline void Hardware_parameter::set_min_x(float value) {
+  set_has_min_x();
+  min_x_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Hardware_parameter.min_x)
+}
+
+// required float max_x = 5;
+inline bool Hardware_parameter::has_max_x() const {
+  return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void Hardware_parameter::set_has_max_x() {
+  _has_bits_[0] |= 0x00000008u;
+}
+inline void Hardware_parameter::clear_has_max_x() {
+  _has_bits_[0] &= ~0x00000008u;
+}
+inline void Hardware_parameter::clear_max_x() {
+  max_x_ = 0;
+  clear_has_max_x();
+}
+inline float Hardware_parameter::max_x() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.max_x)
+  return max_x_;
+}
+inline void Hardware_parameter::set_max_x(float value) {
+  set_has_max_x();
+  max_x_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Hardware_parameter.max_x)
+}
+
+// repeated .Hardware_limit.Theta_range theta_range = 6;
+inline int Hardware_parameter::theta_range_size() const {
+  return theta_range_.size();
+}
+inline void Hardware_parameter::clear_theta_range() {
+  theta_range_.Clear();
+}
+inline const ::Hardware_limit::Theta_range& Hardware_parameter::theta_range(int index) const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.theta_range)
+  return theta_range_.Get(index);
+}
+inline ::Hardware_limit::Theta_range* Hardware_parameter::mutable_theta_range(int index) {
+  // @@protoc_insertion_point(field_mutable:Hardware_limit.Hardware_parameter.theta_range)
+  return theta_range_.Mutable(index);
+}
+inline ::Hardware_limit::Theta_range* Hardware_parameter::add_theta_range() {
+  // @@protoc_insertion_point(field_add:Hardware_limit.Hardware_parameter.theta_range)
+  return theta_range_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Theta_range >*
+Hardware_parameter::mutable_theta_range() {
+  // @@protoc_insertion_point(field_mutable_list:Hardware_limit.Hardware_parameter.theta_range)
+  return &theta_range_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::Hardware_limit::Theta_range >&
+Hardware_parameter::theta_range() const {
+  // @@protoc_insertion_point(field_list:Hardware_limit.Hardware_parameter.theta_range)
+  return theta_range_;
+}
+
+// required float height = 7;
+inline bool Hardware_parameter::has_height() const {
+  return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void Hardware_parameter::set_has_height() {
+  _has_bits_[0] |= 0x00000010u;
+}
+inline void Hardware_parameter::clear_has_height() {
+  _has_bits_[0] &= ~0x00000010u;
+}
+inline void Hardware_parameter::clear_height() {
+  height_ = 0;
+  clear_has_height();
+}
+inline float Hardware_parameter::height() const {
+  // @@protoc_insertion_point(field_get:Hardware_limit.Hardware_parameter.height)
+  return height_;
+}
+inline void Hardware_parameter::set_height(float value) {
+  set_has_height();
+  height_ = value;
+  // @@protoc_insertion_point(field_set:Hardware_limit.Hardware_parameter.height)
+}
+
+#ifdef __GNUC__
+  #pragma GCC diagnostic pop
+#endif  // __GNUC__
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+}  // namespace Hardware_limit
+
+// @@protoc_insertion_point(global_scope)
+
+#endif  // PROTOBUF_hardware_5flimit_2eproto__INCLUDED

+ 28 - 0
src/verify/hardware_limit.proto

@@ -0,0 +1,28 @@
+syntax="proto2";
+package Hardware_limit;
+
+//栏杆
+message Railing
+{
+    required float pa=1;
+    required float pb=2;
+    required float pc=3;
+    optional float railing_width=4 [default=0];
+}
+
+message Theta_range
+{
+    required float min_theta=1;
+    required float max_theta=2;
+}
+
+message Hardware_parameter
+{
+    repeated Railing railing_parameter=1;
+    required float min_y=2;
+    required float max_y=3;
+    required float min_x=4;
+    required float max_x=5;
+    repeated Theta_range theta_range=6;
+    required float height=7;
+}

+ 8 - 3
src/wj_lidar/plc_data.cpp

@@ -160,15 +160,20 @@ void Plc_data::plc_update_thread(Plc_data *p)
                     temp = *(p->m_data + i);
                     //                temp =HTON(temp);
                     //printf("%d ---->%d\n",*(p->m_data+i), temp);
-                    // 门处于开启状态,判断车辆状态,聚类数量超过4类则不提示
+                    // 门处于开启状态,判断车辆状态,聚类数量错误则不提示
                     if (p->m_door_status[i] == 1)
                     {
-                        p->mb_is_ready = p->mb_is_ready && p->m_plc.WriteShorts(ELE_FENCE_DB_NUM, ELE_FENCE_START_ADDR + i * ELE_FENCE_OFFSET, 1, &temp);
+                        p->mb_is_ready = p->mb_is_ready && p->m_plc.WriteShorts(ELE_FENCE_DB_NUM, ELE_FENCE_BOUNDARY_START_ADDR + i * ELE_FENCE_OFFSET, 1, &temp);
                     }
                     // 门处于关闭状态,异物入侵判断模式,只要存在识别错误情况就输入1,否则0
                     else
                     {
-
+                        // plc是否安全位,0表示不安全,1表示安全
+                        if(temp != 1 && temp != 0)
+                            temp = 0;
+                        else
+                            temp = 1;
+                        p->mb_is_ready = p->mb_is_ready && p->m_plc.WriteShorts(ELE_FENCE_DB_NUM, ELE_FENCE_SAFE_START_ADDR + i * ELE_FENCE_OFFSET, 1, &temp);
                     }
                     g_lock.unlock();
                     usleep(50 * 1000);

+ 3 - 2
src/wj_lidar/plc_data.h

@@ -16,13 +16,14 @@
 #include "glog/logging.h"
 
 #define MAX_REGIONS 6
-#define ELE_FENCE_START_ADDR 4
+#define ELE_FENCE_SAFE_START_ADDR 3
+#define ELE_FENCE_BOUNDARY_START_ADDR 4
 #define ELE_FENCE_DB_NUM 95
 #define ELE_FENCE_OFFSET 7
 #define ELE_FENCE_COUNT 6
 
 #define CENTRAL_CONTROLLER_DB_NUM 41
-#define DOOR_STATUS_OFFSET 36
+#define DOOR_STATUS_OFFSET 18
 
 #define HTON(T) ((T) << 8) | ((T) >> 8)
 

+ 1 - 2
src/wj_lidar/wj_716_lidar_protocol.cpp

@@ -526,8 +526,7 @@ Error_manager Wj_716_lidar_protocol::check_xor(char *recvbuf, int recvlen)
  * */
 bool Wj_716_lidar_protocol::get_initialize_status()
 {
-  return true;
-  // return mb_initialized;
+  return mb_initialized;
 }
 
 } // namespace wj_lidar