Browse Source

hl20200427,优化底层代码
1.为error新增,cout<<的重载
2.雷达任务单控制文件保存的标记位,
3.完善thread_condition的注释说明

huli 5 năm trước cách đây
mục cha
commit
3b2775be61
3 tập tin đã thay đổi với 29 bổ sung9 xóa
  1. 18 4
      laser/laser_task_command.cpp
  2. 6 2
      laser/laser_task_command.h
  3. 5 3
      main.cpp

+ 18 - 4
laser/laser_task_command.cpp

@@ -13,11 +13,13 @@ Laser_task::Laser_task()
     //构造函数锁定任务类型为LASER_TASK,后续不允许更改
     m_task_type = LASER_TASK;
     m_task_statu = TASK_CREATED;
-    //m_task_statu_information默认为空
+    m_task_statu_information.clear();
+	m_task_error_manager.error_manager_clear_all();
 
     m_task_frame_maxnum = 0;
+	m_task_save_flag = false;//默认不保存,false
+	m_task_save_path.clear();
     mp_task_point_cloud = NULL;
-    //m_task_error_manager 默认为空
     mp_task_cloud_lock=NULL;
 }
 //析构函数
@@ -47,11 +49,13 @@ Error_manager Laser_task::task_init(Task_statu task_statu,
 
     m_task_statu = task_statu;
     m_task_statu_information.clear();
+	m_task_error_manager.error_manager_clear_all();
 
     m_task_frame_maxnum = TASK_FRAME_MAXNUM_DEFAULT;
+	m_task_save_flag = false;
+	m_task_save_path.clear();
     mp_task_cloud_lock=p_task_cloud_lock;
     mp_task_point_cloud = p_task_point_cloud;
-    m_task_error_manager.error_manager_clear_all();
 
     return Error_code::SUCCESS;
 }
@@ -67,7 +71,9 @@ Error_manager Laser_task::task_init(Task_statu task_statu,
                                     std::string & task_statu_information,
                                     unsigned int task_frame_maxnum,
                                     pcl::PointCloud<pcl::PointXYZ>::Ptr p_task_point_cloud,
-                                    std::mutex* p_task_cloud_lock)
+                                    std::mutex* p_task_cloud_lock,
+                                    bool task_save_flag ,
+									std::string task_save_path )
 {
     if(p_task_point_cloud.get() == NULL)
     {
@@ -90,6 +96,8 @@ Error_manager Laser_task::task_init(Task_statu task_statu,
     {
         m_task_frame_maxnum = task_frame_maxnum;
     }
+	m_task_save_flag = task_save_flag;
+	m_task_save_path = task_save_path;
     mp_task_cloud_lock=p_task_cloud_lock;
     mp_task_point_cloud = p_task_point_cloud;
     m_task_error_manager.error_manager_clear_all();
@@ -170,6 +178,12 @@ void Laser_task::set_task_save_path(std::string task_save_path)
 {
     m_task_save_path=task_save_path;
 }
+//设置采集的点云保存标志位和路径
+void Laser_task::set_task_save_flag_and_path(bool task_save_flag, std::string task_save_path)
+{
+	m_task_save_flag=task_save_flag;
+	m_task_save_path=task_save_path;
+}
 //设置 三维点云容器的智能指针
 void Laser_task::set_task_point_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr p_task_point_cloud)
 {

+ 6 - 2
laser/laser_task_command.h

@@ -53,7 +53,9 @@ public:
                             std::string & task_statu_information,
                             unsigned int task_frame_maxnum,
                             pcl::PointCloud<pcl::PointXYZ>::Ptr p_task_point_cloud,
-                            std::mutex* p_task_cloud_lock);
+                            std::mutex* p_task_cloud_lock,
+							bool task_save_flag = false,
+							std::string task_save_path = "");
 
     //push点云,把 point_xyz 添加到 p_task_point_cloud 里面。
     Error_manager task_push_point(pcl::PointXYZ point_xyz);
@@ -82,6 +84,8 @@ public:
 	void set_task_save_flag(bool task_save_flag);
 	//设置采集的点云保存路径
     void set_task_save_path(std::string task_save_path);
+	//设置采集的点云保存标志位和路径
+	void set_task_save_flag_and_path(bool task_save_flag, std::string task_save_path);
     //设置 三维点云容器的智能指针
     void set_task_point_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr p_task_point_cloud);
     //设置 错误码
@@ -92,7 +96,7 @@ protected:
     //点云的采集帧数最大值,任务输入
     unsigned int                    m_task_frame_maxnum;
 
-	//雷达保存文件的使能标志位
+	//雷达保存文件的使能标志位,//默认不保存,false
 	bool		 					m_task_save_flag;
     //点云保存文件的路径,任务输入
     std::string                     m_task_save_path;

+ 5 - 3
main.cpp

@@ -49,6 +49,10 @@ int main(int argc,char* argv[])
 
 	Laser_base * m_laser_vector_array[LIVOX_NUMBER];
 	Error_manager err;
+	std::cout << err << std::endl;
+	std::string asd = "";
+	std::cout << asd.empty() << std::endl;
+
 
 	for (int i = 0; i < LIVOX_NUMBER; ++i)
 	{
@@ -153,9 +157,7 @@ int main(int argc,char* argv[])
 			{
 				char time_string[256] = { 0 };
 				sprintf(time_string, "../data/%d/", i);
-				laser_task->set_task_save_path(time_string);
-				laser_task->set_task_save_flag(true);
-
+				laser_task->set_task_save_flag_and_path(true,time_string);
 				err = m_laser_vector_array[i]->execute_task(laser_task);
 //				usleep(3000 * 1000);
 			}