| | |
| | | #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; |