From c484cbb09d445e2ab30ea011c6d2ffd87202bb26 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期五, 23 十月 2020 18:05:34 +0800 Subject: [PATCH] 添加可用户配置的评判参数。 --- lib/src/main/cpp/driver_test.cpp | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 152 insertions(+), 1 deletions(-) diff --git a/lib/src/main/cpp/driver_test.cpp b/lib/src/main/cpp/driver_test.cpp index fa24fec..2e08710 100644 --- a/lib/src/main/cpp/driver_test.cpp +++ b/lib/src/main/cpp/driver_test.cpp @@ -58,6 +58,66 @@ TEST_TYPE_ROAD_CALIBRATE }; +static const int DEFAULT_START_KEY_HOLD_TIME = D_SEC(2); +static const int DEFAULT_CURVE_PAUSE_TIME = D_SEC(2); +static const int DEFAULT_PARK_BOTTOM_PAUSE_TIME = D_SEC(2); +static const int DEFAULT_PARK_BOTTOM_FINISH_TIME = D_SEC(210); +static const int DEFAULT_PART_EDGE_PAUSE_TIME = D_SEC(2); +static const int DEFAULT_PARK_EDGE_FINISH_TIME = D_SEC(90); +static const int DEFAULT_TURN_A90_PAUSE_TIME = D_SEC(2); +static const int DEFAULT_RAMP_FINISH_TIME = D_SEC(30); +static const double DEFAULT_RAMP_STOPPOINT_RED_DISTANCE = 0.5; +static const double DEFAULT_RAMP_EDGE_YELLOW_DISTANCE = 0.3; +static const double DEFAULT_RAMP_EDGE_RED_DISTANCE = 0.5; +static const double DEFAULT_RAMP_SLIDE_YELLOW_DISTANCE = 0.1; +static const double DEFAULT_RAMP_SLIDE_RED_DISTANCE = 0.3; + +static const double DEFAULT_ROAD_SLIDE_YELLOW_DISTANCE = 0.1; +static const double DEFAULT_ROAD_SLIDE_RED_DISTANCE = 0.3; +static const int DEFAULT_ROAD_MAX_DISTANCE = 3000; +static const int DEFAULT_ROAD_MAX_SPEED = 60; +static const int DEFAULT_GEAR_N_TIME = D_SEC(5); +static const int DEFAULT_SAME_GEAR_HOLD_TIME = D_SEC(5); +static const int DEFAULT_GEAR_SPEED_ERROR_MAX_TIME = D_SEC(15); +static const int DEFAULT_ROAD_PAUSE_TIME = D_SEC(2); +static const int DEFAULT_CHANGE_LANE_MIN_TIME = D_SEC(10); +static const int DEFAULT_CRASH_DOTTED_LINE_MAX_TIME = D_SEC(10); +static const int DEFAULT_TURN_SIGNAL_MIN_ADVANCE = D_SEC(3); +static const int DEFAULT_START_CAR_MAX_RMP = 2500; +static const int DEFAULT_START_CAR_DISTANCE = 10; +static const double DEFAULT_START_CAR_OPEN_DOOR_DISTANCE = 1.0; +static const char DEFAULT_START_CAR_BEGIN_TTS[] = "璇疯捣姝ワ紝缁х画瀹屾垚鑰冭瘯"; +static const char DEFAULT_START_CAR_END_TTS[] = "璧锋瀹屾垚"; +static const int CHANGE_LANE_MAX_DISTANCE = 100; +static const char DEFAULT_CHANGE_LANE_BEGIN_TTS[] = "鍓嶆柟璇峰彉鏇磋溅閬�"; +static const char DEFAULT_CHANGE_LANE_END_TTS[] = "鍙橀亾瀹屾垚"; +static const int DEFAULT_SHIFT_MAX_DISTANCE = 120; +static const int DEFAULT_SHIFT_HOLD_TIME = D_SEC(3); +static const char DEFAULT_SHIFT_BEGIN_TTS[] = "璇疯繘琛屽姞鍑忔尅浣嶆搷浣�"; +static const char DEFAULT_SHIFT_END_TTS[] = "鍔犲噺鎸′綅瀹屾垚"; +static const char DEFAULT_STRAIGHT_BEGIN_TTS[] = "璇蜂繚鎸佺洿绾胯椹�"; +static const char DEFAULT_STRAIGHT_END_TTS[] = "鐩寸嚎琛岄┒瀹屾垚"; +static const int DEFAULT_STRAIGHT_MAX_DISTANCE = 100; +static const double DEFAULT_STRAIGHT_MAX_OFFSET = 0.3; +static const int DEFAULT_OVERTAKE_MAX_DISTANCE = 150; +static const char DEFAULT_OVERTAKE_BEGIN_TTS[] = "璇疯秴瓒婂墠鏂硅溅杈�"; +static const char DEFAULT_OVERTAKE_END_TTS[] = "瓒呰溅瀹屾垚"; +static const int DEFAULT_STOP_CAR_MAX_DISTANCE = 150; +static const int DEFAULT_STOP_CAR_OPEN_DOOR_MAX_TIME = D_SEC(15); +static const double DEFAULT_STOP_CAR_EDGE_RED_DISTANCE = 0.5; +static const double DEFAULT_STOP_CAR_EDGE_YELLOW_DISTANCE = 0.5; +static const char DEFAULT_STOP_CAR_BEGIN_TTS[] = "璇烽潬杈瑰仠杞�"; +static const char DEFAULT_STOP_CAR_END_TTS[] = "闈犺竟鍋滆溅瀹屾垚"; +static const double DEFAULT_CROSSING_STOP_VALID_DISTANCE = 3.0; +static const int DEFAULT_CROSS_SCHOOL_MAX_SPEED = 30; +static const int DEFAULT_CROSS_BREAK_VALID_DISTANCE = 30; + +static const char DEFAULT_CROSSING_GO_STRAIGHT_TTS[] = "鍓嶆柟璺彛鐩磋"; +static const char DEFAULT_CROSSING_TURN_LEFT_TTS[] = "鍓嶆柟璺彛宸﹁浆"; +static const char DEFAULT_CROSSING_TURN_RIGHT_TTS[] = "鍓嶆柟璺彛鍙宠浆"; +static const char DEFAULT_CROSSING_TURN_BACK_TTS[] = "鍓嶆柟閫夋嫨鍚堥�傚湴鐐规帀澶�"; +static const char DEFAULT_CROSSING_TURN_UNKNOWN_TTS[] = "鍓嶆柟璺彛鍚粠鏁欑粌鎸囩ず"; + static bool ExamStart = false; static int ExamType; static bool reportSeatbeltEject; @@ -82,6 +142,8 @@ static bool engineStart = false; static bool engineStartTimeout = false; +exam_param_t examParam; + #define MOV_AVG_SIZE 1 #define RTK_BUFFER_SIZE 100 #define CAR_MODEL_CACHE_SIZE 10 @@ -89,6 +151,7 @@ static rtk_info *RtkBuffer = NULL; static int RtkBufferNum = 0, RtkBufferIn = 0; +static void SetExamParamDefault(void); static void EngineStartHold(union sigval sig); static void ExecuteExam(const struct RtkTime* rtkTime); static void ExecuteExam(double speed, int move, double azimuth, const struct RtkTime* rtkTime); @@ -102,6 +165,7 @@ void DriverTestInit(void) { ExamStart = false; + SetExamParamDefault(); CarModel = NULL; CarModelList.clear(); @@ -120,6 +184,93 @@ RtkBuffer = (rtk_info *) malloc(RTK_BUFFER_SIZE * sizeof(rtk_info)); RtkBufferNum = RtkBufferIn = 0; +} + +static void SetExamParamDefault(void) +{ + examParam.hold_start_key_limit_time = DEFAULT_START_KEY_HOLD_TIME; + examParam.curve_pause_criteria = DEFAULT_CURVE_PAUSE_TIME; + examParam.park_bottom_pause_criteria = DEFAULT_PARK_BOTTOM_PAUSE_TIME; + examParam.park_bottom_limit_time = DEFAULT_PARK_BOTTOM_FINISH_TIME; + examParam.park_edge_pause_criteria = DEFAULT_PART_EDGE_PAUSE_TIME; + examParam.park_edge_limit_time = DEFAULT_PARK_EDGE_FINISH_TIME; + examParam.turn_a90_pause_criteria = DEFAULT_TURN_A90_PAUSE_TIME; + + examParam.ramp_stoppoint_red_distance = DEFAULT_RAMP_STOPPOINT_RED_DISTANCE; + examParam.ramp_edge_yellow_distance = DEFAULT_RAMP_EDGE_YELLOW_DISTANCE; + examParam.ramp_edge_red_distance = DEFAULT_RAMP_EDGE_RED_DISTANCE; + examParam.ramp_slide_yellow_distance = DEFAULT_RAMP_SLIDE_YELLOW_DISTANCE; + examParam.ramp_slide_red_distance = DEFAULT_RAMP_SLIDE_RED_DISTANCE; + examParam.ramp_start_car_limit_time = DEFAULT_RAMP_FINISH_TIME; + + examParam.road_slide_yellow_distance = DEFAULT_ROAD_SLIDE_YELLOW_DISTANCE; + examParam.road_slide_red_distance = DEFAULT_ROAD_SLIDE_RED_DISTANCE; + examParam.road_total_distance = DEFAULT_ROAD_MAX_DISTANCE; + examParam.road_max_speed = DEFAULT_ROAD_MAX_SPEED; + + examParam.gear_speed_table.resize(6); + for (int i = 0; i < examParam.gear_speed_table.size(); ++i) { + examParam.gear_speed_table[i].resize(2); + } + examParam.gear_speed_table[0][0] = 0; + examParam.gear_speed_table[0][1] = 20; + examParam.gear_speed_table[1][0] = 5; + examParam.gear_speed_table[1][1] = 30; + examParam.gear_speed_table[2][0] = 15; + examParam.gear_speed_table[2][1] = 40; + examParam.gear_speed_table[3][0] = 25; + examParam.gear_speed_table[3][1] = 10000; + examParam.gear_speed_table[4][0] = 35; + examParam.gear_speed_table[4][1] = 10000; + examParam.gear_speed_table[5][0] = 45; + examParam.gear_speed_table[5][1] = 10000; + + examParam.gear_n_allow_time = DEFAULT_GEAR_N_TIME; + examParam.same_gear_min_time = DEFAULT_SAME_GEAR_HOLD_TIME; // x绉掑唴锛屼笉鍏佽N->X->N->X缃悓涓�鎸′綅 + examParam.gear_speed_error_cumulative_time = DEFAULT_GEAR_SPEED_ERROR_MAX_TIME; + examParam.road_pause_criteria = DEFAULT_ROAD_PAUSE_TIME; + examParam.continuous_change_lane_min_time = DEFAULT_CHANGE_LANE_MIN_TIME; + examParam.crash_dotted_line_cumulative_time = DEFAULT_CRASH_DOTTED_LINE_MAX_TIME; + examParam.turn_signal_min_advance = DEFAULT_TURN_SIGNAL_MIN_ADVANCE; + examParam.start_car_max_rpm = DEFAULT_START_CAR_MAX_RMP; + examParam.start_car_limit_distance = DEFAULT_START_CAR_DISTANCE; + examParam.open_door_drive_allow_distance = DEFAULT_START_CAR_OPEN_DOOR_DISTANCE; + examParam.start_car_begin_tts = DEFAULT_START_CAR_BEGIN_TTS; + examParam.start_car_end_tts = DEFAULT_START_CAR_END_TTS; + examParam.change_lane_limit_distance = CHANGE_LANE_MAX_DISTANCE; + examParam.change_lane_begin_tts = DEFAULT_CHANGE_LANE_BEGIN_TTS; + examParam.change_lane_end_tts = DEFAULT_CHANGE_LANE_END_TTS; + examParam.shift_limit_distance = DEFAULT_SHIFT_MAX_DISTANCE; + examParam.shift_hold_time = DEFAULT_SHIFT_HOLD_TIME; + examParam.shift_begin_tts = DEFAULT_SHIFT_BEGIN_TTS; + examParam.shift_end_tts = DEFAULT_SHIFT_END_TTS; + examParam.shift_up_tts = ""; + examParam.shift_down_tts = ""; + + examParam.straight_begin_tts = DEFAULT_STRAIGHT_BEGIN_TTS; + examParam.straight_end_tts = DEFAULT_STRAIGHT_END_TTS; + examParam.straight_limit_distance = DEFAULT_STRAIGHT_MAX_DISTANCE; + examParam.straight_max_offset = DEFAULT_STRAIGHT_MAX_OFFSET; + + examParam.overtake_limit_distance = DEFAULT_OVERTAKE_MAX_DISTANCE; + examParam.overtake_begin_tts = DEFAULT_OVERTAKE_BEGIN_TTS; + examParam.overtake_end_tts = DEFAULT_OVERTAKE_END_TTS; + + examParam.stop_car_limit_distance = DEFAULT_STOP_CAR_MAX_DISTANCE; + examParam.stop_car_open_door_allow_time = DEFAULT_STOP_CAR_OPEN_DOOR_MAX_TIME; + examParam.stop_car_edge_red_distance = DEFAULT_STOP_CAR_EDGE_RED_DISTANCE; + examParam.stop_car_edge_yellow_distance = DEFAULT_STOP_CAR_EDGE_YELLOW_DISTANCE; + examParam.stop_car_begin_tts = DEFAULT_STOP_CAR_BEGIN_TTS; + examParam.stop_car_end_tts = DEFAULT_STOP_CAR_END_TTS; + examParam.crossing_stop_valid_distance = DEFAULT_CROSSING_STOP_VALID_DISTANCE; + examParam.cross_school_max_speed = DEFAULT_CROSS_SCHOOL_MAX_SPEED; + examParam.crossing_break_valid_distance = DEFAULT_CROSS_BREAK_VALID_DISTANCE; + + examParam.crossing_go_straight_tts = DEFAULT_CROSSING_GO_STRAIGHT_TTS; + examParam.crossing_turn_left_tts = DEFAULT_CROSSING_TURN_LEFT_TTS; + examParam.crossing_turn_right_tts = DEFAULT_CROSSING_TURN_RIGHT_TTS; + examParam.crossing_turn_back_tts = DEFAULT_CROSSING_TURN_BACK_TTS; + examParam.crossing_turn_unknown_tts = DEFAULT_CROSSING_TURN_UNKNOWN_TTS; } static void ReadDriverExamPrimerTimeout(union sigval sig) @@ -660,7 +811,7 @@ AddExamFault(4, rtkTime); } AppTimer_delete(EngineStartHold); - AppTimer_add(EngineStartHold, D_SEC(2)); + AppTimer_add(EngineStartHold, examParam.hold_start_key_limit_time); } } else if (engineStart) { engineStart = false; -- Gitblit v1.8.0