| | |
| | | import android.graphics.Path; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.util.DebugUtils; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.SurfaceHolder; |
| | |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(Color.GREEN); |
| | | paint.setStrokeWidth(2.0f); |
| | | paint.setPathEffect(null); |
| | | |
| | | Log.d(TAG, "画车体"); |
| | | |
| | | Path carpath = new Path(); |
| | | // 画车体 |
| | |
| | | } |
| | | |
| | | private SurfaceView mSurfaceView; |
| | | private static final String TAG = "RoadDriveFragmentaa"; |
| | | private static final String TAG = "RoadDriveFragmentab"; |
| | | private SurfaceHolder holder; |
| | | Path path = new Path(); |
| | | private Canvas canvas; |
| | |
| | | paint.setStyle(Paint.Style.STROKE); |
| | | paint.setColor(Color.GREEN); |
| | | paint.setStrokeWidth(2.0f); |
| | | paint.setPathEffect(null); |
| | | |
| | | Path carpath = new Path(); |
| | | // 画车体 |
| | |
| | | // RoadMap.examScheme.assign(scheme.begin(), scheme.end()); |
| | | |
| | | DEBUG("得到新的路考地图 路数量 %d 特殊区域数量 %d 其他禁止线数量 %d 项目数量 %d", RoadMap.roads.size(), RoadMap.specialAreas.size(), RoadMap.forbidLines.size(), RoadMap.examScheme.size()); |
| | | |
| | | for (int i = 0; i < RoadMap.roads.size(); ++i) { |
| | | DEBUG("路 id = %d", RoadMap.roads[i].id); |
| | | DEBUG("左边线段数 %d", RoadMap.roads[i].leftEdge.size()); |
| | | for (int j = 0; j < RoadMap.roads[i].leftEdge.size(); ++j) { |
| | | int n = RoadMap.roads[i].leftEdge[j].points.size(); |
| | | |
| | | DEBUG("\t当前左边线段 类型 %d 点数 %d", RoadMap.roads[i].leftEdge[j].character, n); |
| | | for (int k = 0; k < n; ++k) { |
| | | DEBUG("\t\t点坐标 %d: %f, %f", k, RoadMap.roads[i].leftEdge[j].points[k].X, RoadMap.roads[i].leftEdge[j].points[k].Y); |
| | | } |
| | | } |
| | | |
| | | DEBUG("右边线段数 %d", RoadMap.roads[i].rightEdge.size()); |
| | | for (int j = 0; j < RoadMap.roads[i].rightEdge.size(); ++j) { |
| | | int n = RoadMap.roads[i].rightEdge[j].points.size(); |
| | | |
| | | DEBUG("\t当前右边线段 类型 %d 点数 %d", RoadMap.roads[i].rightEdge[j].character, n); |
| | | for (int k = 0; k < n; ++k) { |
| | | DEBUG("\t\t点坐标 %d: %f, %f", k, RoadMap.roads[i].rightEdge[j].points[k].X, RoadMap.roads[i].rightEdge[j].points[k].Y); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | void SetRoadExamScheme(vector<scheme_t> &scheme) |
| | |
| | | |
| | | vector<stop_line_t> crossing; |
| | | |
| | | |
| | | for (Value::ConstValueIterator itr2 = a2.Begin(); itr2 != a2.End(); ++itr2) { |
| | | stop_line_t temp; |
| | | if (!itr2->IsObject()) { |
| | |
| | | sensor.surround3 = data[x++]; |
| | | sensor.surround4 = data[x++]; |
| | | |
| | | if (sensor.clutch == 1) |
| | | sensor.gear = 0; |
| | | // DEBUG("离合 = %d", sensor.clutch); |
| | | |
| | | // if (sensor.clutch == 1) |
| | | // sensor.gear = 0; |
| | | |
| | | UpdateSensor(&sensor); |
| | | break; |
| | |
| | | return newPoint; |
| | | } |
| | | |
| | | PointF centerOfTwoPoint(PointF p1, PointF p2) { |
| | | PointF center; |
| | | |
| | | center.X = (p1.X + p2.X) / 2; |
| | | center.Y = (p1.Y + p2.Y) / 2; |
| | | |
| | | return center; |
| | | } |
| | | |
| | | // All in |
| | | bool InsidePolygon(const Polygon *t1, const Polygon *t2) { |
| | | for (int i = 0; i < t1->num; ++i) { |
| | |
| | | double DeltaYaw(double yaw1, double yaw2); |
| | | double CalculateAngle(Line base, Line dest); |
| | | PointF rotatePoint(PointF oldPoint, PointF centre, double degree); |
| | | PointF centerOfTwoPoint(PointF p1, PointF p2); |
| | | bool InsidePolygon(const Polygon *t1, const Polygon *t2); |
| | | bool PartInsidePolygon(const Polygon *t1, const Polygon *t2); |
| | | bool OutsidePolygon(const Polygon *t1, const Polygon *t2); |
| | |
| | | if (s->surround4 != Sensor.surround4 && s->surround4 != '#') { |
| | | SensorChanged(SENSOR_SURROUND_CAR_4, BX(s->surround4)); |
| | | } |
| | | |
| | | // DEBUG("挡位 老的 %d 当前 %d", Sensor.gear, s->gear); |
| | | |
| | | if (s->gear != Sensor.gear && s->gear != '#') { |
| | | // SensorChanged(GEAR, GEAR_N + s->gear); |
| | | DEBUG("状态改变 挡位 %d", s->gear); |
| | |
| | | } |
| | | |
| | | void UpdataOdo(double speed, int moveDirect, const struct RtkTime *rtkTime) { |
| | | // 行驶距离,不包含倒车 |
| | | if (odoCnt == 0 && moveDirect == 1) { |
| | | // 行驶距离,含倒车 |
| | | if (odoCnt == 0 && moveDirect != 0) { |
| | | odoPrevSpeed = speed; |
| | | odoCnt = 1; |
| | | odoTimer = *rtkTime; |
| | | } else if (odoCnt == 1) { |
| | | if (moveDirect == 1) { |
| | | if (moveDirect != 0) { |
| | | uint32_t tm = TimeGetDiff(rtkTime, &odoTimer); |
| | | if (tm >= D_SEC(1)) { |
| | | odoGraph += ((double) tm) * (odoPrevSpeed + speed) / 2.0 / 1000.0; |
| | |
| | | static int CurrExamMapIndex = -1; |
| | | static int CurrEnterMapIndex = -1; |
| | | |
| | | static void DetectEnterOrExitMap(const car_model *CarModel, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList); |
| | | static int EnterMap(const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList); |
| | | static void DetectEnterOrExitMap(int moveDirect, const car_model *CarModel, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList); |
| | | static int EnterMap(int moveDirect, const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList); |
| | | static bool ExitMap(const car_model *car, int index, LIST_AREA_MAP &mapList); |
| | | static bool CrashTriggerLine(Line triggerLine, const car_model *car, LIST_CAR_MODEL &CarModelList); |
| | | static void ExecuteExam(int index, LIST_AREA_MAP &AreaMapList, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int move, double azimuth, const struct RtkTime* rtkTime); |
| | |
| | | { |
| | | UpdataOdo(speed, moveDirect, rtkTime); |
| | | |
| | | DetectEnterOrExitMap(car, CarModelList, AreaMapList); |
| | | DetectEnterOrExitMap(moveDirect, car, CarModelList, AreaMapList); |
| | | |
| | | ExecuteExam(CurrExamMapIndex, AreaMapList, car, CarModelList, speed, moveDirect, azimuth, rtkTime); |
| | | } |
| | |
| | | array.push_back(rd); |
| | | } |
| | | |
| | | static void DetectEnterOrExitMap(const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList) |
| | | static void DetectEnterOrExitMap(int moveDirect, const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList) |
| | | { |
| | | if (CurrExamMapIndex < 0) { |
| | | if (CurrEnterMapIndex < 0) { |
| | | CurrEnterMapIndex = EnterMap(car, CarModelList, mapList); |
| | | CurrEnterMapIndex = EnterMap(moveDirect, car, CarModelList, mapList); |
| | | if (CurrEnterMapIndex >= 0) { |
| | | DEBUG("进入某个子项目 idx = %d", CurrEnterMapIndex); |
| | | CurrExamMapIndex = CurrEnterMapIndex; |
| | |
| | | } |
| | | } |
| | | |
| | | static int EnterMap(const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList) |
| | | static int EnterMap(int moveDirect, const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList) |
| | | { |
| | | vector<int> score(mapList.size(), 0); // 场地重合时,车头尾都在内的优先 |
| | | |
| | |
| | | triggerLine.X2 = x9; |
| | | triggerLine.Y2 = y9; |
| | | |
| | | if (CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | if (moveDirect > 0 && CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | return i; |
| | | } |
| | | if (mapList[i].type == MAP_TYPE_PARK_BUTTOM) { |
| | |
| | | |
| | | MakeLine(&triggerLine, &(mapList[i].map.point[1]), &(mapList[i].map.point[0])); |
| | | |
| | | if (CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | if (moveDirect > 0 && CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | return i; |
| | | |
| | | MakeLine(&triggerLine, &(mapList[i].map.point[7]), &(mapList[i].map.point[6])); |
| | | |
| | | if (CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | if (moveDirect > 0 && CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | return i; |
| | | |
| | | // 全车在场地内 |
| | | if (moveDirect == 0) { |
| | | Polygon carBody; |
| | | bool ret = false; |
| | | carBody.num = car->bodyNum; |
| | | carBody.point = (PointF *) malloc(carBody.num * sizeof(PointF)); |
| | | for (int i = 0; i < carBody.num; ++i) { |
| | | carBody.point[i] = car->carXY[car->body[i]]; |
| | | } |
| | | |
| | | if (IntersectionOf(&carBody, &mapList[i].map) == GM_Containment) { |
| | | ret = true; |
| | | } |
| | | |
| | | free(carBody.point); |
| | | |
| | | if (ret) |
| | | return i; |
| | | } |
| | | // // 车头顶点在场地内 |
| | | // if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &mapList[i].map) == GM_Containment) { |
| | | // Line enterLine1, enterLine2; |
| | |
| | | |
| | | MakeLine(&triggerLine, &(mapList[i].map.point[1]), &(mapList[i].map.point[0])); |
| | | |
| | | if (CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | if (moveDirect > 0 && CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | return i; |
| | | |
| | | // 全车在场地内 |
| | | if (moveDirect == 0) { |
| | | Polygon carBody; |
| | | bool ret = false; |
| | | carBody.num = car->bodyNum; |
| | | carBody.point = (PointF *) malloc(carBody.num * sizeof(PointF)); |
| | | for (int i = 0; i < carBody.num; ++i) { |
| | | carBody.point[i] = car->carXY[car->body[i]]; |
| | | } |
| | | |
| | | if (IntersectionOf(&carBody, &mapList[i].map) == GM_Containment) { |
| | | ret = true; |
| | | } |
| | | |
| | | free(carBody.point); |
| | | |
| | | if (ret) |
| | | return i; |
| | | } |
| | | // // 车头顶点在场地内 |
| | | // if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &mapList[i].map) == GM_Containment) { |
| | | // Line enterLine; |
| | |
| | | |
| | | MakeLine(&triggerLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1])); |
| | | |
| | | if (CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | if (moveDirect > 0 && CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | return i; |
| | | } |
| | | if (mapList[i].type == MAP_TYPE_CURVE) { |
| | |
| | | Line triggerLine; |
| | | |
| | | MakeLine(&triggerLine, &mapList[i].map2.point[0], &mapList[i].map.point[0]); |
| | | if (CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | if (moveDirect > 0 && CrashTriggerLine(triggerLine, car, CarModelList)) |
| | | return i; |
| | | } |
| | | } |
| | |
| | | |
| | | car_model *c1 = *iter; |
| | | |
| | | trace.point[pn] = c1->carXY[c1->left_front_tire[TIRE_OUTSIDE]]; |
| | | trace2.point[pn++] = c1->carXY[c1->left_rear_tire[TIRE_OUTSIDE]]; |
| | | trace.point[pn] = centerOfTwoPoint(c1->carXY[c1->left_front_tire[TIRE_OUTSIDE]], c1->carXY[c1->right_front_tire[TIRE_OUTSIDE]]); |
| | | trace2.point[pn++] = centerOfTwoPoint(c1->carXY[c1->left_rear_tire[TIRE_OUTSIDE]], c1->carXY[c1->right_rear_tire[TIRE_OUTSIDE]]); |
| | | |
| | | ++iter; |
| | | |
| | |
| | | uint32_t tdiff = TimeGetDiff(c1->tm.hh, c1->tm.mm, c1->tm.ss, c1->tm.mss * 10, c2->tm.hh, c2->tm.mm, c2->tm.ss, c2->tm.mss*10); |
| | | |
| | | if (tdiff >= D_SEC(1)) { |
| | | trace.point[pn] = c2->carXY[c2->left_front_tire[TIRE_OUTSIDE]]; |
| | | trace2.point[pn++] = c2->carXY[c2->left_rear_tire[TIRE_OUTSIDE]]; |
| | | trace.point[pn] = centerOfTwoPoint(c2->carXY[c2->left_front_tire[TIRE_OUTSIDE]], c2->carXY[c2->right_front_tire[TIRE_OUTSIDE]]); |
| | | trace2.point[pn++] = centerOfTwoPoint(c2->carXY[c2->left_rear_tire[TIRE_OUTSIDE]], c2->carXY[c2->right_rear_tire[TIRE_OUTSIDE]]); |
| | | c1 = c2; |
| | | } |
| | | ++iter; |
| | |
| | | MakeLine(&trace2_line, &trace2.point[pp], &trace2.point[p]); |
| | | |
| | | if ((IntersectionOf(trace_line, triggerLine) == GM_Intersection && |
| | | IntersectionOfLine(p1, p2, car->carXY[car->left_front_tire[TIRE_OUTSIDE]]) == -1 && |
| | | DistanceOf(car->carXY[car->left_front_tire[TIRE_OUTSIDE]], triggerLine) > 0.1) || |
| | | IntersectionOfLine(p1, p2, centerOfTwoPoint(car->carXY[car->left_front_tire[TIRE_OUTSIDE]], car->carXY[car->right_front_tire[TIRE_OUTSIDE]])) == -1 && |
| | | DistanceOf(centerOfTwoPoint(car->carXY[car->left_front_tire[TIRE_OUTSIDE]], car->carXY[car->right_front_tire[TIRE_OUTSIDE]]), triggerLine) > 0.1) || |
| | | (IntersectionOf(trace2_line, triggerLine) == GM_Intersection && |
| | | IntersectionOfLine(p1, p2, car->carXY[car->left_rear_tire[TIRE_OUTSIDE]]) == -1 && |
| | | DistanceOf(car->carXY[car->left_rear_tire[TIRE_OUTSIDE]], triggerLine) > 0.1) ) { |
| | | IntersectionOfLine(p1, p2, centerOfTwoPoint(car->carXY[car->left_rear_tire[TIRE_OUTSIDE]], car->carXY[car->right_rear_tire[TIRE_OUTSIDE]])) == -1 && |
| | | DistanceOf(centerOfTwoPoint(car->carXY[car->left_rear_tire[TIRE_OUTSIDE]], car->carXY[car->right_rear_tire[TIRE_OUTSIDE]]), triggerLine) > 0.1) ) { |
| | | // 碰到触发线 |
| | | DEBUG("碰撞触发线 引发地图"); |
| | | trigger = true; |
| | |
| | | #include "../master/comm_if.h" |
| | | #include "area_exam.h" |
| | | #include "../test_common/car_sensor.h" |
| | | #include "../test_common/odo_graph.h" |
| | | #include <vector> |
| | | #include <cstdlib> |
| | | |
| | |
| | | static int gearAtStop; |
| | | static int currGear; |
| | | static char prevCrossedCtrlLine; |
| | | |
| | | static double odo; |
| | | static int exitAreaCfm; |
| | | static char CrossCtrlLine(const Polygon *map, const car_model *car, const car_model *prev_car); |
| | | static bool EnterParking(const Polygon *map, const car_model *car); |
| | | static bool CrashRedLine(const Polygon *map, const car_model *car, int &who); |
| | |
| | | |
| | | currGear = ReadCarStatus(GEAR); |
| | | prevCrossedCtrlLine = 0; |
| | | stopTimepoint = 0; |
| | | exitAreaCfm = 0; |
| | | odo = ReadOdo(); |
| | | |
| | | PlayTTS("您已进入倒车入库区域", NULL); |
| | | } |
| | |
| | | } else if (currGear == GEAR_R) { |
| | | gear_change = true; |
| | | currGear = gear; |
| | | } |
| | | |
| | | if (gear_change) { |
| | | // 检查上一次挡位的行驶距离,过小就放弃,避开学员原地挂挡重试 |
| | | double run_distance = ReadOdo() - odo; |
| | | |
| | | DEBUG("2次挡位运行距离 %f", run_distance); |
| | | |
| | | if (run_distance < 1) { |
| | | gear_change = false; |
| | | DEBUG("2次挡位运行距离过小,忽略"); |
| | | } |
| | | odo = ReadOdo(); |
| | | } |
| | | |
| | | if (testStatus == TESTING && gear_change) { |
| | |
| | | } |
| | | |
| | | if (testStatus == TESTING && parkCount < 2 && AllTireExitParkArea(map, car)) { |
| | | testStatus = TEST_FAIL; |
| | | AddExamFault(10103, rtkTime); |
| | | DEBUG("直接驶离测试区,不按考试员指令驾驶"); |
| | | if (++exitAreaCfm >= 4) { // 避免信号漂移造成的误判 |
| | | testStatus = TEST_FAIL; |
| | | AddExamFault(10103, rtkTime); |
| | | DEBUG("直接驶离测试区,不按考试员指令驾驶"); |
| | | } |
| | | } else { |
| | | exitAreaCfm = 0; |
| | | } |
| | | |
| | | if (ExitParkArea(map, car)) { |
| | |
| | | gearAtStop = (currGear == GEAR_R ? 1 : 0); |
| | | DEBUG("停车了 %d %d %d %d %d %d %d", rtkTime->YY, rtkTime->MM, rtkTime->DD, rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss); |
| | | DEBUG("停车时挡位 = %d", gearAtStop); |
| | | } else if (prevMoveDirect == 0) { |
| | | } else if (prevMoveDirect == 0 && stopTimepoint > 0) { |
| | | DEBUG("继续行驶 %d %d %d %d %d %d %d", rtkTime->YY, rtkTime->MM, rtkTime->DD, rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss); |
| | | |
| | | DEBUG("停车时间 %ld", tp - stopTimepoint); |
| | |
| | | return ret; |
| | | } |
| | | |
| | | // 双前轮和任一后轮不在区域 |
| | | // 双前轮和双后轮不在区域 |
| | | static bool AllTireExitParkArea(const Polygon *map, const car_model *car) |
| | | { |
| | | int tireExitNum = 0; |
| | |
| | | tireExitNum++; |
| | | } |
| | | |
| | | if (tireExitNum >= 3) { |
| | | if (tireExitNum >= 4) { |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | #include "../test_common/car_sensor.h" |
| | | #include "../master/comm_if.h" |
| | | #include "area_exam.h" |
| | | #include "../test_common/odo_graph.h" |
| | | |
| | | #include <vector> |
| | | #include <cstdlib> |
| | |
| | | static bool reportParkFail; |
| | | |
| | | static uint32_t stopTimepoint = 0; |
| | | static bool occurCrashRedLine1, occurCrashRedLine2; |
| | | static bool occurCrashRedLine1, occurCrashRedLine2, occurCrashRedLine3; |
| | | static int prevMoveStatus, storeMoveStatusBeforeStop; |
| | | static int parkStatus; |
| | | static int gearAtStop; |
| | | static bool occurMoveBack, checkPark, parkSuccess, checkLight; |
| | | static uint32_t moveBackTimePoint; |
| | | static int testStatus; |
| | | static int exitAreaCfm; |
| | | static int currGear; |
| | | static double odo; |
| | | |
| | | static bool CrashRedLine1(const Polygon *map, const car_model *car); |
| | | static bool CrashRedLine2(const Polygon *map, const car_model *car); |
| | | static bool CrashRedLine3(const Polygon *map, const car_model *car); |
| | | static bool EnterParking(const Polygon *map, const car_model *car); |
| | | static bool ExitParkArea(const Polygon *map, const car_model *car); |
| | | static bool ExitParkArea2(const Polygon *map, const car_model *car); |
| | |
| | | testStatus = TESTING; |
| | | mapIndex = index; |
| | | |
| | | occurCrashRedLine1 = occurCrashRedLine2 = false; // 这个科目规定特殊点,发生一次扣10分,而不直接淘汰 |
| | | occurCrashRedLine1 = occurCrashRedLine2 = occurCrashRedLine3 = false; // 这个科目规定特殊点,发生一次扣10分,而不直接淘汰 |
| | | reportExamTimeout = false; |
| | | reportParkFail = false; |
| | | prevMoveStatus = moveStatus; |
| | |
| | | checkPark = false; |
| | | checkLight = false; |
| | | gearAtStop = -1; |
| | | stopTimepoint = 0; |
| | | odo = ReadOdo(); |
| | | currGear = ReadCarStatus(GEAR); |
| | | exitAreaCfm = 0; |
| | | |
| | | PlayTTS("您已进入侧方停车区域", NULL); |
| | | // 仅当发生倒车,才意味着项目开始 |
| | |
| | | vector<double> dtox; |
| | | vector<Line> line_set; |
| | | Line distance_line; |
| | | bool is_gear_r = false; |
| | | |
| | | bool gear_change = false; |
| | | int gear = ReadCarStatus(GEAR); |
| | | |
| | | if (gear == GEAR_R) { |
| | | if (currGear != GEAR_R) { |
| | | gear_change = true; |
| | | currGear = GEAR_R; |
| | | } |
| | | } else if (currGear == GEAR_R) { |
| | | gear_change = true; |
| | | currGear = gear; |
| | | } |
| | | |
| | | if (gear_change) { |
| | | // 检查上一次挡位的行驶距离,过小就放弃,避开学员原地挂挡重试 |
| | | double run_distance = ReadOdo() - odo; |
| | | |
| | | DEBUG("2次挡位运行距离 %f", run_distance); |
| | | |
| | | if (run_distance < 1) { |
| | | gear_change = false; |
| | | DEBUG("2次挡位运行距离过小,忽略"); |
| | | } |
| | | odo = ReadOdo(); |
| | | } |
| | | |
| | | // 首次挂倒挡, 才意味着项目开始 |
| | | if (testStatus == TESTING) { |
| | | if (ReadCarStatus(GEAR) == GEAR_R) { |
| | | is_gear_r = true; |
| | | if (testStatus == TESTING && gear_change) { |
| | | if (currGear == GEAR_R) { |
| | | if (!occurMoveBack) { |
| | | DEBUG("首次侧方停车"); |
| | | } else { |
| | | DEBUG("再次侧方停车"); |
| | | } |
| | | |
| | | { |
| | | checkPark = false; |
| | | occurMoveBack = true; |
| | | moveBackTimePoint = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, |
| | | rtkTime->mss * 10); // 开始计时 |
| | | MA_EnterMap(mapIndex, MAP_TYPE_PART_EDGE, 1); |
| | | } |
| | | } else { |
| | | is_gear_r = false; |
| | | if (occurMoveBack && !checkPark) { |
| | | // 检查车身入库情况 |
| | | DEBUG("检查车身入库情况"); |
| | | checkPark = true; |
| | | checkLight = false; |
| | | if (EnterParking(map, car)) { |
| | | parkStatus = 1; |
| | | parkSuccess = true; |
| | |
| | | } |
| | | } else { |
| | | occurCrashRedLine2 = false; |
| | | } |
| | | |
| | | if (CrashRedLine3(map, car)) { |
| | | if (!occurCrashRedLine3 && !occurMoveBack && moveStatus == 1) { |
| | | // 车身压库位线,每次扣10分 |
| | | AddExamFault(20407, rtkTime); |
| | | DEBUG("车身压库位线"); |
| | | occurCrashRedLine3 = true; |
| | | } |
| | | } else { |
| | | occurCrashRedLine3 = false; |
| | | } |
| | | |
| | | if (ExitParkArea2(map, car)) { |
| | |
| | | |
| | | if (testStatus == TESTING && !occurMoveBack && ExitParkArea(map, car)) { |
| | | // 入库后一直前进,车头移出驶离线 |
| | | AddExamFault(10103, rtkTime); |
| | | DEBUG("直接驶离测试区,不按考试员指令驾驶"); |
| | | testStatus = TEST_FAIL; |
| | | if (++exitAreaCfm >= 4) { // 避免信号漂移造成的误判 |
| | | AddExamFault(10103, rtkTime); |
| | | DEBUG("直接驶离测试区,不按考试员指令驾驶"); |
| | | testStatus = TEST_FAIL; |
| | | } |
| | | } else { |
| | | exitAreaCfm = 0; |
| | | } |
| | | |
| | | if (occurMoveBack) { |
| | |
| | | parkStatus = 0; |
| | | stopTimepoint = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10); |
| | | storeMoveStatusBeforeStop = prevMoveStatus; |
| | | gearAtStop = is_gear_r ? 1 : 0; |
| | | gearAtStop = (currGear == GEAR_R ? 1 : 0); |
| | | DEBUG("停车了 %d %d %d %d %d %d %d", rtkTime->YY, rtkTime->MM, rtkTime->DD, rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss); |
| | | } else if (prevMoveStatus == 0) { |
| | | DEBUG("停车时挡位 = %d", gearAtStop); |
| | | } else if (prevMoveStatus == 0 && stopTimepoint > 0) { |
| | | DEBUG("继续行驶 %d %d %d %d %d %d %d", rtkTime->YY, rtkTime->MM, rtkTime->DD, rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss); |
| | | uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10); |
| | | |
| | | DEBUG("停车时间 %ld", tp - stopTimepoint); |
| | | DEBUG("再次移动时挡位 = %d", currGear == GEAR_R ? 1 : 0); |
| | | |
| | | if (tp - stopTimepoint >= CorrectPauseCriteria(examParam.park_edge_pause_criteria) |
| | | && occurMoveBack |
| | | && gearAtStop == (is_gear_r ? 1 : 0)) { |
| | | && gearAtStop == (currGear == GEAR_R ? 1 : 0)) { |
| | | // 停车超2秒,每次扣5分 |
| | | AddExamFault(20406, rtkTime); |
| | | DEBUG("停车超时"); |
| | |
| | | } |
| | | } |
| | | |
| | | free(car_body.point); |
| | | return ret; |
| | | } |
| | | |
| | | static bool CrashRedLine3(const Polygon *map, const car_model *car) { |
| | | bool ret = false; |
| | | |
| | | if (!occurMoveBack) { |
| | | // 倒车前,车身不得压库位虚线 |
| | | Polygon car_body; |
| | | Line red_line; |
| | | |
| | | car_body.num = car->bodyNum; |
| | | car_body.point = (PointF *) malloc(sizeof(PointF) * car_body.num); |
| | | for (int i = 0; i < car_body.num; ++i) { |
| | | car_body.point[i] = car->carXY[car->body[i]]; |
| | | } |
| | | |
| | | MakeLine(&red_line, &map->point[2], &map->point[5]); |
| | | if (IntersectionOf(red_line, &car_body) != GM_None) { |
| | | ret = true; |
| | | } |
| | | |
| | | free(car_body.point); |
| | | } |
| | | |
| | | free(car_body.point); |
| | | return ret; |
| | | } |
| | | |
| | |
| | | #include "../test_common/car_sensor.h" |
| | | #include "../master/comm_if.h" |
| | | #include "area_exam.h" |
| | | #include "../defs.h" |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<stop_and_start> <%s>: " fmt, __func__, ##args) |
| | | |
| | |
| | | |
| | | double l2 = DistanceOf(car->carXY[car->right_rear_tire[TIRE_OUTSIDE]], edge); |
| | | |
| | | return (l1+l2)/2.0; |
| | | // return (l1+l2)/2.0; |
| | | return MAX(l1, l2); // 取最远的 |
| | | } |
| | | |
| | | // 整个车辆都要驶离该测试区域 |
| | |
| | | vector<PointF> roadOutLine; |
| | | Polygon area; |
| | | |
| | | // DEBUG("CalcRoadIndex %d 做点 %d 有点 %d", index, RoadMap.roads[index].leftEdge.size(), RoadMap.roads[index].rightEdge.size()); |
| | | |
| | | for (int i = 0; i < RoadMap.roads[index].leftEdge.size(); ++i) { |
| | | for (int j = 0; j < RoadMap.roads[index].leftEdge[i].points.size(); ++j) { |
| | | if (changeSegment && roadOutLine.size() > 0 && IsSamePoint(roadOutLine.back(), RoadMap.roads[index].leftEdge[i].points[j])) { |
| | | // DEBUG("重复点"); |
| | | continue; |
| | | } |
| | | changeSegment = false; |
| | | roadOutLine.push_back(RoadMap.roads[index].leftEdge[i].points[j]); |
| | | // DEBUG("做点加入 point (%f, %f)", RoadMap.roads[index].leftEdge[i].points[j].X, RoadMap.roads[index].leftEdge[i].points[j].Y); |
| | | } |
| | | changeSegment = true; |
| | | } |
| | | |
| | | for (int i = 0; i < RoadMap.roads[index].rightEdge.size(); ++i) { |
| | | for (int j = RoadMap.roads[index].rightEdge[i].points.size() - 1; j >= 0; --j) { |
| | | if (changeSegment && roadOutLine.size() > 0 && IsSamePoint(roadOutLine.back(), RoadMap.roads[index].leftEdge[i].points[j])) { |
| | | if (changeSegment && roadOutLine.size() > 0 && IsSamePoint(roadOutLine.back(), RoadMap.roads[index].rightEdge[i].points[j])) { |
| | | // DEBUG("重复点"); |
| | | continue; |
| | | } |
| | | changeSegment = false; |
| | | roadOutLine.push_back(RoadMap.roads[index].rightEdge[i].points[j]); |
| | | |
| | | // DEBUG("有点加入 point (%f, %f)", RoadMap.roads[index].rightEdge[i].points[j].X, RoadMap.roads[index].rightEdge[i].points[j].Y); |
| | | } |
| | | changeSegment = true; |
| | | } |
| | |
| | | for (int i = 0; i < area.num; ++i) { |
| | | area.point[i] = roadOutLine[i]; |
| | | } |
| | | |
| | | // { |
| | | // for (int x = 0; x < area.num; ++x) { |
| | | // DEBUG("road %d point %d (%f, %f)", index, x, area.point[x].X, area.point[x].Y); |
| | | // } |
| | | // } |
| | | |
| | | if (IntersectionOf(car->carXY[car->axial[AXIAL_FRONT]], &area) == GM_Containment) { |
| | | free(area.point); |
| | |
| | | |
| | | // 挡位不匹配超时 |
| | | if (currGearError && prevGearError) { |
| | | DEBUG("挡位错误增加 %ld毫秒 当前挡位 %d 时速 %f", TimeGetDiff(rtkTime, &gearErrorTimePoint), |
| | | ReadCarStatus(GEAR), ConvertMs2KMh(speed)); |
| | | // DEBUG("挡位错误增加 %ld毫秒 当前挡位 %d 时速 %f", TimeGetDiff(rtkTime, &gearErrorTimePoint), |
| | | // ReadCarStatus(GEAR), ConvertMs2KMh(speed)); |
| | | gearErrorTime += TimeGetDiff(rtkTime, &gearErrorTimePoint); |
| | | } |
| | | if (gearErrorTime > examParam.gear_speed_error_cumulative_time) { |
| | |
| | | DEBUG("导向类型切换 %d", Lane.guide); |
| | | } |
| | | } |
| | | DEBUG("currExamMapIndex = %d Lane.no = %d Lane.guide = %d (%f, %f)", currExamMapIndex, Lane.no, Lane.guide, car->carXY[car->axial[AXIAL_FRONT]].X, car->carXY[car->axial[AXIAL_FRONT]].Y); |
| | | |
| | | if (currExamMapIndex >= 0 && Lane.guide == 0) { |
| | | BigStraightRoadFree = AnalysisRoad(RoadMap, currExamMapIndex, Lane, car); |
| | |
| | | item = EntryItem(roadIndex, RoadMap, car, CarModelList, forward, moveDirect); |
| | | } |
| | | |
| | | if (RoadExamStatus == ROAD_EXAM_READY_NEXT && item == 3) { |
| | | if (RoadExamStatus == RoadExamStatus && item == 6) { |
| | | PlayTTS("前方会车", NULL); |
| | | } |
| | | else if (RoadExamStatus == ROAD_EXAM_READY_NEXT && item == 3) { |
| | | StartDriveStraightExam(); |
| | | RoadExamStatus = ROAD_EXAM_ITEM_STRAIGHT; |
| | | } else if (RoadExamStatus == ROAD_EXAM_READY_NEXT && item == 4) { |