123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- //
- // Created by zx on 2019/12/28.
- //
- #include <iostream>
- #include "./laser/laser_manager.h"
- #include "./laser/Laser.h"
- #include "./laser/LivoxLaser.h"
- #include "./locate/locate_manager.h"
- #include <iostream>
- #include <fstream>
- #include "./tool/communication_socket_base.h"
- #include "./error_code/error_code.h"
- #include "LogFiles.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;
- #define O_RDONLY 00
- #define LIVOX_NUMBER 2
- int main(int argc,char* argv[])
- {
- Communication_socket_base csb;
- std::vector<std::string> connect_string_vector;
- connect_string_vector.push_back("tcp://192.168.2.166:9001");
- csb.communication_init("tcp://192.168.2.166:9000", connect_string_vector);
- // csb.communication_init();
- char ch ;
- std::cin >> ch ;
- return 0;
- LOG(INFO) << " --- main start --- " ;
- Error_manager t_error;
- Error_manager t_result ;
- std::cout << "huli 101 main start!" << std::endl;
- std::cout << "1111111111111111111111" << std::endl;
- Laser_manager::get_instance_pointer()->laser_manager_init();
- Locate_manager::get_instance_pointer()->Locate_manager_init();
- Point_sift_segmentation* mp_point_sift;
- int point_size = 8192;
- int cls_num = 3;
- double freq = 20.0;
- std::string graph = "../model_param/seg_model_404500.ckpt.meta";
- std::string cpkt = "../model_param/seg_model_404500.ckpt";
- pcl::PointXYZ minp(-10000,-10000,-10000);
- pcl::PointXYZ maxp(10000,10000,10000);
- while(1)
- {
- std::cout << "huli 401 connect_laser Error_code::SUCCESS" << std::endl;
- std::cout << " press to start" << std::endl;
- char ch ;
- // = getchar();
- std::this_thread::sleep_for(std::chrono::seconds(2));
- std::cin >> ch ;
- if ( ch == 'b' )
- {
- std::cout << " end scan ------------" << std::endl;
- break;
- }
- std::cout << " start scan ------------" << std::endl;
- int n = 1;
- while(n)
- {
- n--;
- std::map<int,pcl::PointCloud<pcl::PointXYZ>::Ptr> point_cloud_map;
- std::mutex cloud_lock;
- std::vector<int> select_laser_id_vector;
- select_laser_id_vector.push_back(0);
- time_t nowTime;
- nowTime = time(NULL);
- struct tm* sysTime = localtime(&nowTime);
- char t_save_path[256] = { 0 };
- sprintf(t_save_path, "../data/%04d%02d%02d_%02d%02d%02d",
- sysTime->tm_year + 1900, sysTime->tm_mon + 1, sysTime->tm_mday, sysTime->tm_hour, sysTime->tm_min, sysTime->tm_sec);
- Laser_manager_task * laser_manager_task = new Laser_manager_task;
- laser_manager_task->task_init(TASK_CREATED,"",NULL,std::chrono::milliseconds(15000),
- true,t_save_path,&cloud_lock,&point_cloud_map,false,
- 1000,false,select_laser_id_vector );
- t_error = Task_command_manager::get_instance_references().execute_task(laser_manager_task);
- // tp_laser_manager->execute_task(laser_manager_task);
- if ( t_error != Error_code::SUCCESS )
- {
- std::cout << "huli Laser_manager:::::" << t_error.to_string() << std::endl;
- }
- else
- {
- while ( laser_manager_task->is_task_end() == false)
- {
- if ( laser_manager_task->is_over_time() )
- {
- //超时处理。取消任务。
- Laser_manager::get_instance_pointer()->cancel_task();
- laser_manager_task->set_task_statu(TASK_DEAD);
- t_error.error_manager_reset(Error_code::LASER_MANAGER_TASK_OVER_TIME, Error_level::MINOR_ERROR,
- " laser_manager_task is_over_time ");
- laser_manager_task->set_task_error_manager(t_error);
- }
- else
- {
- std::this_thread::yield();
- }
- }
- std::cout << "huli task_error::::" << laser_manager_task->get_task_error_manager().to_string() << std::endl;
- }
- delete(laser_manager_task);
- std::cout << "huli laser result---------------------" << t_error.to_string() << std::endl;
- std::cout << "huli zczxczxczx---------------------" << t_error.to_string() << std::endl;
- std::cout << "huli zczxczxczx---------------------" << t_error.to_string() << std::endl;
- std::cout << "huli zczxczxczx---------------------" << t_error.to_string() << std::endl;
- /*
- pcl::PointCloud<pcl::PointXYZ>::Ptr scan_cloud ;
- scan_cloud = point_cloud_map[0];
- //locate
- pcl::getMinMax3D(*scan_cloud,minp,maxp);
- std::cout << "huli 112" << std::endl;
- mp_point_sift = new Point_sift_segmentation(point_size,cls_num,freq,minp,maxp);
- std::cout << t_error.to_string() << std::endl;
- t_error = mp_point_sift->init(graph,cpkt);
- std::cout << t_error.to_string() << std::endl;
- std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> segmentation_clouds;
- t_error = mp_point_sift->segmentation(scan_cloud, segmentation_clouds, true, "../data/locate_data");
- std::cout << t_error.to_string() << std::endl;
- */
- Locate_manager_task * locate_manager_task = new Locate_manager_task;
- locate_manager_task->task_init(TASK_CREATED,"",NULL,std::chrono::milliseconds(15000),
- true,t_save_path,&cloud_lock,&point_cloud_map,true
- );
- t_error = Task_command_manager::get_instance_references().execute_task(locate_manager_task);
- if ( t_error != Error_code::SUCCESS )
- {
- std::cout << "huli Locate_manager:::::" << t_error.to_string() << std::endl;
- }
- else
- {
- while ( locate_manager_task->is_task_end() == false)
- {
- if ( locate_manager_task->is_over_time() )
- {
- //超时处理。取消任务。
- Locate_manager::get_instance_pointer()->cancel_task();
- locate_manager_task->set_task_statu(TASK_DEAD);
- t_error.error_manager_reset(Error_code::LOCATE_MANAGER_TASK_OVER_TIME, Error_level::MINOR_ERROR,
- " locate_manager_task is_over_time ");
- locate_manager_task->set_task_error_manager(t_error);
- }
- else
- {
- std::this_thread::yield();
- }
- }
- std::cout << "huli task_error:::::" << locate_manager_task->get_task_error_manager().to_string() << std::endl;
- }
- delete(locate_manager_task);
- std::cout << "huli locate result:::::" << t_error.to_string() << std::endl;
- }
- cout << "huli: 601 :" << t_error.to_string() << endl;
- std::this_thread::sleep_for(std::chrono::seconds(2));
- }
- Laser_manager::get_instance_pointer()->laser_manager_uninit();
- Locate_manager::get_instance_pointer()->Locate_manager_uninit();
- cout << "huli 1234 main end" << endl;
- std::this_thread::sleep_for(std::chrono::seconds(3));
- return 0;
- }
|