|
@@ -298,6 +298,7 @@ void Terminor_Command_Executor::set_save_root_path(std::string root)
|
|
|
Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
std::lock_guard<std::mutex> lock(ms_mutex_scan_measure);
|
|
|
Error_manager code;
|
|
|
+ Error_manager t_result;
|
|
|
LOG(INFO) << ">>>>>>>>>>>> Enter terminator ID:" << m_terminor_parameter.id();
|
|
|
//计时起点
|
|
|
auto t_start_point = std::chrono::system_clock::now();
|
|
@@ -363,45 +364,82 @@ Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
m_terminor_statu = TERMINOR_SCANNING;
|
|
|
|
|
|
//等待雷达完成任务单
|
|
|
- while (1) {
|
|
|
+ while (1)
|
|
|
+ {
|
|
|
//判断是否强制退出
|
|
|
if (mb_force_quit == true) {
|
|
|
char description[255] = {0};
|
|
|
sprintf(description, "ternimal is force quit terminal id : %d", m_terminor_parameter.id());
|
|
|
return Error_manager(TERMINOR_FORCE_QUIT, NORMAL, description);
|
|
|
}
|
|
|
- //判断雷达任务单是否全部完成
|
|
|
- bool tb_laser_complete = true;
|
|
|
- for (int i = 0; i < laser_task_vector.size(); ++i) {
|
|
|
- tb_laser_complete &= (TASK_OVER == laser_task_vector[i]->get_statu());
|
|
|
- }
|
|
|
- if (tb_laser_complete) {
|
|
|
- break;
|
|
|
- }
|
|
|
- //计算扫描时间,若超时,并且没有点,则返回错误.
|
|
|
- auto t_end_point = std::chrono::system_clock::now();
|
|
|
- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(t_end_point - t_start_point);
|
|
|
- double second = double(duration.count()) *
|
|
|
- std::chrono::milliseconds::period::num / std::chrono::milliseconds::period::den;
|
|
|
- if (second > m_timeout_second) {
|
|
|
- //扫描超时,点云中没有点,则返回错误
|
|
|
- if (scan_cloud.size() == 0) {
|
|
|
- return Error_manager(TERMINOR_LASER_TIMEOUT, MAJOR_ERROR, "laser scanning timeout");
|
|
|
- }
|
|
|
|
|
|
+ int i = 0;
|
|
|
+ for (; i < laser_task_vector.size(); ++i)
|
|
|
+ {
|
|
|
+ if (laser_task_vector[i]->is_task_end() == false)
|
|
|
+ {
|
|
|
+ if (laser_task_vector[i]->is_over_time())
|
|
|
+ {
|
|
|
+ //超时处理。取消任务。
|
|
|
+// tp_lasers[i]->cancel_task();
|
|
|
+ tp_lasers[i]->stop_scan();
|
|
|
+ laser_task_vector[i]->set_task_statu(TASK_DEAD);
|
|
|
+ code.error_manager_reset(Error_code::LASER_TASK_OVER_TIME, Error_level::MINOR_ERROR,
|
|
|
+ " LASER_TASK is_over_time ");
|
|
|
+ laser_task_vector[i]->set_task_error_manager(code);
|
|
|
+
|
|
|
+ continue;
|
|
|
+ //本次子任务超时死亡.直接进行下一个
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //如果任务还在执行, 那就等待任务继续完成,等1ms
|
|
|
+ //std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
+ std::this_thread::yield();
|
|
|
+ break;
|
|
|
+ //注意了:这里break之后, i != laser_task_vector.size()
|
|
|
+ //这就表示仍然有子任务单没有结束.那就继续等待,,,直到所有任务完成或者超时.
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //else 任务完成就判断下一个
|
|
|
+ }
|
|
|
+ //如果下发的任务全部结束,那么汇总所有的结果, 并销毁下发的任务单。
|
|
|
+ if(i == laser_task_vector.size() )
|
|
|
+ {
|
|
|
+ for ( int j = 0; j < laser_task_vector.size(); ++j)
|
|
|
+ {
|
|
|
+ if (laser_task_vector[i] != 0) {
|
|
|
+ //数据汇总,
|
|
|
+ //由于 pcl::PointCloud<pcl::PointXYZ>::Ptr mp_task_point_cloud; 是所有任务单共用的,所以不用处理了。自动就在一起。
|
|
|
+ //错误汇总
|
|
|
+ t_result.compare_and_cover_error(laser_task_vector[j]->get_task_error_manager());
|
|
|
+ //销毁下发的任务单。
|
|
|
+ delete laser_task_vector[i];
|
|
|
+ laser_task_vector[i] = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ laser_task_vector.clear();
|
|
|
+ }
|
|
|
+ //else 直接通过, 然后重新进入 while (1)
|
|
|
|
|
|
- }
|
|
|
usleep(1000 * 100);
|
|
|
}
|
|
|
+
|
|
|
+ //暂时不做错误处理,
|
|
|
+ // 如果有个别雷达扫描故障, 取消雷达子任务之后, 忽略错误
|
|
|
+ //用其他正常的雷达扫描点云, 继续后面的流程,
|
|
|
+ // 交给locate去定位识别, 如果识别不出来, 由locate来报错.
|
|
|
+ if ( t_result != SUCCESS )
|
|
|
+ {
|
|
|
+ LOG(INFO) << " laser_task error :::: "<< t_result.to_string()<< this;
|
|
|
+// return t_result;
|
|
|
+ }
|
|
|
+
|
|
|
//检查雷达任务完成情况,是否是正常完成
|
|
|
LOG(INFO) << " laser scanning over cloud size:" << scan_cloud.size();
|
|
|
- //释放扫描任务单
|
|
|
- for (int i = 0; i < laser_task_vector.size(); ++i) {
|
|
|
- if (laser_task_vector[i] != 0) {
|
|
|
- delete laser_task_vector[i];
|
|
|
- laser_task_vector[i] = NULL;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//第二步,根据区域筛选点云
|
|
|
pcl::PointCloud<pcl::PointXYZ>::Ptr locate_cloud(new pcl::PointCloud<pcl::PointXYZ>);
|
|
@@ -482,32 +520,20 @@ Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
float offset_width = fabs(dj_locate_information.locate_width - wj_locate_information.locate_width);
|
|
|
float offset_wheel_base = fabs(
|
|
|
dj_locate_information.locate_wheel_base - wj_locate_information.locate_wheel_base);
|
|
|
- if (offset_x > 100 || offset_y > 100 || offset_angle > 4 || offset_wheel_base > 550 || offset_width > 200) {
|
|
|
- LOG(WARNING) << "chekc failed. (offset x>100, y>100, angle>4, wheel_base>550, width>200): " << offset_x
|
|
|
+ if (offset_x > 100 || offset_y > 150 || offset_angle > 5 || offset_wheel_base > 550 || offset_width > 250) {
|
|
|
+ LOG(WARNING) << "chekc failed. (offset x>100, y>150, angle>5, wheel_base>550, width>250): " << offset_x
|
|
|
<< " " << offset_y << " " << offset_angle << " " << offset_wheel_base << " " << offset_width;
|
|
|
return Error_manager(TERMINOR_CHECK_RESULTS_ERROR, NORMAL, "check results failed ");
|
|
|
}
|
|
|
- ///根据两个结果选择最优结果,角度选择两值加权,轴距已以2750为基准作卡尔曼滤波
|
|
|
+ ///根据sigmod函数计算角度权重
|
|
|
+ double angle_weight=1.0-1.0/(1.0+exp(-offset_angle/1.8));
|
|
|
+ ///根据两个结果选择最优结果,中心点选择万集雷达,角度选择两值加权,轴距已以2750为基准作卡尔曼滤波
|
|
|
///车长以大疆雷达为准,车宽以万集雷达为准,高以大疆雷达为准
|
|
|
- //m_measure_information.locate_x = wj_locate_information.locate_x;
|
|
|
- // m_measure_information.locate_y = wj_locate_information.locate_y;
|
|
|
- if (offset_angle < 2) {
|
|
|
- float r1=0.5;
|
|
|
- float r2=1.0-r1;
|
|
|
- m_measure_information.locate_theta =
|
|
|
- r1 * wj_locate_information.locate_theta + r2 * dj_locate_information.locate_theta;
|
|
|
- m_measure_information.locate_x=r1*wj_locate_information.locate_x+r2*dj_locate_information.locate_x;
|
|
|
- m_measure_information.locate_y=r1*wj_locate_information.locate_y+r2*dj_locate_information.locate_y;
|
|
|
- }
|
|
|
+ m_measure_information.locate_x = wj_locate_information.locate_x;
|
|
|
+ m_measure_information.locate_y = wj_locate_information.locate_y;
|
|
|
|
|
|
- else {
|
|
|
- float r1=0.1;
|
|
|
- float r2=1.0-r1;
|
|
|
- m_measure_information.locate_theta =
|
|
|
- r1 * wj_locate_information.locate_theta + r2 * dj_locate_information.locate_theta;
|
|
|
- m_measure_information.locate_x=r1*wj_locate_information.locate_x+r2*dj_locate_information.locate_x;
|
|
|
- m_measure_information.locate_y=r1*wj_locate_information.locate_y+r2*dj_locate_information.locate_y;
|
|
|
- }
|
|
|
+ m_measure_information.locate_theta =angle_weight * wj_locate_information.locate_theta +
|
|
|
+ (1.0-angle_weight) * dj_locate_information.locate_theta;
|
|
|
|
|
|
float dj_distance = fabs(dj_locate_information.locate_wheel_base - 2750);
|
|
|
float wj_distance = fabs(wj_locate_information.locate_wheel_base - 2750);
|