|
@@ -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, ¶meter);
|
|
|
+ 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;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|