|
@@ -473,8 +473,9 @@ bool detect_wheel_ceres3d::detect(std::vector<pcl::PointCloud<pcl::PointXYZ>::Pt
|
|
|
|
|
|
Detect_result t_detect_result = detect_result;
|
|
|
// 寻找最小loss值对应的初始旋转角
|
|
|
+ // LOG(WARNING) <<cloud_all.size()<< ", car angle: "<<t_detect_result.theta<<", "<<(-angle_x ) * M_PI / 180.0;
|
|
|
+ // t_detect_result.theta = (-angle_x ) * M_PI / 180.0;
|
|
|
|
|
|
- t_detect_result.theta = (-angle_x ) * M_PI / 180.0;
|
|
|
Loss_result t_loss_result;
|
|
|
t_loss_result.total_avg_loss = 1000;
|
|
|
//输出角度已变化,需恢复成弧度
|
|
@@ -614,7 +615,7 @@ void detect_wheel_ceres3d::save_debug_data(std::string dir )
|
|
|
}
|
|
|
|
|
|
// 外接矩形估算车轮宽度,以此调整模型比例
|
|
|
-bool detect_wheel_ceres3d::wheel_size_estimate(double &wheel_width, double &wheel_length, float &ratio)
|
|
|
+bool detect_wheel_ceres3d::wheel_size_estimate(double &wheel_width, double &wheel_length, double car_angle, float &ratio)
|
|
|
{
|
|
|
// 分别对四轮寻找外接矩形
|
|
|
int rect_res = 0;
|
|
@@ -642,16 +643,54 @@ bool detect_wheel_ceres3d::wheel_size_estimate(double &wheel_width, double &whee
|
|
|
avg_width /= 2.0;
|
|
|
avg_length /= 2.0;
|
|
|
// std::cout << "avg width: " << avg_width << ", avg length: " << avg_length << std::endl;
|
|
|
- wheel_width = avg_width;
|
|
|
+
|
|
|
+ // 以投影方式计算轮宽
|
|
|
+ Eigen::Vector2d car_angle_vec(cos(-car_angle), sin(-car_angle));
|
|
|
+ double left_min=INT_MAX, left_max=-INT_MAX, right_min=INT_MAX, right_max=-INT_MAX;
|
|
|
+ if(m_left_rear_cloud.size()==0 || m_right_rear_cloud.size()==0)
|
|
|
+ {
|
|
|
+ ratio = 1.0f;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (size_t i = 0; i < m_left_rear_cloud.size(); i++)
|
|
|
+ {
|
|
|
+ Eigen::Vector2d point_vec(m_left_rear_cloud[i].x, m_left_rear_cloud[i].y);
|
|
|
+ double res = car_angle_vec.dot(point_vec);
|
|
|
+ // std::cout<<"lres: "<<res<<std::endl;
|
|
|
+ if(res<left_min)
|
|
|
+ left_min=res;
|
|
|
+ if(res>left_max)
|
|
|
+ left_max=res;
|
|
|
+ }
|
|
|
+ for (size_t i = 0; i < m_right_rear_cloud.size(); i++)
|
|
|
+ {
|
|
|
+ Eigen::Vector2d point_vec(m_right_rear_cloud[i].x, m_right_rear_cloud[i].y);
|
|
|
+ double res = car_angle_vec.dot(point_vec);
|
|
|
+ // std::cout<<"rres: "<<res<<std::endl;
|
|
|
+ if(res<right_min)
|
|
|
+ right_min=res;
|
|
|
+ if(res>right_max)
|
|
|
+ right_max=res;
|
|
|
+ }
|
|
|
+ double new_wheel_width = (left_max+right_max-left_min-right_min)/2.0;
|
|
|
+ // std::cout << "avg width: " << avg_width << ", new width: " << new_wheel_width << std::endl;
|
|
|
+
|
|
|
+ wheel_width = new_wheel_width;
|
|
|
wheel_length = avg_length;
|
|
|
|
|
|
- // 轮宽范围,实际0.185-0.3,通常会少0.03-0.04,因此设定范围0.16-0.26
|
|
|
- // 比例以半径0.64为模板,范围0.61-0.69
|
|
|
- float t_model_ratio = float((0.6 + ((wheel_width - 0.16) * 0.1 / 0.1)) / 0.64);
|
|
|
- t_model_ratio = std::max(0.6f/0.64f, t_model_ratio);
|
|
|
- t_model_ratio = std::min(0.7f/0.64f, t_model_ratio);
|
|
|
- ratio = 1.0f / t_model_ratio;
|
|
|
+ // ratio = 1.0f;
|
|
|
|
|
|
+ // 轮宽范围,实际0.185-0.3,通常会少0.03-0.04,(新方法不会少),因此设定范围0.175-0.275
|
|
|
+ // 比例以半径0.64为模板,范围0.6-0.7
|
|
|
+ if(wheel_width<0.18||wheel_width>0.3)
|
|
|
+ {
|
|
|
+ ratio = 1.0f;
|
|
|
+ }else{
|
|
|
+ float t_model_ratio = float((0.6 + ((wheel_width - 0.175) * 0.1 / 0.1)) / 0.64);
|
|
|
+ t_model_ratio = std::max(0.6f/0.64f, t_model_ratio);
|
|
|
+ t_model_ratio = std::min(0.7f/0.64f, t_model_ratio);
|
|
|
+ ratio = 1.0f / t_model_ratio;
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -787,7 +826,7 @@ bool detect_wheel_ceres3d::Solve(Detect_result &detect_result, Loss_result &loss
|
|
|
{
|
|
|
// 20220118 added by yct. 计算比例传入模型
|
|
|
float model_ratio = 1.0f;
|
|
|
- bool ws_res = wheel_size_estimate(detect_result.single_wheel_width, detect_result.single_wheel_length, model_ratio);
|
|
|
+ // bool ws_res = wheel_size_estimate(detect_result.single_wheel_width, detect_result.single_wheel_length, detect_result.theta, model_ratio);
|
|
|
// std::cout << "change cloud with ratio: " << model_ratio << std::endl;
|
|
|
|
|
|
double cx=detect_result.cx;
|