|
@@ -56,6 +56,7 @@ iv::GPS_INS iv::decition::Compute00::dTpoint1;
|
|
|
iv::GPS_INS iv::decition::Compute00::dTpoint2;
|
|
|
iv::GPS_INS iv::decition::Compute00::dTpoint3;
|
|
|
double iv::decition::Compute00::dBocheAngle;
|
|
|
+int iv::decition::Compute00::nParkType;
|
|
|
|
|
|
|
|
|
std::vector<int> lastEsrIdVector;
|
|
@@ -1378,6 +1379,183 @@ double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
|
|
|
return ang;
|
|
|
}
|
|
|
|
|
|
+int iv::decition::Compute00::bocheCompute(GPS_INS nowGps,GPS_INS aimGps,std::vector<GPS_INS> & xvectorPoint,double & dBocheAngle,double & fDirectRearDis,double l)
|
|
|
+{
|
|
|
+ GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
|
|
|
+ Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
|
|
|
+
|
|
|
+ double x_1 = pt.x;
|
|
|
+ double y_1 = pt.y;
|
|
|
+ double angle_1 = getQieXianAngle(nowGps,aimGps);
|
|
|
+ double x_2 = 0.0, y_2 = 0.0;
|
|
|
+ double steering_angle;
|
|
|
+ double r =6;
|
|
|
+ double x_o, y_o, x_o_1, y_o_1, x_o_2, y_o_2, x_3, y_3;
|
|
|
+ double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
|
|
|
+ double x_t_1, y_t_1, x_t_2, y_t_2;//圆形1的切点
|
|
|
+ double x_t_3, y_t_3, x_t_4, y_t_4;//圆形2的切点
|
|
|
+ double g_1 = tan(angle_1);
|
|
|
+ double car_pos[3] = { x_1,y_1,g_1 };
|
|
|
+ double parking_pos[2] = { x_2,y_2 };
|
|
|
+ double g_3;
|
|
|
+ double t[4][2];
|
|
|
+ double p[4];
|
|
|
+ double s1, s2; //切点与车起始位置的距离
|
|
|
+ double min;
|
|
|
+ int min_i;
|
|
|
+
|
|
|
+ //g_3 = 0 - 0.5775;
|
|
|
+ g_3 = pingfenxian_xielv(x_1, y_1, x_2, y_2, angle_1);
|
|
|
+ //交点
|
|
|
+ x_3 = 0.0;//(y_1 - y_2 + g_2*x_2 - g_1*x_1) / (g_2 - g_1);
|
|
|
+ y_3 = y_1 - g_1 * x_1;
|
|
|
+ //圆心1
|
|
|
+ x_o_1 = r;
|
|
|
+ y_o_1 = g_3 * r + y_3;
|
|
|
+ //圆形1的切点1
|
|
|
+ x_t_1 = 0.0;
|
|
|
+ y_t_1 = g_3 * r + y_3;
|
|
|
+ //圆形1的切点2
|
|
|
+ if (g_1 == 0)
|
|
|
+ {
|
|
|
+ x_t_2 = r;
|
|
|
+ y_t_2 = y_1 - g_1 * x_1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ y_t_2 = (y_1 + g_1 * x_o_1 + y_o_1 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
|
|
|
+ x_t_2 = (y_t_2 + g_1 * x_1 - y_1) / g_1;
|
|
|
+
|
|
|
+ }
|
|
|
+ //圆心2
|
|
|
+ x_o_2 = 0 - r;
|
|
|
+ y_o_2 = y_3 - g_3 * r;
|
|
|
+ //圆形2的切点1
|
|
|
+ x_t_3 = 0;
|
|
|
+ y_t_3 = y_3 - g_3 * r;
|
|
|
+ //圆形2的切点2
|
|
|
+ if (g_1 == 0)
|
|
|
+ {
|
|
|
+ x_t_4 = 0 - r;
|
|
|
+ y_t_4 = y_1 - g_1 * x_1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ y_t_4 = (y_1 + g_1 * x_o_2 + y_o_2 * g_1*g_1 - g_1 * x_1) / (1 + g_1 * g_1);
|
|
|
+ x_t_4 = (y_t_4 + g_1 * x_1 - y_1) / g_1;
|
|
|
+
|
|
|
+ }
|
|
|
+ t[0][0] = x_t_1;
|
|
|
+ t[0][1] = y_t_1;
|
|
|
+ t[1][0] = x_t_2;
|
|
|
+ t[1][1] = y_t_2;
|
|
|
+ t[2][0] = x_t_3;
|
|
|
+ t[2][1] = y_t_3;
|
|
|
+ t[3][0] = x_t_4;
|
|
|
+ t[3][1] = y_t_4;
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ p[i] = (t[i][0] - parking_pos[0])*(t[i][0] - parking_pos[0]) + (t[i][1] - parking_pos[1])*(t[i][1] - parking_pos[1]);
|
|
|
+
|
|
|
+ }
|
|
|
+ min = p[0];
|
|
|
+ min_i = 0;
|
|
|
+ for (int i = 1; i < 4; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (p[i] < min)
|
|
|
+ {
|
|
|
+ min = p[i]; min_i = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (min_i < 2)
|
|
|
+ {
|
|
|
+ x_o = x_o_1;
|
|
|
+ y_o = y_o_1;
|
|
|
+ s1 = (x_t_1 - x_1)*(x_t_1 - x_1) + (y_t_1 - y_1)*(y_t_1 - y_1);
|
|
|
+ s2 = (x_t_2 - x_1)*(x_t_2 - x_1) + (y_t_2 - y_1)*(y_t_2 - y_1);
|
|
|
+ if (s1 < s2)
|
|
|
+ {
|
|
|
+ x_t_n = x_t_1;
|
|
|
+ y_t_n = y_t_1;
|
|
|
+ x_t_f = x_t_2;
|
|
|
+ y_t_f = y_t_2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x_t_n = x_t_2;
|
|
|
+ y_t_n = y_t_2;
|
|
|
+ x_t_f = x_t_1;
|
|
|
+ y_t_f = y_t_1;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x_o = x_o_2;
|
|
|
+ y_o = y_o_2;
|
|
|
+ s1 = (x_t_3 - x_1)*(x_t_3 - x_1) + (y_t_3 - y_1)*(y_t_3 - y_1);
|
|
|
+ s2 = (x_t_4 - x_1)*(x_t_4 - x_1) + (y_t_4 - y_1)*(y_t_4 - y_1);
|
|
|
+
|
|
|
+ if (s1 < s2)
|
|
|
+ {
|
|
|
+
|
|
|
+ x_t_n = x_t_3;
|
|
|
+ y_t_n = y_t_3;
|
|
|
+ x_t_f = x_t_4;
|
|
|
+ y_t_f = y_t_4;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ x_t_n = x_t_4;
|
|
|
+ y_t_n = y_t_4;
|
|
|
+ x_t_f = x_t_3;
|
|
|
+ y_t_f = y_t_3;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ steering_angle = atan2(l, r);
|
|
|
+
|
|
|
+ if (x_t_n < 0)
|
|
|
+ {
|
|
|
+ steering_angle = 0 - steering_angle;
|
|
|
+ }
|
|
|
+
|
|
|
+ nearTpoint=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
|
|
|
+ farTpoint = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
|
|
|
+ bocheAngle = steering_angle*180/PI;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // if (x_1 < 0 && y_1 > 0 && x_1 < x_t_n &&y_t_f > 0.1) {
|
|
|
+ // return 1;
|
|
|
+ // }
|
|
|
+ Point2D ptN = Coordinate_Transfer(nearTpoint.gps_x, nearTpoint.gps_y, nowGps);
|
|
|
+ double disA = GetDistance(aimGps,nowGps);
|
|
|
+ if(y_t_n>0 && ptN.y<0 && y_t_f>0.1 && disA<40){
|
|
|
+
|
|
|
+
|
|
|
+ dBocheAngle = bocheAngle;
|
|
|
+ fDirectRearDis = sqrt(pow(pt.x - x_t_n,2)+ pow(pt.y - y_t_n,2));
|
|
|
+ xvectorPoint.push_back(nearTpoint);
|
|
|
+ xvectorPoint.push_back(farTpoint);
|
|
|
+ cout << "近切点:x_t_n=" << x_t_n << endl;
|
|
|
+ cout << "近切点:y_t_n=" << y_t_n << endl;
|
|
|
+ cout << "远切点:x_t_f=" << x_t_f << endl;
|
|
|
+ cout << "远切点:y_t_f=" << y_t_f << endl;
|
|
|
+ cout << "航向角:" << steering_angle << endl;
|
|
|
+
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
|
|
|
double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
|
|
@@ -1649,6 +1827,81 @@ double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps)
|
|
|
*/
|
|
|
|
|
|
|
|
|
+int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps,GPS_INS aimGps,std::vector<GPS_INS> & xvectorPoint,double & dBocheAngle,double & fDirectRearDis,double l)
|
|
|
+{
|
|
|
+ double x_0 = 0, y_0 = 0.5;
|
|
|
+ double x_1, y_1;//车起点坐标
|
|
|
+ double ange1;//车航向角弧度
|
|
|
+ double x_2, y_2;//另一条与车直线在angle2和R_M 固定情况下过坐标点,第二个近切点
|
|
|
+ double real_rad;;//另一条直线的航向角弧度
|
|
|
+ double angle_3;//垂直平分线弧度
|
|
|
+ double x_3, y_3;//垂直平分线交点
|
|
|
+ double x_4, y_4;//另一条直线的远切点坐标,第二个远切点,已知
|
|
|
+ double x_o_1, y_o_1;//圆形1坐标
|
|
|
+ double x_o_2, y_o_2;//圆形2坐标
|
|
|
+ double x_t_n, y_t_n, x_t_f, y_t_f;//近切点和远切点
|
|
|
+ double min_rad;
|
|
|
+ double R_M; //后轴中点的转弯半径
|
|
|
+ double steering_angle;
|
|
|
+
|
|
|
+ xvectorPoint.clear();
|
|
|
+
|
|
|
+
|
|
|
+ GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
|
|
|
+ Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
|
|
|
+ x_1=pt.x;
|
|
|
+ y_1=pt.y;
|
|
|
+ ange1=getQieXianAngle(nowGps,aimGps);
|
|
|
+
|
|
|
+ min_rad_zhuanxiang(&R_M , &min_rad);
|
|
|
+ qiedian_n(x_1,y_1,R_M,min_rad,&x_2 , &y_2, &real_rad);//计算另一条与车直线在angle2和R_M 固定情况下近切点:x_2, y_2
|
|
|
+ liangzhixian_jiaodian( x_1, y_1, x_2, y_2,ange1,real_rad,&x_3 , &y_3);
|
|
|
+ chuizhipingfenxian_xielv( x_1, y_1, ange1, real_rad, min_rad,&angle_3);
|
|
|
+ yuanxin( x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_o_1,&y_o_1,&x_o_2,&y_o_2);
|
|
|
+ yuanxin_qiedian( ange1, x_o_1, y_o_1, x_o_2, y_o_2,
|
|
|
+ x_1, y_1, x_2, y_2, x_3, y_3, real_rad, angle_3, R_M,&x_t_n,&y_t_n,&x_t_f, &y_t_f);
|
|
|
+ steering_angle = atan2(l, R_M);
|
|
|
+ x_4 = 0.5;
|
|
|
+ y_4 = 0;
|
|
|
+ //for (int i = 0; i < 4; i++)
|
|
|
+ //{
|
|
|
+ //for (int j = 0; j < 2; j++)
|
|
|
+ //{
|
|
|
+ // cout << t[i][j] << endl;
|
|
|
+ //}
|
|
|
+ //}
|
|
|
+ //cout << "min_rad:" << min_rad<< endl;
|
|
|
+ //cout << "jiaodian:x=" << x_3 << endl;
|
|
|
+ //cout << "jiaodian:y=" << y_3 << endl;
|
|
|
+ // cout << "R-M:" << R_M << endl;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ dTpoint0=Coordinate_UnTransfer(x_t_n, y_t_n, aimGps);
|
|
|
+ dTpoint1 = Coordinate_UnTransfer(x_t_f, y_t_f, aimGps);
|
|
|
+ dTpoint2 = Coordinate_UnTransfer(x_2, y_2, aimGps);
|
|
|
+ dTpoint3 = Coordinate_UnTransfer(x_0, y_0, aimGps);
|
|
|
+ dBocheAngle = steering_angle*180/PI;
|
|
|
+
|
|
|
+ double disA = GetDistance(aimGps,nowGps);
|
|
|
+
|
|
|
+ if(pt.y>y_t_n && x_t_f<x_2 && y_t_f>y_2&&disA<40){
|
|
|
+ cout << "x_0:" << x_0 << endl;
|
|
|
+ cout << "y_0:" << y_0 << endl;
|
|
|
+ cout << "x_2:" << x_2 << endl;
|
|
|
+ cout << "y_2:" << y_2 << endl;
|
|
|
+ cout << "近切点:x_t_n="<< x_t_n << endl;
|
|
|
+ cout << "近切点:y_t_n=" << y_t_n << endl;
|
|
|
+ cout << "远切点:x_t_f=" << x_t_f << endl;
|
|
|
+ cout << "远切点:y_t_f=" << y_t_f << endl;
|
|
|
+ xvectorPoint.push_back(dTpoint0);xvectorPoint.push_back(dTpoint1);xvectorPoint.push_back(dTpoint2);xvectorPoint.push_back(dTpoint3);
|
|
|
+ fDirectRearDis = sqrt(pow(pt.x - x_t_n,2) + pow(pt.y - y_t_n,2));
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
|
|
|
{
|
|
|
|