فهرست منبع

20190106,对laser模块进行了优化,
1.laser_task_command的命名进行了重整。
2.laser增加了注释和部分优化
3.重载execute_task。

huli 5 سال پیش
والد
کامیت
cda2831129
3فایلهای تغییر یافته به همراه93 افزوده شده و 8 حذف شده
  1. 8 3
      laser/Laser.cpp
  2. 0 1
      laser/LivoxLaser.cpp
  3. 85 4
      main.cpp

+ 8 - 3
laser/Laser.cpp

@@ -355,13 +355,18 @@ void Laser_base::thread_toXYZ()
             {
                 if (pData == NULL)
                     continue;
-                m_binary_log_tool.write(pData->Data(), pData->Length());
+                if(m_bSave_file)
+                {
+                    m_binary_log_tool.write(pData->Data(), pData->Length());
+                }
                 type= this->Data2PointXYZ(pData, cloud);
             }
             else
             {
-                type = this->Data2PointXYZ(NULL, cloud);
+            	type = this->Data2PointXYZ(NULL, cloud);
             }
+
+
             if (type == eUnknow)
             {
                 delete pData;
@@ -384,7 +389,7 @@ void Laser_base::thread_toXYZ()
 
                     if(mp_laser_task!=NULL)
                     {
-                        Error_manager code=mp_laser_task->task_push_point(pcl::PointXYZ(point.x,point.y,point.z));
+                        Error_manager code= mp_laser_task->task_push_point(pcl::PointXYZ(point.x,point.y,point.z));
                     }
                 }
                 m_points_count+=cloud.size();

+ 0 - 1
laser/LivoxLaser.cpp

@@ -18,7 +18,6 @@ void CLivoxLaser::UpdataHandle()
 	{
 		m_handle = g_sn_handle[sn];
 	}
-
 }
 
 

+ 85 - 4
main.cpp

@@ -5,17 +5,98 @@
 
 #include "./laser/Laser.h"
 #include "./laser/LivoxLaser.h"
+#include "./error_code/error_code.h"
 
 #include <string.h>
+#include <fcntl.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
+//#include </usr/local/include/google/protobuf/io/zero_copy_stream_impl.h>
+using google::protobuf::io::FileInputStream;
+using google::protobuf::io::FileOutputStream;
+using google::protobuf::io::ZeroCopyInputStream;
+using google::protobuf::io::CodedInputStream;
+using google::protobuf::io::ZeroCopyOutputStream;
+using google::protobuf::io::CodedOutputStream;
+using google::protobuf::Message;
 
-#include "./error_code/error_code.h"
+#define O_RDONLY	     00
+//读取protobuf 配置文件
+//file:文件
+//parameter:要读取的配置
+bool read_proto_param(std::string file, ::google::protobuf::Message& parameter)
+{
+	int fd = open(file.c_str(), O_RDONLY);
+	if (fd == -1) return false;
+	FileInputStream* input = new FileInputStream(fd);
+	bool success = google::protobuf::TextFormat::Parse(input, &parameter);
+	delete input;
+	close(fd);
+	return success;
+}
 
 
 int main(int argc,char* argv[])
 {
-    std::cout << "Hello, World!" << std::endl;
+	std::cout << "start!" << std::endl;
+
+	Error_manager err;
+
+	Laser_base *m_laser_vector;
+
+	Laser_proto::Laser_parameter_all laser_parameters;
+
+	if (!read_proto_param("./setting/laser.prototxt", laser_parameters))
+	{
+		err.error_manager_reset(SYSTEM_READ_PARAMETER_ERROR, NORMAL, "read laser parameter failed");
+		cout << err.to_string() << endl;
+		return err.get_error_code();
+	}
+
+	int i = 0;
+	m_laser_vector = LaserRegistory::CreateLaser(laser_parameters.laser_parameters(i).type(), i,
+												 laser_parameters.laser_parameters(i));
+
+	if (m_laser_vector != NULL)
+	{
+		if (!m_laser_vector->Connect())
+		{
+			char description[255] = {0};
+			sprintf(description, "Laser %d connect failed...", i);
+			err.error_manager_reset(LASER_CONNECT_FAILED, NORMAL, description);
+			cout << err.to_string() << endl;
+			return err.get_error_code();
+		}
+		else
+		{
+			Uninit();
+		}
+
 
-//    CLivoxLaser t_livox_laser;
+		pcl::PointCloud<pcl::PointXYZ>::Ptr scan_cloud(new pcl::PointCloud<pcl::PointXYZ>);
+		std::mutex cloud_lock;
 
-    return 0;
+		Laser_task *laser_task = new Laser_task();
+		//
+		laser_task->task_init(TASK_CREATED, scan_cloud, &cloud_lock);
+		laser_task->set_task_frame_maxnum(1000);
+		laser_task->set_task_save_path("123");
+
+		//发送任务单给雷达
+		std::this_thread::sleep_for(std::chrono::seconds(2));
+		err = m_laser_vector->execute_task(laser_task);
+		cout << err.to_string() << endl;
+	}
+
+
+	int x;
+	cin >> x ;
+	cout << "end" << endl;
 }
+
+
+
+
+
+
+