|
@@ -94,7 +94,7 @@ char& CBinaryData::operator[](int n)
|
|
|
}
|
|
|
//////////////
|
|
|
|
|
|
-CLaser::CLaser(int id, Automatic::stLaserCalibParam laser_param)
|
|
|
+Laser_base::Laser_base(int id, Laser_proto::laser_parameter laser_param)
|
|
|
:m_ThreadRcv(0)
|
|
|
,m_ThreadPro(0)
|
|
|
,m_ThreadPub(0)
|
|
@@ -112,7 +112,7 @@ CLaser::CLaser(int id, Automatic::stLaserCalibParam laser_param)
|
|
|
}
|
|
|
|
|
|
|
|
|
-CLaser::~CLaser()
|
|
|
+Laser_base::~Laser_base()
|
|
|
{
|
|
|
if (m_dMatrix)
|
|
|
{
|
|
@@ -121,7 +121,12 @@ CLaser::~CLaser()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool CLaser::Start()
|
|
|
+Error_manager Laser_base::check_error()
|
|
|
+{
|
|
|
+ return SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
+bool Laser_base::Start()
|
|
|
{
|
|
|
m_bscan_start=true;
|
|
|
m_statu = eLaser_busy;
|
|
@@ -130,7 +135,7 @@ bool CLaser::Start()
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool CLaser::Stop()
|
|
|
+bool Laser_base::Stop()
|
|
|
{
|
|
|
m_bscan_start=false;
|
|
|
m_bStart_capture.Notify(false);
|
|
@@ -150,7 +155,7 @@ bool CLaser::Stop()
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void CLaser::SetMetrix(double* data)
|
|
|
+void Laser_base::SetMetrix(double* data)
|
|
|
{
|
|
|
if (m_dMatrix == 0)
|
|
|
{
|
|
@@ -158,22 +163,22 @@ void CLaser::SetMetrix(double* data)
|
|
|
}
|
|
|
memcpy(m_dMatrix, data, 12 * sizeof(double));
|
|
|
}
|
|
|
-void CLaser::SetPointCallBack(PointCallBack fnc, void* pointer)
|
|
|
+void Laser_base::SetPointCallBack(PointCallBack fnc, void* pointer)
|
|
|
{
|
|
|
m_point_callback_fnc = fnc;
|
|
|
m_point_callback_pointer = pointer;
|
|
|
}
|
|
|
|
|
|
-bool CLaser::Connect()
|
|
|
+bool Laser_base::Connect()
|
|
|
{
|
|
|
m_bThreadRcvRun.Notify(true);
|
|
|
if(m_ThreadRcv==0)
|
|
|
- m_ThreadRcv = new std::thread(&CLaser::thread_recv, this);
|
|
|
+ m_ThreadRcv = new std::thread(&Laser_base::thread_recv, this);
|
|
|
m_ThreadRcv->detach();
|
|
|
|
|
|
m_bThreadProRun.Notify(true);
|
|
|
if(m_ThreadPro==0)
|
|
|
- m_ThreadPro = new std::thread(&CLaser::thread_toXYZ, this);
|
|
|
+ m_ThreadPro = new std::thread(&Laser_base::thread_toXYZ, this);
|
|
|
m_ThreadPro->detach();
|
|
|
|
|
|
if(m_ThreadPub==0)
|
|
@@ -182,7 +187,7 @@ bool CLaser::Connect()
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
-void CLaser::Disconnect()
|
|
|
+void Laser_base::Disconnect()
|
|
|
{
|
|
|
if (m_ThreadRcv)
|
|
|
{
|
|
@@ -207,46 +212,44 @@ void CLaser::Disconnect()
|
|
|
|
|
|
//对外的接口函数,负责接受并处理任务单,
|
|
|
//input:laser_task 雷达任务单,必须是子类,并且任务正确。(传引用)
|
|
|
-Error_manager CLaser::porform_task(Laser_task* p_laser_task)
|
|
|
+Error_manager Laser_base::execute_task(Task_Base* p_laser_task)
|
|
|
{
|
|
|
Error_manager t_error_manager;
|
|
|
//检查指针
|
|
|
if(p_laser_task == NULL)
|
|
|
{
|
|
|
return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
|
|
|
- "CLaser::porform_task failed, POINTER_IS_NULL");
|
|
|
+ "Laser_base::porform_task failed, POINTER_IS_NULL");
|
|
|
}
|
|
|
- else
|
|
|
+ if(p_laser_task->get_task_type()!=LASER_TASK)
|
|
|
{
|
|
|
- //接受任务,并将任务的状态改为TASK_SIGNED已签收
|
|
|
- mp_laser_task = p_laser_task;
|
|
|
- mp_laser_task->set_task_statu(TASK_SIGNED);
|
|
|
+ return Error_manager(Error_code::LASER_TASK_TYPE_ERROR, Error_level::MINOR_ERROR,
|
|
|
+ "laser task type error");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //接受任务,并将任务的状态改为TASK_SIGNED已签收
|
|
|
+ mp_laser_task = (Laser_task*)p_laser_task;
|
|
|
+ mp_laser_task->set_task_statu(TASK_SIGNED);
|
|
|
+
|
|
|
+
|
|
|
//检查消息内容是否正确,
|
|
|
//检查点云指针
|
|
|
- if(p_laser_task->get_task_point3d_cloud_vector() == NULL)
|
|
|
+ if(mp_laser_task->get_task_point3d_cloud_vector().get() == NULL)
|
|
|
{
|
|
|
t_error_manager.error_manager_reset(Error_code::POINTER_IS_NULL,
|
|
|
Error_level::MINOR_ERROR,
|
|
|
- "CLaser::porform_task failed, POINTER_IS_NULL");
|
|
|
- }
|
|
|
- //检查任务类型
|
|
|
- else if(p_laser_task->get_task_type() != LASER_TASK)
|
|
|
- {
|
|
|
- t_error_manager.error_manager_reset(Error_code::LASER_TASK_PARAMETER_ERROR,
|
|
|
- Error_level::MINOR_ERROR,
|
|
|
- "CLaser::porform_task failed, task_type is error");
|
|
|
+ "Laser_base::porform_task failed, POINTER_IS_NULL");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//将任务的状态改为 TASK_WORKING 处理中
|
|
|
mp_laser_task->set_task_statu(TASK_WORKING);
|
|
|
-
|
|
|
+ std::string save_path=mp_laser_task->get_save_path();
|
|
|
+ SetSaveDir(save_path);
|
|
|
//启动雷达扫描
|
|
|
Start();
|
|
|
}
|
|
|
-
|
|
|
//返回错误码
|
|
|
if(t_error_manager != Error_code::SUCCESS)
|
|
|
{
|
|
@@ -256,7 +259,7 @@ Error_manager CLaser::porform_task(Laser_task* p_laser_task)
|
|
|
}
|
|
|
|
|
|
|
|
|
-void CLaser::SetSaveDir(std::string strDir,bool bSaveFile)
|
|
|
+void Laser_base::SetSaveDir(std::string strDir,bool bSaveFile)
|
|
|
{
|
|
|
m_bSave_file = bSaveFile;
|
|
|
m_pts_log_tool.close();
|
|
@@ -275,7 +278,7 @@ void CLaser::SetSaveDir(std::string strDir,bool bSaveFile)
|
|
|
m_binary_log_tool.open(bin_file,true);
|
|
|
}
|
|
|
|
|
|
-void CLaser::thread_recv()
|
|
|
+void Laser_base::thread_recv()
|
|
|
{
|
|
|
while (m_bThreadRcvRun.WaitFor(1))
|
|
|
{
|
|
@@ -295,7 +298,7 @@ void CLaser::thread_recv()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-CPoint3D CLaser::transfor(CPoint3D point)
|
|
|
+CPoint3D Laser_base::transfor(CPoint3D point)
|
|
|
{
|
|
|
if (m_dMatrix)
|
|
|
{
|
|
@@ -314,7 +317,7 @@ CPoint3D CLaser::transfor(CPoint3D point)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void CLaser::thread_toXYZ()
|
|
|
+void Laser_base::thread_toXYZ()
|
|
|
{
|
|
|
while (m_bThreadProRun.WaitFor(1))
|
|
|
{
|
|
@@ -351,8 +354,6 @@ void CLaser::thread_toXYZ()
|
|
|
for (int i = 0; i < cloud.size(); ++i)
|
|
|
{
|
|
|
CPoint3D point = transfor(cloud[i]);
|
|
|
- if (m_point_callback_fnc)
|
|
|
- m_point_callback_fnc(point, m_point_callback_pointer);
|
|
|
if(m_bSave_file) {
|
|
|
char buf[64] = {0};
|
|
|
sprintf(buf, "%f %f %f\n", point.x, point.y, point.z);
|
|
@@ -361,7 +362,10 @@ void CLaser::thread_toXYZ()
|
|
|
|
|
|
//此时cloud为雷达采集数据的结果,转换后的三维点云。
|
|
|
//将每个点存入任务单里面的点云容器。
|
|
|
- mp_laser_task->get_task_point3d_cloud_vector()->push_back(point);
|
|
|
+ if(mp_laser_task!=NULL)
|
|
|
+ {
|
|
|
+ mp_laser_task->get_task_point3d_cloud_vector()->push_back(pcl::PointXYZ(point.x,point.y,point.z));
|
|
|
+ }
|
|
|
}
|
|
|
m_points_count+=cloud.size();
|
|
|
if (type == eStop)
|
|
@@ -401,7 +405,7 @@ void CLaser::thread_toXYZ()
|
|
|
|
|
|
|
|
|
#include "unistd.h"
|
|
|
-void CLaser::threadPublish(CLaser *laser)
|
|
|
+void Laser_base::threadPublish(Laser_base *laser)
|
|
|
{
|
|
|
if(laser==0) return ;
|
|
|
while(laser->m_bThreadRcvRun.WaitFor(1))
|
|
@@ -411,10 +415,10 @@ void CLaser::threadPublish(CLaser *laser)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#include "../common.h"
|
|
|
-void CLaser::PublishMsg()
|
|
|
+
|
|
|
+void Laser_base::PublishMsg()
|
|
|
{
|
|
|
- globalmsg::msg msg;
|
|
|
+ /*globalmsg::msg msg;
|
|
|
msg.set_msg_type(globalmsg::eLaser);
|
|
|
|
|
|
globalmsg::laserStatus status;
|
|
@@ -427,5 +431,5 @@ void CLaser::PublishMsg()
|
|
|
msg.mutable_laser_msg()->set_laser_status(status);
|
|
|
msg.mutable_laser_msg()->set_queue_data_count(m_queue_laser_data.size());
|
|
|
msg.mutable_laser_msg()->set_cloud_count(m_points_count);
|
|
|
- MeasureTopicPublisher::GetInstance()->Publish(msg.SerializeAsString());
|
|
|
+ MeasureTopicPublisher::GetInstance()->Publish(msg.SerializeAsString());*/
|
|
|
}
|