|
@@ -295,6 +295,22 @@ void Terminor_Command_Executor::set_save_root_path(std::string root)
|
|
|
m_save_root_path=root;
|
|
|
}
|
|
|
|
|
|
+// !!!!!!!!!!!! 临时使用,保存点云debug
|
|
|
+void save_cloud_txt(std::string txt, pcl::PointCloud<pcl::PointXYZ>::Ptr pCloud)
|
|
|
+{
|
|
|
+ std::ofstream os;
|
|
|
+ os.open(txt, std::ios::out);
|
|
|
+ for (int i = 0; i < pCloud->points.size(); i++)
|
|
|
+ {
|
|
|
+ pcl::PointXYZ point = pCloud->points[i];
|
|
|
+ char buf[255];
|
|
|
+ memset(buf, 0, 255);
|
|
|
+ sprintf(buf, "%f %f %f\n", point.x, point.y, point.z);
|
|
|
+ os.write(buf, strlen(buf));
|
|
|
+ }
|
|
|
+ os.close();
|
|
|
+}
|
|
|
+
|
|
|
Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
std::lock_guard<std::mutex> lock(ms_mutex_scan_measure);
|
|
|
Error_manager code;
|
|
@@ -435,6 +451,9 @@ Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
m_measure_information.locate_correct = false;
|
|
|
//获取测量结果
|
|
|
Locate_information dj_locate_information = locate_task->get_locate_information();
|
|
|
+ //added by yct, 获取车轮点云
|
|
|
+ pcl::PointCloud<pcl::PointXYZ>::Ptr t_combined_wheel_cloud(new pcl::PointCloud<pcl::PointXYZ>);
|
|
|
+ t_combined_wheel_cloud = locate_task->get_locate_cloud();
|
|
|
//释放locate task
|
|
|
if (locate_task != NULL) {
|
|
|
delete locate_task;
|
|
@@ -465,6 +484,14 @@ Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
///万集测量正确,对比两数据
|
|
|
wj_measure_result wj_result;
|
|
|
code = wj_task->get_result(wj_result);
|
|
|
+ //added by yct, wj wheel cloud
|
|
|
+ pcl::PointCloud<pcl::PointXYZ> t_wj_wheel = wj_task->get_cloud();
|
|
|
+ for (int m = 0; m < t_wj_wheel.size(); ++m) {
|
|
|
+ t_wj_wheel[m].x *= 1000.0;
|
|
|
+ t_wj_wheel[m].y *= 1000.0;
|
|
|
+ t_wj_wheel[m].z *= 1000.0;
|
|
|
+ }
|
|
|
+ t_combined_wheel_cloud->operator+=(t_wj_wheel);
|
|
|
if (code != SUCCESS) {
|
|
|
delete wj_task;
|
|
|
return code;
|
|
@@ -488,7 +515,9 @@ Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
return Error_manager(TERMINOR_CHECK_RESULTS_ERROR, NORMAL, "check results failed ");
|
|
|
}
|
|
|
///根据sigmod函数计算角度权重
|
|
|
- double angle_weight=1.0-1.0/(1.0+exp(-offset_angle/1.8));
|
|
|
+// double angle_weight=1.0-1.0/(1.0+exp(-offset_angle/1.8));
|
|
|
+ // added by yct, 角度偏差越大,越倾向于万集,之后校验结果
|
|
|
+ double angle_weight=1.0/(1.0+exp(-offset_angle/0.5));
|
|
|
///根据两个结果选择最优结果,中心点选择万集雷达,角度选择两值加权,轴距已以2750为基准作卡尔曼滤波
|
|
|
///车长以大疆雷达为准,车宽以万集雷达为准,高以大疆雷达为准
|
|
|
m_measure_information.locate_x = wj_locate_information.locate_x;
|
|
@@ -508,7 +537,54 @@ Error_manager Terminor_Command_Executor::scanning_measuring() {
|
|
|
m_measure_information.locate_length = dj_locate_information.locate_length;
|
|
|
m_measure_information.locate_width = wj_locate_information.locate_width;
|
|
|
m_measure_information.locate_hight = dj_locate_information.locate_hight;
|
|
|
+ // 20210527 added by yct
|
|
|
+ // 6号位标定地面偏低,高度增加21mm
|
|
|
+ if(m_terminor_parameter.id()==5)
|
|
|
+ {
|
|
|
+ m_measure_information.locate_hight += 21;
|
|
|
+ }
|
|
|
m_measure_information.locate_correct = true;
|
|
|
+
|
|
|
+ // 20210527 added by yct, 融合大疆轮子与万集点云进行结果校验,机械手内空2150,取2000计算
|
|
|
+ save_cloud_txt(project_path+"/comb.txt", t_combined_wheel_cloud);
|
|
|
+ Eigen::Vector3d line_param_left, line_param_right;
|
|
|
+ double sign = 1.0;
|
|
|
+ if(m_measure_information.locate_theta==90.0)
|
|
|
+ {
|
|
|
+ line_param_left << 1.0, 0, -m_measure_information.locate_x + 1000.0;
|
|
|
+ line_param_right << 1.0, 0, -m_measure_information.locate_x - 1000.0;
|
|
|
+ }else{
|
|
|
+ // 减去2度测试外点个数
|
|
|
+ double k = (m_measure_information.locate_theta) * M_PI / 180.0;
|
|
|
+ line_param_left << tan(k), -1, m_measure_information.locate_y - (m_measure_information.locate_x - 1000.0/sin(k))*tan(k);
|
|
|
+ line_param_right << tan(k), -1, m_measure_information.locate_y - (m_measure_information.locate_x + 1000.0/sin(k))*tan(k);
|
|
|
+ if(tan(k)<0)
|
|
|
+ {
|
|
|
+ sign = -sign;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int outside_point_count = 0;
|
|
|
+ pcl::PointCloud<pcl::PointXYZ>::Ptr t_outside_cloud(new pcl::PointCloud<pcl::PointXYZ>);
|
|
|
+ for (int l = 0; l < t_combined_wheel_cloud->size(); ++l) {
|
|
|
+ Eigen::Vector3d t_point(t_combined_wheel_cloud->points[l].x,t_combined_wheel_cloud->points[l].y,1.0);
|
|
|
+ double t_left_value = sign * (line_param_left.transpose() * t_point)[0];
|
|
|
+ double t_right_value = sign * (line_param_right.transpose() * t_point)[0];
|
|
|
+ // 点在线右侧为正,左侧为负
|
|
|
+ if(t_left_value <= 0 || t_right_value >= 0)
|
|
|
+ {
|
|
|
+ outside_point_count++;
|
|
|
+ t_outside_cloud->push_back(pcl::PointXYZ(t_combined_wheel_cloud->points[l].x, t_combined_wheel_cloud->points[l].y, t_combined_wheel_cloud->points[l].z));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ save_cloud_txt(project_path+"/outside.txt", t_outside_cloud);
|
|
|
+ LOG(INFO) << "outside point count: "<<outside_point_count;
|
|
|
+ // 安全判断,外点超过15个判断本次测量失败
|
|
|
+ if(outside_point_count > 15)
|
|
|
+ {
|
|
|
+ m_measure_information.locate_correct = false;
|
|
|
+ code = Error_code::ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
////如果测量正确,检验结果
|
|
|
if (mp_verify_tool != NULL) {
|
|
|
|