| | |
| | | test_items2/through_something.cpp |
| | | test_items2/drive_straight.cpp |
| | | test_items2/stop_car.cpp |
| | | test_items2/operate_gear.cpp |
| | | |
| | | rtk_module/rtk.cpp |
| | | rtk_module/virtual_rtk.cpp |
| | |
| | | |
| | | if (start == 0) { |
| | | DEBUG("结束考试"); |
| | | |
| | | TerminateRoadExam(); |
| | | |
| | | CurrExamMapIndex = -1; |
| | | ExamStart = false; |
| | | MA_SendExamStatus(0, 0); |
| | |
| | | if (ReadCarStatus(ENGINE_START) == ENGINE_START_ACTIVE) { |
| | | if (!engineStart) { |
| | | engineStart = true; |
| | | if (ReadCarStatus(GEAR) != 'N') { |
| | | if (ReadCarStatus(GEAR) != GEAR_N) { |
| | | // 不是空挡点火,不合格 |
| | | if (ExamType == TEST_TYPE_AREA) |
| | | AddExamFault(3, rtkTime); |
| | |
| | | }*/ |
| | | |
| | | if (RxBufLen > 0) { |
| | | #if 0 |
| | | #if 1 |
| | | const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen); |
| | | if(ptr != RxBuf) { |
| | | memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf)); |
| | |
| | | #include "../driver_test.h" |
| | | #include "../test_common/car_sensor.h" |
| | | #include "../test_items2/stop_car.h" |
| | | #include "../test_items2/operate_gear.h" |
| | | |
| | | #define PARSE_BUFF_SIZE 4096 |
| | | |
| | |
| | | if (events & PLAY_TTS_DONE_EVT) { |
| | | DummyLightTTSDone(*((int *)data)); |
| | | StopCarTTSDone(*((int *)data)); |
| | | OperateGearTTSDone(*((int *)data)); |
| | | } |
| | | } |
| | | |
| | |
| | | #include "../common/apptimer.h" |
| | | #include "../native-lib.h" |
| | | #include "../utils/xconvert.h" |
| | | #include "../test_common/car_sensor.h" |
| | | |
| | | #include <vector> |
| | | #include <cstdlib> |
| | |
| | | } |
| | | |
| | | // 在这里检查转向灯状态 |
| | | if (true) { |
| | | if (ReadCarStatus(TURN_SIGNAL_LAMP) != LEFT_TURN_LIGHT) { |
| | | // 不开转向灯,扣10分 |
| | | AddExamFault(25, rtkTime); |
| | | DEBUG("未开启转向灯"); |
| | |
| | | #include "../jni_log.h" |
| | | #include "../common/apptimer.h" |
| | | #include "../utils/xconvert.h" |
| | | #include "../test_common/car_sensor.h" |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<stop_and_start> <%s>: " fmt, __func__, ##args) |
| | | |
| | |
| | | } |
| | | |
| | | // 检查是否拉住手刹 |
| | | if (true) { |
| | | if (ReadCarStatus(HAND_BREAK) != BREAK_ACTIVE) { |
| | | AddExamFault(19, rtkTime); |
| | | DEBUG("没拉手刹"); |
| | | } |
| | |
| | | #include "../jni_log.h" |
| | | #include "../utils/xconvert.h" |
| | | #include "../defs.h" |
| | | #include "../test_common/car_sensor.h" |
| | | |
| | | #include <vector> |
| | | #include <cstdlib> |
| | |
| | | |
| | | if (az >= 30) { |
| | | if (!turnLeftFinished) { |
| | | char turn_direct; |
| | | if((( ((int)heading) + 360 - enterAreaHeading) % 360) < 180) { |
| | | DEBUG("右转"); |
| | | turn_direct = 'R'; |
| | | } else { |
| | | DEBUG("左转"); |
| | | turn_direct = 'L'; |
| | | } |
| | | // 转向灯未开启,扣10分 |
| | | AddExamFault(30, rtkTime); |
| | | DEBUG("转向灯未开启"); |
| | | if ((turn_direct == 'R' && ReadCarStatus(TURN_SIGNAL_LAMP) != RIGHT_TURN_LIGHT) || |
| | | (turn_direct == 'L' && ReadCarStatus(TURN_SIGNAL_LAMP) != LEFT_TURN_LIGHT)) { |
| | | DEBUG("转向灯未开启"); |
| | | AddExamFault(30, rtkTime); |
| | | } |
| | | } |
| | | turnLeftFinished = true; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | void TerminateDummyLightExam(void) |
| | | { |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | AppTimer_delete(ExamDummyLight); |
| | | } |
| | | |
| | | static void DummyLightCheckActive(union sigval sig) |
| | | { |
| | | int active = sig.sival_int; |
| | |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num, const struct RtkTime* rtkTime); |
| | | int ExecuteDummyLightExam(const struct RtkTime* rtkTime); |
| | | void DummyLightTTSDone(int id); |
| | | void TerminateDummyLightExam(void); |
| | | |
| | | #endif //MYAPPLICATION2_DUMMY_LIGHT_H |
New file |
| | |
| | | // |
| | | // Created by YY on 2020/3/25. |
| | | // |
| | | |
| | | #include "operate_gear.h" |
| | | #include "../driver_test.h" |
| | | #include "../common/apptimer.h" |
| | | #include "../native-lib.h" |
| | | #include "../test_common/car_sensor.h" |
| | | #include "../jni_log.h" |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<operate_gear> <%s>: " fmt, __func__, ##args) |
| | | |
| | | static int opGear; |
| | | static bool testing; |
| | | static int examTtsSeq = 0; |
| | | static int expectGear; |
| | | static int upDownShift; |
| | | static bool checkError; |
| | | static int opCnt = 0; |
| | | |
| | | enum { |
| | | START_GEAR, |
| | | WAIT_TTS_END, |
| | | TTS_END, |
| | | WAITE_CHECK, |
| | | CHECKED |
| | | }; |
| | | |
| | | static void CheckGear(union sigval sig); |
| | | |
| | | void StartOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList) { |
| | | if (index == -1) |
| | | return; |
| | | |
| | | testing = true; |
| | | opGear = START_GEAR; |
| | | checkError = false; |
| | | upDownShift = 0; |
| | | opCnt = 0; |
| | | } |
| | | |
| | | void TerminateOperateGearExam(void) |
| | | { |
| | | AppTimer_delete(CheckGear); |
| | | } |
| | | |
| | | int ExecuteOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car, |
| | | LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime) { |
| | | DEBUG("opGear %d", opGear); |
| | | |
| | | if (opGear == START_GEAR) { |
| | | int currGear = ReadCarStatus(GEAR); |
| | | switch (currGear) { |
| | | case GEAR_1: { |
| | | opGear = WAIT_TTS_END; |
| | | upDownShift = 1; |
| | | expectGear = GEAR_2; |
| | | examTtsSeq = PlayTTS("请加到二挡"); |
| | | break; |
| | | } |
| | | case GEAR_2: { |
| | | opGear = WAIT_TTS_END; |
| | | if (upDownShift == 0) { |
| | | upDownShift = 1; |
| | | expectGear = GEAR_3; |
| | | examTtsSeq = PlayTTS("请加到三挡"); |
| | | } else if (upDownShift == 1) { |
| | | upDownShift = -1; |
| | | expectGear = GEAR_1; |
| | | examTtsSeq = PlayTTS("请减到一挡"); |
| | | } else { |
| | | upDownShift = 1; |
| | | expectGear = GEAR_3; |
| | | examTtsSeq = PlayTTS("请加到三挡"); |
| | | } |
| | | break; |
| | | } |
| | | case GEAR_3: { |
| | | opGear = WAIT_TTS_END; |
| | | if (upDownShift == 0) { |
| | | upDownShift = -1; |
| | | expectGear = GEAR_2; |
| | | examTtsSeq = PlayTTS("请减到二挡"); |
| | | } else if (upDownShift == 1) { |
| | | upDownShift = -1; |
| | | expectGear = GEAR_2; |
| | | examTtsSeq = PlayTTS("请减到二挡"); |
| | | } else { |
| | | upDownShift = 1; |
| | | expectGear = GEAR_4; |
| | | examTtsSeq = PlayTTS("请加到四挡"); |
| | | } |
| | | break; |
| | | } |
| | | case GEAR_4: { |
| | | opGear = WAIT_TTS_END; |
| | | if (upDownShift == 0) { |
| | | upDownShift = -1; |
| | | expectGear = GEAR_3; |
| | | examTtsSeq = PlayTTS("请减到三挡"); |
| | | } else if (upDownShift == 1) { |
| | | upDownShift = -1; |
| | | expectGear = GEAR_3; |
| | | examTtsSeq = PlayTTS("请减到三挡"); |
| | | } else { |
| | | upDownShift = 1; |
| | | expectGear = GEAR_5; |
| | | examTtsSeq = PlayTTS("请加到五挡"); |
| | | } |
| | | break; |
| | | } |
| | | case GEAR_5: { |
| | | opGear = WAIT_TTS_END; |
| | | upDownShift = -1; |
| | | expectGear = GEAR_4; |
| | | examTtsSeq = PlayTTS("请减到四挡"); |
| | | break; |
| | | } |
| | | default: |
| | | // 未读到有效挡位,继续尝试 |
| | | break; |
| | | } |
| | | } else if (opGear == WAIT_TTS_END) { |
| | | |
| | | } else if (opGear == TTS_END) { |
| | | opCnt++; |
| | | opGear = WAITE_CHECK; |
| | | checkError = false; |
| | | AppTimer_delete(CheckGear); |
| | | AppTimer_add(CheckGear, D_SEC(5)); |
| | | } else if (opGear == CHECKED) { |
| | | if (checkError) { |
| | | // 未按指令操作挡位,不合格 |
| | | DEBUG("未按指令操作挡位"); |
| | | AddExamFault(31, rtkTime); |
| | | } |
| | | |
| | | if (opCnt < 2) { |
| | | opGear = START_GEAR; |
| | | } else { |
| | | testing = false; |
| | | } |
| | | } |
| | | |
| | | return testing ? index : -1; |
| | | } |
| | | |
| | | void OperateGearTTSDone(int id) |
| | | { |
| | | DEBUG("OperateGearTTSDone %d", id); |
| | | // 等语音播报完毕后计时 |
| | | if (id == examTtsSeq) { |
| | | opGear = TTS_END; |
| | | } |
| | | } |
| | | |
| | | static void CheckGear(union sigval sig) |
| | | { |
| | | AppTimer_delete(CheckGear); |
| | | |
| | | DEBUG("检测挡位 %d", expectGear); |
| | | // 检查挡位 |
| | | if (ReadCarStatus(GEAR) != expectGear) { |
| | | // 不执行指定挡位,不合格 |
| | | checkError = true; |
| | | } |
| | | opGear = CHECKED; |
| | | } |
New file |
| | |
| | | // |
| | | // Created by YY on 2020/3/25. |
| | | // |
| | | |
| | | #ifndef MYAPPLICATION2_OPERATE_GEAR_H |
| | | #define MYAPPLICATION2_OPERATE_GEAR_H |
| | | |
| | | #include "../driver_test.h" |
| | | |
| | | void StartOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList); |
| | | int ExecuteOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car, |
| | | LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime); |
| | | void OperateGearTTSDone(int id); |
| | | void TerminateOperateGearExam(void); |
| | | |
| | | #endif //MYAPPLICATION2_OPERATE_GEAR_H |
| | |
| | | #include "../master/comm_if.h" |
| | | #include "drive_straight.h" |
| | | #include "stop_car.h" |
| | | #include "operate_gear.h" |
| | | |
| | | #include <vector> |
| | | #include <list> |
| | |
| | | static bool occurCrashRedLine; |
| | | static bool occurCrashGreenLine; |
| | | static bool occurOverSpeed; |
| | | static bool occurSecondBreak; |
| | | static int checkCrashGreenTimeout; |
| | | static char carIntersectionOfGreenLine; |
| | | static int currTurnSignalStatus; |
| | |
| | | static int startCar; |
| | | static int currExamMapIndex; |
| | | |
| | | static bool checkDoor = false; |
| | | static bool handBreakActive = false; |
| | | static bool reportRPMOver = false; |
| | | |
| | | static const int MAX_ENGINE_RPM = 2500; |
| | | static const double START_CAR_MOVE_DISTANCE = 0.5;//10.0; |
| | | static const double START_CAR_CHECK_DOOR_DISTANCE = 0.1;//1.0; |
| | | static const double START_CAR_MOVE_DISTANCE = 10.0; |
| | | static const double START_CAR_CHECK_DOOR_DISTANCE = 1.0; |
| | | static const uint32_t GEAR_N_SLIDE_TIMEOUT = D_SEC(5); |
| | | static const uint32_t GEAR_ERROR_TIMEOUT = D_SEC(15); |
| | | static const uint32_t STOP_CAR_TIME = D_SEC(2); |
| | |
| | | occurCrashRedLine = false; |
| | | occurCrashGreenLine = false; |
| | | occurOverSpeed = false; |
| | | occurSecondBreak = false; |
| | | checkCrashGreenTimeout = 0; |
| | | carIntersectionOfGreenLine = 0; |
| | | |
| | |
| | | currExamMapIndex = -1; |
| | | |
| | | startCar = START_CAR_NOT_DO; |
| | | |
| | | checkDoor = false; |
| | | handBreakActive = false; |
| | | reportRPMOver = false; |
| | | } |
| | | |
| | | void TerminateRoadExam(void) |
| | | { |
| | | TerminateDummyLightExam(); |
| | | TerminateStopCarExam(); |
| | | TerminateOperateGearExam(); |
| | | } |
| | | |
| | | static void TestRoadStartCar(const car_model *car, double speed, int moveDirect, const struct RtkTime *rtkTime) |
| | | { |
| | | double moveDistance; |
| | | static bool checkDoor = false; |
| | | static bool handBreakActive = false; |
| | | static bool reportRPMOver = false; |
| | | |
| | | if (startCar == START_CAR_NOT_DO) { |
| | | startPoint = car->basePoint; |
| | |
| | | } |
| | | } else { |
| | | occurOverSpeed = false; |
| | | } |
| | | |
| | | // 副刹车检测 |
| | | if (ReadCarStatus(SECOND_BREAK) == BREAK_ACTIVE) { |
| | | // 副刹车踩下,不合格 |
| | | if (!occurSecondBreak) { |
| | | DEBUG("副刹车动作了"); |
| | | occurSecondBreak = true; |
| | | AddExamFault(17, rtkTime); |
| | | } |
| | | } else { |
| | | occurSecondBreak = false; |
| | | } |
| | | |
| | | // 挡位匹配检测 |
| | |
| | | currTurnSignalStatus = ReadCarStatus(TURN_SIGNAL_LAMP); |
| | | break; |
| | | } |
| | | |
| | | |
| | | // 检查是否持续转向 |
| | | char turnDirect = CheckCarTurn(CarModelList); |
| | |
| | | StartDriveStraightExam(currExamMapIndex, RoadMapList); |
| | | } else if (RoadMapList[currExamMapIndex].type == STOP_CAR_MAP) { |
| | | StartStopCarExam(currExamMapIndex, RoadMapList); |
| | | } else if (RoadMapList[currExamMapIndex].type == OP_GEAER_MAP) { |
| | | StartOperateGearExam(currExamMapIndex, RoadMapList); |
| | | } |
| | | } |
| | | } else if (startCar == START_CAR_DONE) { |
| | |
| | | } else if (RoadMapList[currExamMapIndex].type == STOP_CAR_MAP) { |
| | | currExamMapIndex = ExecuteStopCarExam(currExamMapIndex, RoadMapList, car, |
| | | CarModelList, speed, moveDirect, rtkTime); |
| | | } else if (RoadMapList[currExamMapIndex].type == OP_GEAER_MAP) { |
| | | currExamMapIndex = ExecuteOperateGearExam(currExamMapIndex, RoadMapList, car, |
| | | CarModelList, speed, moveDirect, rtkTime); |
| | | } |
| | | |
| | | if (currExamMapIndex == -1) { |
| | |
| | | |
| | | void Rtk2DriveTimer(struct drive_timer &tm, const struct RtkTime *rtkTime); |
| | | void InitRoadExam(void); |
| | | void TerminateRoadExam(void); |
| | | void TestRoadGeneral(LIST_ROAD_MAP &RoadMapList, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime); |
| | | bool ExitSonArea(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car); |
| | | bool CrashSonRedLine(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car, LIST_CAR_MODEL &CarModelList); |
| | |
| | | |
| | | void StopCarTTSDone(int id) |
| | | { |
| | | DEBUG("DummyLightTTSDone %d", id); |
| | | DEBUG("StopCarTTSDone %d", id); |
| | | // 等语音播报完毕后计时 |
| | | if (id == examTtsSeq) { |
| | | ttsPlayEnd = 1; |
| | | } |
| | | } |
| | | |
| | | void TerminateStopCarExam(void) |
| | | { |
| | | AppTimer_delete(PlayTTSTimeout); |
| | | } |
| | | |
| | | int ExecuteStopCarExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car, |
| | | LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime) { |
| | | if (ttsPlayEnd == 1) { |
| | |
| | | void StopCarTTSDone(int id); |
| | | int ExecuteStopCarExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car, |
| | | LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime); |
| | | void TerminateStopCarExam(void); |
| | | |
| | | #endif //MYAPPLICATION2_STOP_CAR_H |