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/test_items/driving_curve.cpp | 4 lib/src/main/cpp/driver_test.cpp | 153 ++++++++++++ lib/src/main/cpp/native-lib.h | 3 lib/src/main/cpp/test_items/stop_and_start.cpp | 21 - lib/src/main/cpp/test_items2/car_start.cpp | 14 lib/src/main/cpp/test_items2/stop_car.cpp | 24 - lib/src/main/cpp/rtk_module/rtk.cpp | 2 lib/src/main/cpp/test_items2/change_lane.cpp | 6 lib/src/main/cpp/test_items2/operate_gear.cpp | 8 lib/src/main/cpp/driver_test.h | 77 ++++++ lib/src/main/cpp/test_items/park_bottom.cpp | 7 lib/src/main/cpp/test_items/turn_a90.cpp | 4 lib/src/main/cpp/test_items2/drive_straight.cpp | 13 lib/src/main/cpp/test_items/park_edge.cpp | 6 lib/src/main/cpp/test_items2/overtake.cpp | 6 lib/src/main/cpp/master/comm_if.cpp | 227 ++++++++++++++++++ lib/src/main/cpp/native-lib.cpp | 5 lib/src/main/cpp/test_items2/through_something.cpp | 16 lib/src/main/cpp/test_items2/road_exam.cpp | 75 ++--- lib/src/main/cpp/rtk_platform/platform.cpp | 5 20 files changed, 546 insertions(+), 130 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; diff --git a/lib/src/main/cpp/driver_test.h b/lib/src/main/cpp/driver_test.h index 07c91ff..11d5134 100644 --- a/lib/src/main/cpp/driver_test.h +++ b/lib/src/main/cpp/driver_test.h @@ -212,6 +212,83 @@ Polygon map2; }; +typedef struct { + int hold_start_key_limit_time; // 鐐圭伀淇濇寔锛屾绉� + + int curve_pause_criteria; // 鍋滆溅鏂畾锛岃豹绉� + + int park_bottom_pause_criteria; // 璞 + int park_bottom_limit_time; // 绉� + + int park_edge_pause_criteria; // MSec + int park_edge_limit_time; // Sec + + int turn_a90_pause_criteria; // MSec + + double ramp_stoppoint_red_distance; // 绫� + double ramp_edge_yellow_distance; + double ramp_edge_red_distance; + double ramp_slide_yellow_distance; + double ramp_slide_red_distance; + int ramp_start_car_limit_time; // Sec + + double road_slide_yellow_distance; + double road_slide_red_distance; + int road_total_distance; + int road_max_speed; // Km per hour + vector<vector<int>> gear_speed_table; + int gear_n_allow_time; // Sec + int same_gear_min_time; // Sec, x绉掑唴锛屼笉鍏佽N->X->N->X缃悓涓�鎸′綅 + int gear_speed_error_cumulative_time; // Sec + int road_pause_criteria; // MSec + int continuous_change_lane_min_time; // Sec + int crash_dotted_line_cumulative_time; // Sec + int turn_signal_min_advance; // Sec + int start_car_max_rpm; + int start_car_limit_distance; + double open_door_drive_allow_distance; + string start_car_begin_tts; + string start_car_end_tts; + + int change_lane_limit_distance; + string change_lane_begin_tts; + string change_lane_end_tts; + + int shift_limit_distance; + int shift_hold_time; // Sec + string shift_begin_tts; + string shift_end_tts; + string shift_up_tts; + string shift_down_tts; + + string straight_begin_tts; + string straight_end_tts; + int straight_limit_distance; + double straight_max_offset; + + int overtake_limit_distance; + string overtake_begin_tts; + string overtake_end_tts; + + int stop_car_limit_distance; + int stop_car_open_door_allow_time; + double stop_car_edge_red_distance; + double stop_car_edge_yellow_distance; + string stop_car_begin_tts; + string stop_car_end_tts; + double crossing_stop_valid_distance; + int cross_school_max_speed; + int crossing_break_valid_distance; + + string crossing_go_straight_tts; + string crossing_turn_left_tts; + string crossing_turn_right_tts; + string crossing_turn_back_tts; + string crossing_turn_unknown_tts; +} exam_param_t; + +extern exam_param_t examParam; + typedef vector<struct area_exam_map> LIST_AREA_MAP; typedef list<car_model *> LIST_CAR_MODEL; diff --git a/lib/src/main/cpp/master/comm_if.cpp b/lib/src/main/cpp/master/comm_if.cpp index 6009256..3c01860 100644 --- a/lib/src/main/cpp/master/comm_if.cpp +++ b/lib/src/main/cpp/master/comm_if.cpp @@ -40,6 +40,7 @@ #define ID_MS_ROAD_MAP 0x8014 #define ID_MS_ROAD_MAP2 0x8013 #define ID_MS_SCHEME 0x8017 +#define ID_MS_EXAM_PARAM 0x8019 #define ID_SM_READ_CAR 0x0007 #define ID_MS_CAR 0x8007 @@ -1370,6 +1371,232 @@ } break; } + + case ID_MS_EXAM_PARAM: { + Document doc; + doc.Parse(value); + if (!doc.HasParseError()) { + if (doc.HasMember("hold_start_key_limit_time")) { + const Value &a = doc["hold_start_key_limit_time"]; + examParam.hold_start_key_limit_time = a.GetInt(); + } + + if (doc.HasMember("curve_pause_criteria")) { + const Value &a = doc["curve_pause_criteria"]; + examParam.curve_pause_criteria = a.GetInt(); + } + + if (doc.HasMember("park_bottom_pause_criteria")) { + const Value &a = doc["park_bottom_pause_criteria"]; + examParam.park_bottom_pause_criteria = a.GetInt(); + } + + if (doc.HasMember("park_bottom_limit_time")) { + const Value &a = doc["park_bottom_limit_time"]; + examParam.park_bottom_limit_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("park_edge_pause_criteria")) { + const Value &a = doc["park_edge_pause_criteria"]; + examParam.park_edge_pause_criteria = a.GetInt(); + } + + if (doc.HasMember("park_edge_limit_time")) { + const Value &a = doc["park_edge_limit_time"]; + examParam.park_edge_limit_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("turn_a90_pause_criteria")) { + const Value &a = doc["turn_a90_pause_criteria"]; + examParam.turn_a90_pause_criteria = a.GetInt(); + } + + if (doc.HasMember("ramp_stoppoint_red_distance")) { + const Value &a = doc["ramp_stoppoint_red_distance"]; + examParam.ramp_stoppoint_red_distance = a.GetDouble(); + } + + if (doc.HasMember("ramp_edge_yellow_distance")) { + const Value &a = doc["ramp_edge_yellow_distance"]; + examParam.ramp_edge_yellow_distance = a.GetDouble(); + } + + if (doc.HasMember("ramp_edge_red_distance")) { + const Value &a = doc["ramp_edge_red_distance"]; + examParam.ramp_edge_red_distance = a.GetDouble(); + } + + if (doc.HasMember("ramp_slide_yellow_distance")) { + const Value &a = doc["ramp_slide_yellow_distance"]; + examParam.ramp_slide_yellow_distance = a.GetDouble(); + } + + if (doc.HasMember("ramp_slide_red_distance")) { + const Value &a = doc["ramp_slide_red_distance"]; + examParam.ramp_slide_red_distance = a.GetDouble(); + } + + if (doc.HasMember("ramp_start_car_limit_time")) { + const Value &a = doc["ramp_start_car_limit_time"]; + examParam.ramp_start_car_limit_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("road_slide_yellow_distance")) { + const Value &a = doc["road_slide_yellow_distance"]; + examParam.road_slide_yellow_distance = a.GetDouble(); + } + + double road_slide_red_distance; + if (doc.HasMember("road_slide_red_distance")) { + const Value &a = doc["road_slide_red_distance"]; + examParam.road_slide_red_distance = a.GetDouble(); + } + + if (doc.HasMember("road_total_distance")) { + const Value &a = doc["road_total_distance"]; + examParam.road_total_distance = a.GetDouble(); + } + + if (doc.HasMember("road_max_speed")) { + const Value &a = doc["road_max_speed"]; + examParam.road_max_speed = a.GetInt(); + } + + if (doc.HasMember("gear_speed_table")) { + const Value &a = doc["gear_speed_table"]; + + int m = 0, n = 0; + + for (Value::ConstValueIterator itr = a.Begin(); + itr != a.End() && m < 6; ++itr, ++m) { + n = 0; + for (Value::ConstValueIterator itr2 = (*itr).Begin(); + itr2 != (*itr).End() && n < 2; ++itr2, ++n) { + examParam.gear_speed_table[m][n] = (*itr2).GetInt(); + } + } + } + + if (doc.HasMember("gear_n_allow_time")) { + const Value &a = doc["gear_n_allow_time"]; + examParam.gear_n_allow_time = D_SEC(a.GetInt()); + } + + + if (doc.HasMember("same_gear_min_time")) { + const Value &a = doc["same_gear_min_time"]; + examParam.same_gear_min_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("gear_speed_error_cumulative_time")) { + const Value &a = doc["gear_speed_error_cumulative_time"]; + examParam.gear_speed_error_cumulative_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("road_pause_criteria")) { + const Value &a = doc["road_pause_criteria"]; + examParam.road_pause_criteria = a.GetInt(); + } + + if (doc.HasMember("continuous_change_lane_min_time")) { + const Value &a = doc["continuous_change_lane_min_time"]; + examParam.continuous_change_lane_min_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("crash_dotted_line_cumulative_time")) { + const Value &a = doc["crash_dotted_line_cumulative_time"]; + examParam.crash_dotted_line_cumulative_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("turn_signal_min_advance")) { + const Value &a = doc["turn_signal_min_advance"]; + examParam.turn_signal_min_advance = D_SEC(a.GetInt()); + } + + if (doc.HasMember("start_car_max_rpm")) { + const Value &a = doc["start_car_max_rpm"]; + examParam.start_car_max_rpm = a.GetInt(); + } + + if (doc.HasMember("start_car_limit_distance")) { + const Value &a = doc["start_car_limit_distance"]; + examParam.start_car_limit_distance = a.GetInt(); + } + + if (doc.HasMember("open_door_drive_allow_distance")) { + const Value &a = doc["open_door_drive_allow_distance"]; + examParam.open_door_drive_allow_distance = a.GetDouble(); + } + + if (doc.HasMember("change_lane_limit_distance")) { + const Value &a = doc["change_lane_limit_distance"]; + examParam.change_lane_limit_distance = a.GetInt(); + } + + if (doc.HasMember("shift_limit_distance")) { + const Value &a = doc["shift_limit_distance"]; + examParam.shift_limit_distance = a.GetInt(); + } + + if (doc.HasMember("shift_hold_time")) { + const Value &a = doc["shift_hold_time"]; + examParam.shift_hold_time = D_SEC(a.GetInt()); + } + + int straight_limit_distance; + if (doc.HasMember("straight_limit_distance")) { + const Value &a = doc["straight_limit_distance"]; + examParam.straight_limit_distance = a.GetInt(); + } + + if (doc.HasMember("straight_max_offset")) { + const Value &a = doc["straight_max_offset"]; + examParam.straight_max_offset = a.GetDouble(); + } + + if (doc.HasMember("overtake_limit_distance")) { + const Value &a = doc["overtake_limit_distance"]; + examParam.overtake_limit_distance = a.GetInt(); + } + + if (doc.HasMember("stop_car_limit_distance")) { + const Value &a = doc["stop_car_limit_distance"]; + examParam.stop_car_limit_distance = a.GetInt(); + } + + if (doc.HasMember("stop_car_open_door_allow_time")) { + const Value &a = doc["stop_car_open_door_allow_time"]; + examParam.stop_car_open_door_allow_time = D_SEC(a.GetInt()); + } + + if (doc.HasMember("stop_car_edge_red_distance")) { + const Value &a = doc["stop_car_edge_red_distance"]; + examParam.stop_car_edge_red_distance = a.GetDouble(); + } + + if (doc.HasMember("stop_car_edge_yellow_distance")) { + const Value &a = doc["stop_car_edge_yellow_distance"]; + examParam.stop_car_edge_yellow_distance = a.GetDouble(); + } + + if (doc.HasMember("crossing_stop_valid_distance")) { + const Value &a = doc["crossing_stop_valid_distance"]; + examParam.crossing_stop_valid_distance = a.GetDouble(); + } + + if (doc.HasMember("cross_school_max_speed")) { + const Value &a = doc["cross_school_max_speed"]; + examParam.cross_school_max_speed = a.GetInt(); + } + + if (doc.HasMember("crossing_break_valid_distance")) { + const Value &a = doc["crossing_break_valid_distance"]; + examParam.crossing_break_valid_distance = a.GetInt(); + } + } + break; + } + case ID_MS_MAP: { Document doc; doc.Parse(value); diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp index 823ca99..2eb0fc9 100644 --- a/lib/src/main/cpp/native-lib.cpp +++ b/lib/src/main/cpp/native-lib.cpp @@ -252,6 +252,11 @@ return id; } +int PlayTTS(std::string &tts, void (*callback)(int)) +{ + return PlayTTS(tts.c_str(), callback); +} + void PlayRing(void) { JNIEnv *env; diff --git a/lib/src/main/cpp/native-lib.h b/lib/src/main/cpp/native-lib.h index a088514..bff3f5d 100644 --- a/lib/src/main/cpp/native-lib.h +++ b/lib/src/main/cpp/native-lib.h @@ -6,6 +6,8 @@ #define RTKBASESTATION_NATIVE_LIB_H #include <cstdint> +#include <string> + #include "test_common/Geometry.h" typedef struct { @@ -24,6 +26,7 @@ void DrawScreen(const Polygon *map, const Polygon *car); void SendMsgToMainProc(int cmd, const char *value); int PlayTTS(const char *string, void (*callback)(int)); +int PlayTTS(std::string &tts, void (*callback)(int)); void PlayRing(void); #endif //RTKBASESTATION_NATIVE_LIB_H diff --git a/lib/src/main/cpp/rtk_module/rtk.cpp b/lib/src/main/cpp/rtk_module/rtk.cpp index b7afde4..a5c75d3 100644 --- a/lib/src/main/cpp/rtk_module/rtk.cpp +++ b/lib/src/main/cpp/rtk_module/rtk.cpp @@ -214,7 +214,7 @@ }*/ if (RxBufLen > 0) { -#if 0 +#if 1 const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen); if(ptr != RxBuf) { memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf)); diff --git a/lib/src/main/cpp/rtk_platform/platform.cpp b/lib/src/main/cpp/rtk_platform/platform.cpp index a3b0098..a2e10ba 100644 --- a/lib/src/main/cpp/rtk_platform/platform.cpp +++ b/lib/src/main/cpp/rtk_platform/platform.cpp @@ -565,8 +565,9 @@ if (length == 4) MA_MainProcMsgEntry(c.a, NULL); - else - MA_MainProcMsgEntry(c.a, (char *)data + 4); + else { + MA_MainProcMsgEntry(c.a, (char *) data + 4); + } } } diff --git a/lib/src/main/cpp/test_items/driving_curve.cpp b/lib/src/main/cpp/test_items/driving_curve.cpp index 9f19572..085a8d0 100644 --- a/lib/src/main/cpp/test_items/driving_curve.cpp +++ b/lib/src/main/cpp/test_items/driving_curve.cpp @@ -18,8 +18,6 @@ #define DEBUG(fmt, args...) LOGD("<driving_curve> <%s>: " fmt, __func__, ##args) -const uint32_t STOP_CAR_TIME = D_SEC(2); - static bool testing = false; static int mapIndex = 0; static uint32_t stopTimepoint = 0; @@ -132,7 +130,7 @@ } else if (moveDirect == 0) { uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10); - if (tp - stopTimepoint >= STOP_CAR_TIME && !reportStopCarTimeout) { + if (tp - stopTimepoint >= examParam.curve_pause_criteria && !reportStopCarTimeout) { // 鍋滆溅瓒�2绉掞紝涓嶅悎鏍� AddExamFault(28, rtkTime); DEBUG("涓�斿仠杞�"); diff --git a/lib/src/main/cpp/test_items/park_bottom.cpp b/lib/src/main/cpp/test_items/park_bottom.cpp index 5854125..40350b5 100644 --- a/lib/src/main/cpp/test_items/park_bottom.cpp +++ b/lib/src/main/cpp/test_items/park_bottom.cpp @@ -27,12 +27,9 @@ THIRD_TOUCH_CTRL_LINE }; -const int PARK_TIMEOUT = D_SEC(210); - static bool testing = false, reverseCar = false; static int mapIndex = 0; -const uint32_t STOP_CAR_TIME = D_SEC(2); const uint32_t CHECK_PARK_DELAY = 400; static uint32_t stopTimepoint; @@ -153,7 +150,7 @@ } } - if (testing && darray[0] > 0 && tp - firstReverseTimepoint >= PARK_TIMEOUT) { + if (testing && darray[0] > 0 && tp - firstReverseTimepoint >= examParam.park_bottom_limit_time) { // 瀹屾垚瓒呮椂锛屼笉鍚堟牸 if (!reportExamTimeout) { reportExamTimeout = true; @@ -178,7 +175,7 @@ if (moveDirect == storeMoveDirectBeforeStop) { // 鍚屾柟鍚戝啀鍚姩锛岀户缁垽鏂槸鍚﹀仠杞﹁秴鏃� - if (tp - stopTimepoint >= STOP_CAR_TIME && reverseCar) { + if (tp - stopTimepoint >= examParam.park_bottom_pause_criteria && reverseCar) { // 鍋滆溅瓒�2绉掞紝姣忔鎵�5鍒� AddExamFault(11, rtkTime); DEBUG("涓�斿仠杞�"); diff --git a/lib/src/main/cpp/test_items/park_edge.cpp b/lib/src/main/cpp/test_items/park_edge.cpp index fab68ea..6ad7c5e 100644 --- a/lib/src/main/cpp/test_items/park_edge.cpp +++ b/lib/src/main/cpp/test_items/park_edge.cpp @@ -20,8 +20,6 @@ using namespace std; -const int PARK_TIMEOUT = D_SEC(90); -const uint32_t STOP_CAR_TIME = D_SEC(2); const uint32_t CHECK_PARK_DELAY = 400; static int mapIndex = 0; @@ -122,7 +120,7 @@ if (occurMoveBack) { uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10); - if (!reportExamTimeout && tp - moveBackTimePoint >= PARK_TIMEOUT) { + if (!reportExamTimeout && tp - moveBackTimePoint >= examParam.park_edge_limit_time) { // 瓒呮椂90绉掞紝涓嶅悎鏍� AddExamFault(22, rtkTime); reportExamTimeout = true; @@ -145,7 +143,7 @@ if (moveStatus == storeMoveStatusBeforeStop) { // 鍚屾柟鍚戝啀鍚姩锛岀户缁垽鏂槸鍚﹀仠杞﹁秴鏃� - if (tp - stopTimepoint >= STOP_CAR_TIME && occurMoveBack) { + if (tp - stopTimepoint >= examParam.park_edge_pause_criteria && occurMoveBack) { // 鍋滆溅瓒�2绉掞紝姣忔鎵�5鍒� AddExamFault(26, rtkTime); DEBUG("鍋滆溅瓒呮椂"); diff --git a/lib/src/main/cpp/test_items/stop_and_start.cpp b/lib/src/main/cpp/test_items/stop_and_start.cpp index d75ed70..477884b 100644 --- a/lib/src/main/cpp/test_items/stop_and_start.cpp +++ b/lib/src/main/cpp/test_items/stop_and_start.cpp @@ -19,12 +19,7 @@ using namespace std; -const double STOP_DISTANCE_THRESHOLD_RED = 0.5; -const double EDGE_DISTANCE_THRESHOLD_RED = 0.5; -const double EDGE_DISTANCE_THRESHOLD_YELLOW = 0.3; -const double SLIDE_DISTANCE_THRESHOLD_RED = 0.3; -const double SLIDE_DISTANCE_THRESHOLD_YELLOW = 0.1; -const uint32_t CAR_START_TIMEOUT = D_SEC(30); + const uint32_t STOP_CAR_TIME = D_SEC(1); const double EPSILON = 1e-3; @@ -126,7 +121,7 @@ DEBUG("DIS1 = %f DIS2 = %f", dis1, dis2); - if (dis1 > STOP_DISTANCE_THRESHOLD_RED) { + if (dis1 > examParam.ramp_stoppoint_red_distance) { // 璺濈鍋滄绾垮墠鍚庤秴鍑�50鍘樼背 AddExamFault(12, rtkTime); DEBUG("璺濈鍋滄绾垮墠鍚庤秴鍑�50鍘樼背锛屼笉鍚堟牸"); @@ -136,12 +131,12 @@ DEBUG("鍓嶄繚闄╂病鏈変綅浜庡仠姝㈠甫鍐咃紝浣嗘病鏈夎秴鍑�50鍘樼背"); } - if (dis2 > EDGE_DISTANCE_THRESHOLD_RED) { + if (dis2 > examParam.ramp_edge_red_distance) { // 璺濈杈圭嚎瓒呭嚭50鍘樼背,涓嶅悎鏍� AddExamFault(14, rtkTime); DEBUG("璺濈杈圭嚎瓒呭嚭50鍘樼背"); - } else if (dis2 > EDGE_DISTANCE_THRESHOLD_YELLOW) { - // 璺濈杈圭嚎瓒呭嚭30鍘樼背锛屼笉鍚堟牸 + } else if (dis2 > examParam.ramp_edge_yellow_distance) { + // 璺濈杈圭嚎瓒呭嚭30鍘樼背锛屾墸10鍒� AddExamFault(18, rtkTime); DEBUG("璺濈杈圭嚎瓒呭嚭30鍘樼背"); } @@ -158,11 +153,11 @@ // 鍙戠敓鍚庢粦 double slideDistance = DistanceOf(stopPoint, car->carXY[car->axial[AXIAL_FRONT]]); - if (slideDistance > SLIDE_DISTANCE_THRESHOLD_YELLOW) { + if (slideDistance > examParam.ramp_slide_yellow_distance) { slideNormalDistance = true; } - if (slideDistance > SLIDE_DISTANCE_THRESHOLD_RED && !slideLongDistance && !reportSlideFault) { + if (slideDistance > examParam.ramp_slide_red_distance && !slideLongDistance && !reportSlideFault) { // 鍚庢粦瓒呰繃30鍘樼背, 涓嶅悎鏍� AddExamFault(16, rtkTime); DEBUG("鍚庢粦瓒呰繃30鍘樼背"); @@ -174,7 +169,7 @@ if (!reportStartTimeout && (IntersectionOfLine(map->point[4], stopPoint, car->carXY[car->axial[AXIAL_FRONT]]) != -1 || DistanceOf(stopPoint, car->carXY[car->axial[AXIAL_FRONT]]) < 0.1)) { - if (TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10) - stopCarTime > CAR_START_TIMEOUT) { + if (TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10) - stopCarTime > examParam.ramp_start_car_limit_time) { // 璧锋鏃堕棿瓒呰繃30绉掞紝涓嶅悎鏍� AddExamFault(15, rtkTime); DEBUG("璧锋鏃堕棿瓒呰繃30绉�"); diff --git a/lib/src/main/cpp/test_items/turn_a90.cpp b/lib/src/main/cpp/test_items/turn_a90.cpp index b0777ea..be8b131 100644 --- a/lib/src/main/cpp/test_items/turn_a90.cpp +++ b/lib/src/main/cpp/test_items/turn_a90.cpp @@ -20,8 +20,6 @@ using namespace std; -const uint32_t STOP_CAR_TIME = D_SEC(2); - static bool testing; static int mapIndex; @@ -101,7 +99,7 @@ } else if (moveDirect == 0) { uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10); - if (tp - stopTimepoint >= STOP_CAR_TIME && !reportStopCarTimeout) { + if (tp - stopTimepoint >= examParam.turn_a90_pause_criteria && !reportStopCarTimeout) { // 鍋滆溅瓒�2绉掞紝姣忔鎵�5鍒� AddExamFault(31, rtkTime); DEBUG("涓�斿仠杞�"); diff --git a/lib/src/main/cpp/test_items2/car_start.cpp b/lib/src/main/cpp/test_items2/car_start.cpp index 9d0fb35..fdc3a59 100644 --- a/lib/src/main/cpp/test_items2/car_start.cpp +++ b/lib/src/main/cpp/test_items2/car_start.cpp @@ -13,10 +13,6 @@ #define DEBUG(fmt, args...) LOGD("<road_exam car_start> <%s>: " fmt, __func__, ##args) -static const int MAX_ENGINE_RPM = 2500; -static const double START_CAR_MOVE_DISTANCE = 10.0; -static const double START_CAR_CHECK_DOOR_DISTANCE = 1.0; - static double startCarMoveDistance; static bool checkEngineRPM, checkStartCarSignal, checkDoor, handBreakActive; @@ -32,7 +28,7 @@ checkStartCarSignal = false; checkDoor = false; handBreakActive = false; - PlayTTS("璇疯捣姝�", cb); + PlayTTS(examParam.start_car_begin_tts, cb); DEBUG("杞﹁締璧锋"); } @@ -61,7 +57,7 @@ } } - if (moveDistance > START_CAR_MOVE_DISTANCE) { + if (moveDistance > examParam.start_car_limit_distance) { sensor = ReadCarSensorValue(HAND_BREAK); if (sensor.name == HAND_BREAK && sensor.value == BREAK_ACTIVE) { @@ -74,11 +70,11 @@ AddExamFault(26, rtkTime); } - PlayTTS("瀹屾垚璧锋", NULL); + PlayTTS(examParam.start_car_end_tts, NULL); DEBUG("############# 瀹屾垚璧锋 ############"); return false; - } else if (moveDistance >= START_CAR_CHECK_DOOR_DISTANCE) { + } else if (moveDistance >= examParam.open_door_drive_allow_distance) { if (!checkDoor) { checkDoor = true; @@ -96,7 +92,7 @@ } } - if (ReadCarStatus(ENGINE_RPM) > MAX_ENGINE_RPM && !checkEngineRPM) { + if (ReadCarStatus(ENGINE_RPM) > examParam.start_car_max_rpm && !checkEngineRPM) { // 杞�熻秴鏍囷紝涓嶅悎鏍� DEBUG("杞�熻秴鏍�"); AddExamFault(29, rtkTime); diff --git a/lib/src/main/cpp/test_items2/change_lane.cpp b/lib/src/main/cpp/test_items2/change_lane.cpp index 0fb8225..80053ac 100644 --- a/lib/src/main/cpp/test_items2/change_lane.cpp +++ b/lib/src/main/cpp/test_items2/change_lane.cpp @@ -27,7 +27,7 @@ start = false; originalLane = ori_lane; - PlayTTS("鍓嶆柟璇峰彉鏇磋溅閬�", TtsBack); + PlayTTS(examParam.change_lane_begin_tts, TtsBack); } bool TestChangeLane(int currLane, const struct RtkTime *rtkTime) @@ -36,11 +36,11 @@ return true; if (originalLane != currLane) { DEBUG("瀹屾垚鍙橀亾"); - PlayTTS("瀹屾垚鍙橀亾", NULL); + PlayTTS(examParam.change_lane_end_tts, NULL); return false; } - if (ReadOdo() - maxMoveDistance > 100) { + if (ReadOdo() - maxMoveDistance > examParam.change_lane_limit_distance) { // 瓒呰溅鏈畬鎴� DEBUG("鍙橀亾鍥哄畾璺濈鍐呮湭瀹屾垚 褰撳墠閲岀▼ %f", ReadOdo()); AddExamFault(3, rtkTime); diff --git a/lib/src/main/cpp/test_items2/drive_straight.cpp b/lib/src/main/cpp/test_items2/drive_straight.cpp index 8b7d1cf..44d120a 100644 --- a/lib/src/main/cpp/test_items2/drive_straight.cpp +++ b/lib/src/main/cpp/test_items2/drive_straight.cpp @@ -14,9 +14,6 @@ #define DEBUG(fmt, args...) LOGD("<road_exam drive_straight> <%s>: " fmt, __func__, ##args) -static const double CHECK_STAGE_DISTANCE = 100.0; -static const double MAX_OFFSET_DISTANCE = 0.3; - static int setup; static double beginOdo; static int yaw_stat; @@ -31,7 +28,7 @@ DEBUG("寮�濮嬬洿绾胯椹�"); setup = 0; yaw_stat = 0; - PlayTTS("璇蜂繚鎸佺洿绾胯椹�", TtsBack); + PlayTTS(examParam.straight_begin_tts, TtsBack); } bool TestDriveStraight(road_exam_map &RoadMap, int roadIndex, const car_model *car, const struct RtkTime *rtkTime) { @@ -70,7 +67,7 @@ } else if (setup == 2) { offset1 = DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], baseLine); - if (offset1 > MAX_OFFSET_DISTANCE) { + if (offset1 > examParam.straight_max_offset) { DEBUG("铏氭嫙鐩寸嚎鍋忕Щ澶т簬30鍘樼背 offset1 = %f", offset1); // // 鍋忕Щ澶т簬30鍘樼背锛屼笉鍚堟牸 // AddExamFault(30, rtkTime); @@ -80,7 +77,7 @@ PointF px = CalcProjectionWithRoadEdge(RoadMap.roads[roadIndex].rightEdge, car->carXY[car->axial[AXIAL_FRONT]]); offset2 = DistanceOf(px, car->carXY[car->axial[AXIAL_FRONT]]); - if (fabs(offset2 - offsetBase) > MAX_OFFSET_DISTANCE) { + if (fabs(offset2 - offsetBase) > examParam.straight_max_offset) { DEBUG("鐩寸嚎鍋忕Щ澶т簬30鍘樼背 offset2 = %f", fabs(offset2 - offsetBase)); // 鍋忕Щ澶т簬30鍘樼背锛屼笉鍚堟牸 AddExamFault(30, rtkTime); @@ -88,10 +85,10 @@ } } - if (setup == 2 && ReadOdo() - beginOdo > CHECK_STAGE_DISTANCE) { + if (setup == 2 && ReadOdo() - beginOdo > examParam.straight_limit_distance) { DEBUG("鐩寸嚎琛岄┒缁撴潫 offset1 = %f offset2 = %f", offset1, fabs(offset2 - offsetBase)); - PlayTTS("鐩寸嚎琛岄┒缁撴潫", NULL); + PlayTTS(examParam.straight_end_tts, NULL); return false; } diff --git a/lib/src/main/cpp/test_items2/operate_gear.cpp b/lib/src/main/cpp/test_items2/operate_gear.cpp index d365cc7..c403d17 100644 --- a/lib/src/main/cpp/test_items2/operate_gear.cpp +++ b/lib/src/main/cpp/test_items2/operate_gear.cpp @@ -32,7 +32,7 @@ setup = 0; - PlayTTS("璇疯繘琛屽姞鍑忔尅浣嶆搷浣�", TtsBack); + PlayTTS(examParam.shift_begin_tts, TtsBack); } bool TestOperateGear(const struct RtkTime *rtkTime) @@ -104,7 +104,7 @@ setup = 3; } } else if (setup == 3) { - if (TimeGetDiff(rtkTime, &shiftTime) >= D_SEC(3)) { + if (TimeGetDiff(rtkTime, &shiftTime) >= examParam.shift_hold_time) { setup = 4; char buff[128]; expectGear += 0 - upDownShift; @@ -130,8 +130,8 @@ DEBUG("浜屾鎹㈡尅鎴愬姛锛屼笅涓�涓�..."); } } else if (setup == 5) { - if (TimeGetDiff(rtkTime, &shiftTime) >= D_SEC(3)) { - PlayTTS("鍔犲噺鎸′綅鎿嶄綔缁撴潫", NULL); + if (TimeGetDiff(rtkTime, &shiftTime) >= examParam.shift_hold_time) { + PlayTTS(examParam.shift_end_tts, NULL); DEBUG("鍔犲噺鎸′綅鎿嶄綔缁撴潫"); return false; } diff --git a/lib/src/main/cpp/test_items2/overtake.cpp b/lib/src/main/cpp/test_items2/overtake.cpp index c3e53ad..7f9d29b 100644 --- a/lib/src/main/cpp/test_items2/overtake.cpp +++ b/lib/src/main/cpp/test_items2/overtake.cpp @@ -25,7 +25,7 @@ { DEBUG("瓒呰秺鍓嶆柟杞﹁締"); - PlayTTS("璇疯秴瓒婂墠鏂硅溅杈�", TtsBack); + PlayTTS(examParam.overtake_begin_tts, TtsBack); setup = 0; originalLane = ori_lane; @@ -51,7 +51,7 @@ if (originalLane == currLane) { } else if (currLane == originalLane + 1) { - PlayTTS("瀹屾垚瓒呰溅", NULL); + PlayTTS(examParam.overtake_end_tts, NULL); return false; } else { DEBUG("瓒呰溅杩濊鍙橀亾"); @@ -60,7 +60,7 @@ } } - if (ReadOdo() - maxMoveDistance > 150) { + if (ReadOdo() - maxMoveDistance > examParam.overtake_limit_distance) { // 瓒呰溅鏈畬鎴� DEBUG("瓒呰溅鍥哄畾璺濈鍐呮湭瀹屾垚 褰撳墠閲岀▼ %f", ReadOdo()); AddExamFault(3, rtkTime); diff --git a/lib/src/main/cpp/test_items2/road_exam.cpp b/lib/src/main/cpp/test_items2/road_exam.cpp index 0a3f627..f3164f5 100644 --- a/lib/src/main/cpp/test_items2/road_exam.cpp +++ b/lib/src/main/cpp/test_items2/road_exam.cpp @@ -69,11 +69,6 @@ static const int CROSSING_TURN_THRESHOLD = 35; static const int TURN_THRESHOLD = 3; -const double SLIDE_DISTANCE_THRESHOLD_RED = 0.3; -const double SLIDE_DISTANCE_THRESHOLD_YELLOW = 0.1; - -const double EXAM_RANGE = 2700.0; // 鑷冲皯椹鹃┒璺濈 - static bool occurOverSpeed; static bool occurSecondBreak; @@ -137,18 +132,6 @@ static int startTurnYaw, prevYaw; static int turnCnt, turnTimeCnt; static int prevTurnWise; - -static const uint32_t GEAR_N_SLIDE_TIMEOUT = D_SEC(10); -static const uint32_t GEAR_ERROR_TIMEOUT = D_SEC(15); -static const uint32_t STOP_CAR_TIME = D_SEC(2); -static const uint32_t CHANGE_LANE_MIN_INTERVAL = D_SEC(10); -static const uint32_t CRASH_DOTTED_LINE_TIMEOUT = D_SEC(10); -static const uint32_t TURN_SIGNAL_LAMP_ADVANCE = D_SEC(3); - - -static const double MAX_SPEED = 60.0 * 1000.0 / 3600.0; // 瓒呴�熺‘璁� -static const double DEC_MAX_SPEED = 55.0 * 1000.0 / 3600.0; // 瓒呴�熷彇娑� -static const int SPEED_GEAR_TABLE[][2] = {{0, 20}, {5, 30}, {15, 40}, {25, 10000}, {35, 10000}}; static void ItemExam(road_exam_map &RoadMap, int roadIndex, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime, double straight, double road_end); static void ItemExam2(road_exam_map &RoadMap, int roadIndex, const car_model *car, LIST_CAR_MODEL &CarModelList); @@ -901,7 +884,7 @@ checkCrashGreenTimeout = 1; crashGreenRunTime = *rtkTime; // 杩愬姩涓帇铏氱嚎鐨勫紑濮嬫椂闂寸偣 } else if (checkCrashGreenTimeout == 1) { - if (TimeGetDiff(rtkTime, &crashGreenRunTime) >= CRASH_DOTTED_LINE_TIMEOUT) { + if (TimeGetDiff(rtkTime, &crashGreenRunTime) >= examParam.crash_dotted_line_cumulative_time) { DEBUG("闀挎椂闂村帇铏氱嚎"); checkCrashGreenTimeout = 2; // 闀挎椂闂撮獞杞ц溅閬撳垎鐣岀嚎琛岄┒锛屼笉鍚堟牸 @@ -946,7 +929,7 @@ // 娌℃墦鐏紝涓嶅悎鏍� AddExamFault(13, rtkTime); } else if (TimeGetDiff(&crashGreenStartTime, &turnSignalStatus.time) < - TURN_SIGNAL_LAMP_ADVANCE) { + examParam.turn_signal_min_advance) { DEBUG("杞悜鐏椂闂翠笉瓒� %02d-%02d-%02d %02d:%02d:%02d.%03d -> %02d-%02d-%02d %02d:%02d:%02d.%03d", crashGreenStartTime.YY, crashGreenStartTime.MM, crashGreenStartTime.DD, crashGreenStartTime.hh, crashGreenStartTime.mm, crashGreenStartTime.ss, @@ -963,7 +946,7 @@ // 娌℃墦鐏紝涓嶅悎鏍� AddExamFault(13, rtkTime); } else if (TimeGetDiff(&crashGreenStartTime, &turnSignalStatus.time) < - TURN_SIGNAL_LAMP_ADVANCE) { + examParam.turn_signal_min_advance) { DEBUG("杞悜鐏椂闂翠笉瓒� %02d-%02d-%02d %02d:%02d:%02d.%03d -> %02d-%02d-%02d %02d:%02d:%02d.%03d", crashGreenStartTime.YY, crashGreenStartTime.MM, crashGreenStartTime.DD, crashGreenStartTime.hh, crashGreenStartTime.mm, crashGreenStartTime.ss, @@ -975,7 +958,7 @@ } } - if (((ChangeLane.gain < 0 && gain < 0) || (ChangeLane.gain > 0 && gain > 0)) && TimeGetDiff(rtkTime, &ChangeLane.time) < CHANGE_LANE_MIN_INTERVAL) { + if (((ChangeLane.gain < 0 && gain < 0) || (ChangeLane.gain > 0 && gain > 0)) && TimeGetDiff(rtkTime, &ChangeLane.time) < examParam.continuous_change_lane_min_time) { DEBUG("杩炵画鍙橀亾"); AddExamFault(15, rtkTime); } @@ -1196,23 +1179,23 @@ switch (act) { case ROAD_ACTIVE_FORWARD: DEBUG("璺彛鎻愮ず 鐩磋"); - PlayTTS("鍓嶆柟璺彛璇风洿琛�", NULL); + PlayTTS(examParam.crossing_go_straight_tts, NULL); break; case ROAD_ACTIVE_TURN_LEFT: DEBUG("璺彛鎻愮ず 宸﹁浆"); - PlayTTS("鍓嶆柟璺彛璇峰乏杞�", NULL); + PlayTTS(examParam.crossing_turn_left_tts, NULL); break; case ROAD_ACTIVE_TURN_RIGHT: DEBUG("璺彛鎻愮ず 鍙宠浆"); - PlayTTS("鍓嶆柟璺彛璇峰彸杞�", NULL); + PlayTTS(examParam.crossing_turn_right_tts, NULL); break; case ROAD_ACTIVE_TURN_BACKWARD: DEBUG("璺彛鎻愮ず 鎺夊ご"); - PlayTTS("鍓嶆柟璺彛璇锋帀澶�", NULL); + PlayTTS(examParam.crossing_turn_back_tts, NULL); break; default: DEBUG("璺彛鎻愮ず 鏈厤缃�"); - PlayTTS("鍓嶆柟璺彛鍚暀缁冩寚浠�", NULL); + PlayTTS(examParam.crossing_turn_unknown_tts, NULL); break; } } @@ -1308,14 +1291,14 @@ RingBreak(); // 瓒呴�熸娴� - if (speed > MAX_SPEED) { + if (ConvertMs2KMh(speed) > examParam.road_max_speed) { if (!occurOverSpeed) { occurOverSpeed = true; // 瓒呴�燂紝涓嶅悎鏍� DEBUG("瓒呴�� %f", ConvertMs2KMh(speed)); AddExamFault(10, rtkTime); } - } else if (speed < DEC_MAX_SPEED) { + } else if (ConvertMs2KMh(speed) < examParam.road_max_speed - 5) { occurOverSpeed = false; } @@ -1358,32 +1341,32 @@ } break; case GEAR_1: - if (ConvertMs2KMh(speed) < SPEED_GEAR_TABLE[0][0] || - ConvertMs2KMh(speed) > SPEED_GEAR_TABLE[0][1]) { + if (ConvertMs2KMh(speed) < examParam.gear_speed_table[0][0] || + ConvertMs2KMh(speed) > examParam.gear_speed_table[0][1]) { currGearError = true; } break; case GEAR_2: - if (ConvertMs2KMh(speed) < SPEED_GEAR_TABLE[1][0] || - ConvertMs2KMh(speed) > SPEED_GEAR_TABLE[1][1]) { + if (ConvertMs2KMh(speed) < examParam.gear_speed_table[1][0] || + ConvertMs2KMh(speed) > examParam.gear_speed_table[1][1]) { currGearError = true; } break; case GEAR_3: - if (ConvertMs2KMh(speed) < SPEED_GEAR_TABLE[2][0] || - ConvertMs2KMh(speed) > SPEED_GEAR_TABLE[2][1]) { + if (ConvertMs2KMh(speed) < examParam.gear_speed_table[2][0] || + ConvertMs2KMh(speed) > examParam.gear_speed_table[2][1]) { currGearError = true; } break; case GEAR_4: - if (ConvertMs2KMh(speed) < SPEED_GEAR_TABLE[3][0] || - ConvertMs2KMh(speed) > SPEED_GEAR_TABLE[3][1]) { + if (ConvertMs2KMh(speed) < examParam.gear_speed_table[3][0] || + ConvertMs2KMh(speed) > examParam.gear_speed_table[3][1]) { currGearError = true; } break; case GEAR_5: - if (ConvertMs2KMh(speed) < SPEED_GEAR_TABLE[4][0] || - ConvertMs2KMh(speed) > SPEED_GEAR_TABLE[4][1]) { + if (ConvertMs2KMh(speed) < examParam.gear_speed_table[4][0] || + ConvertMs2KMh(speed) > examParam.gear_speed_table[4][1]) { currGearError = true; } break; @@ -1398,7 +1381,7 @@ gearNSlideTimePoint = *rtkTime; } if (GearNSlideStatus == 1 && - TimeGetDiff(rtkTime, &gearNSlideTimePoint) > GEAR_N_SLIDE_TIMEOUT) { + TimeGetDiff(rtkTime, &gearNSlideTimePoint) > examParam.gear_n_allow_time) { // 绌烘。婊戣瓒�5绉掞紝涓嶅悎鏍� DEBUG("鎸′綅婊戣锛岃秴杩�5绉�"); AddExamFault(8, rtkTime); @@ -1415,7 +1398,7 @@ ReadCarStatus(GEAR), ConvertMs2KMh(speed)); gearErrorTime += TimeGetDiff(rtkTime, &gearErrorTimePoint); } - if (gearErrorTime > GEAR_ERROR_TIMEOUT) { + if (gearErrorTime > examParam.gear_speed_error_cumulative_time) { // 绱15绉掞紝鎸′綅-杞﹂�熶笉鍖归厤锛屼笉鍚堟牸 DEBUG("鎸′綅閿欒瓒呰繃15绉�"); AddExamFault(6, rtkTime); @@ -1453,7 +1436,7 @@ prevMoveDirect = moveDirect; } else if (moveDirect == 0) { // 鎸佺画鍋滆溅 - if (TimeGetDiff(rtkTime, &stopTimepoint) >= STOP_CAR_TIME && !StopCarOnRedArea && + if (TimeGetDiff(rtkTime, &stopTimepoint) >= examParam.road_pause_criteria && !StopCarOnRedArea && StopOnRedArea(RoadMap, car)) { // 鍋滆溅瓒�2绉掞紝鍋滃湪绾㈠尯锛屼笉鍚堟牸 AddExamFault(16, rtkTime); @@ -1465,11 +1448,11 @@ if (occurSlide) { double slideDistance = DistanceOf(stopPoint, car->basePoint); - if (slideDistance > SLIDE_DISTANCE_THRESHOLD_YELLOW) { + if (slideDistance > examParam.road_slide_yellow_distance) { slideNormalDistance = true; } - if (slideDistance > SLIDE_DISTANCE_THRESHOLD_RED && !slideLongDistance) { + if (slideDistance > examParam.road_slide_red_distance && !slideLongDistance) { // 鍚庢粦瓒呰繃30鍘樼背, 涓嶅悎鏍� AddExamFault(5, rtkTime); DEBUG("鍚庢粦瓒呰繃30鍘樼背"); @@ -1629,7 +1612,7 @@ } if (!not_complete) { - if (road_end > 200 && ReadOdo() > EXAM_RANGE) { + if (road_end > 200 && ReadOdo() > examParam.road_total_distance) { RoadExamStatus = ROAD_EXAM_ITEM_CAR_STOP; StartStopCarExam(); return; @@ -1818,7 +1801,7 @@ // 娌℃墦鐏紝涓嶅悎鏍� AddExamFault(13, rtkTime); } else if (TimeGetDiff(&beginTurnTime, &turnSignalStatus.time) < - TURN_SIGNAL_LAMP_ADVANCE) { + examParam.turn_signal_min_advance) { DEBUG("杞悜鐏椂闂翠笉瓒�"); // 涓嶈冻3绉掞紝涓嶅悎鏍� AddExamFault(14, rtkTime); @@ -1829,7 +1812,7 @@ // 娌℃墦鐏紝涓嶅悎鏍� AddExamFault(13, rtkTime); } else if (TimeGetDiff(&beginTurnTime, &turnSignalStatus.time) < - TURN_SIGNAL_LAMP_ADVANCE) { + examParam.turn_signal_min_advance) { DEBUG("杞悜鐏椂闂翠笉瓒�"); // 涓嶈冻3绉掞紝涓嶅悎鏍� AddExamFault(14, rtkTime); diff --git a/lib/src/main/cpp/test_items2/stop_car.cpp b/lib/src/main/cpp/test_items2/stop_car.cpp index 32c6899..8071814 100644 --- a/lib/src/main/cpp/test_items2/stop_car.cpp +++ b/lib/src/main/cpp/test_items2/stop_car.cpp @@ -17,13 +17,7 @@ static bool BreakHandbreakReleaseSametime, OpenDoor; -static const int ENGINE_MIN_ROTATE = 200; -static const double MAX_STOP_DISTANCE = 150; - -static const uint32_t STOP_CAR_TIME = D_SEC(2); -static const uint32_t OPEN_DOOR_TIMEOUT = D_SEC(15); -static const double DISTANCE_TO_ROAD_EDGE_1 = 0.5; -static const double DISTANCE_TO_ROAD_EDGE_2 = 0.3; +static const int ENGINE_MIN_ROTATE = 100; static double beginOdo; static int setup; @@ -38,7 +32,7 @@ BreakHandbreakReleaseSametime = false; setup = 0; OpenDoor = false; - PlayTTS("璇烽潬杈瑰仠杞�", TtsBack); + PlayTTS(examParam.stop_car_begin_tts, TtsBack); } bool TestStopCar(road_exam_map &RoadMap, int roadIndex, const car_model *car, int moveDirect, const struct RtkTime *rtkTime) { @@ -71,14 +65,14 @@ PointF p1 = CalcProjectionWithRoadEdge(RoadMap.roads[roadIndex].rightEdge, car->carXY[ car->right_front_tire[TIRE_OUTSIDE] ]); PointF p2 = CalcProjectionWithRoadEdge(RoadMap.roads[roadIndex].rightEdge, car->carXY[ car->right_rear_tire[TIRE_OUTSIDE] ]); - if (DistanceOf(p1, car->carXY[ car->right_front_tire[TIRE_OUTSIDE] ]) > DISTANCE_TO_ROAD_EDGE_1 || - DistanceOf(p2, car->carXY[ car->right_rear_tire[TIRE_OUTSIDE] ]) > DISTANCE_TO_ROAD_EDGE_1) { + if (DistanceOf(p1, car->carXY[ car->right_front_tire[TIRE_OUTSIDE] ]) > examParam.stop_car_edge_red_distance || + DistanceOf(p2, car->carXY[ car->right_rear_tire[TIRE_OUTSIDE] ]) > examParam.stop_car_edge_red_distance) { DEBUG("鍋滆溅瓒呭嚭璺竟0.5绫�"); // 鍋滆溅璺濈瓒呰繃50鍘樼背锛屼笉鍚堟牸 AddExamFault(36, rtkTime); return false; - } else if (DistanceOf(p1, car->carXY[ car->right_front_tire[TIRE_OUTSIDE] ]) > DISTANCE_TO_ROAD_EDGE_2 || - DistanceOf(p2, car->carXY[ car->right_rear_tire[TIRE_OUTSIDE] ]) > DISTANCE_TO_ROAD_EDGE_2) { + } else if (DistanceOf(p1, car->carXY[ car->right_front_tire[TIRE_OUTSIDE] ]) > examParam.stop_car_edge_yellow_distance || + DistanceOf(p2, car->carXY[ car->right_rear_tire[TIRE_OUTSIDE] ]) > examParam.stop_car_edge_yellow_distance) { DEBUG("鍋滆溅瓒呭嚭璺竟0.3绫�"); // 鍋滆溅璺濈瓒呰繃30鍘樼背锛屾墸10鍒� AddExamFault(37, rtkTime); @@ -115,7 +109,7 @@ OpenDoor = true; } - if (TimeGetDiff(rtkTime, &time) > OPEN_DOOR_TIMEOUT) { + if (TimeGetDiff(rtkTime, &time) > examParam.stop_car_open_door_allow_time) { // 寮�闂ㄦ椂闂磋秴杩�15绉掞紝涓嶅悎鏍� DEBUG("寮�闂ㄦ椂闂磋秴杩�15绉�"); AddExamFault(35, rtkTime); @@ -125,12 +119,12 @@ if (OpenDoor && door.value == DOOR_CLOSE) { DEBUG("瀹屾垚鍋滆溅"); - PlayTTS("闈犺竟鍋滆溅缁撴潫", NULL); + PlayTTS(examParam.stop_car_end_tts, NULL); return false; } } - if (ReadOdo() - beginOdo > MAX_STOP_DISTANCE) { + if (ReadOdo() - beginOdo > examParam.stop_car_limit_distance) { // 150绫冲唴鏈仠杞︼紝涓嶅悎鏍� DEBUG("鍋滆溅璺濈瓒呮爣锛岄潬杈瑰仠杞︾粨鏉�"); AddExamFault(33, rtkTime); diff --git a/lib/src/main/cpp/test_items2/through_something.cpp b/lib/src/main/cpp/test_items2/through_something.cpp index 1000b06..67583d7 100644 --- a/lib/src/main/cpp/test_items2/through_something.cpp +++ b/lib/src/main/cpp/test_items2/through_something.cpp @@ -27,10 +27,6 @@ #define STOP_CAR 8 #define OVER_SPEED 16 -static const double DISTANCE_STOP_CAR_TO_STOP_LINE = 3.0; -static const double PASS_SCHOOL_MAX_SPEED = 30.0; // kmh -static const double LASTEST_BREAK_POINT = 30.0; - static void SetTargetReduceRec(map<int, int> &table, int key, int status) { auto it = table.find(key); @@ -85,7 +81,7 @@ int key = roadIndex * 100 + i; int rec = GetTargetReduceRec(TargetReduceRec, key); - if (distance > 1e-3 && distance < LASTEST_BREAK_POINT) { + if (distance > 1e-3 && distance < examParam.crossing_break_valid_distance) { if (rec == NOT_ENTER) { SetTargetReduceRec(TargetReduceRec, key, ENTER_Z); } @@ -94,13 +90,13 @@ DEBUG("妫�娴嬪埌璺彛鍒硅溅鍔ㄤ綔"); SetTargetReduceRec(TargetReduceRec, key, rec | REDUCE_SPEED); } - } else if (distance > 1e-3 && distance < DISTANCE_STOP_CAR_TO_STOP_LINE) { + } else if (distance > 1e-3 && distance < examParam.crossing_stop_valid_distance) { // 璺彛鍋滆溅瑙傚療 if (moveDirect == 0 && !(rec & STOP_CAR)) { DEBUG("妫�娴嬪埌璺彛鍋滆溅鍔ㄤ綔"); SetTargetReduceRec(TargetReduceRec, key, rec | STOP_CAR); } - } else if (distance > LASTEST_BREAK_POINT + 5 && rec != NOT_ENTER) { + } else if (distance > examParam.crossing_break_valid_distance + 5 && rec != NOT_ENTER) { RemoveTargetReduceRec(TargetReduceRec, key); } } @@ -126,7 +122,7 @@ nearbyTarget.push_back(distance1); } - if (distance1 > 1e-3 && distance1 < LASTEST_BREAK_POINT) { + if (distance1 > 1e-3 && distance1 < examParam.crossing_break_valid_distance) { if (rec == NOT_ENTER) { SetTargetReduceRec(TargetReduceRec2, key, ENTER_Z); } @@ -135,7 +131,7 @@ DEBUG("妫�娴嬪埌浜鸿閬撶瓑鍒硅溅鍔ㄤ綔"); SetTargetReduceRec(TargetReduceRec2, key, rec | REDUCE_SPEED); } - } else if (distance1 > LASTEST_BREAK_POINT + 5 && rec != NOT_ENTER) { + } else if (distance1 > examParam.crossing_break_valid_distance + 5 && rec != NOT_ENTER) { RemoveTargetReduceRec(TargetReduceRec2, key); } } else if (RoadMap.specialAreas[i].type == SCHOOL_AREA) { @@ -150,7 +146,7 @@ if (rec == NOT_ENTER) { SetTargetReduceRec(TargetReduceRec2, key, ENTER_Z); } - if (ConvertMs2KMh(speed) > PASS_SCHOOL_MAX_SPEED && !(rec & OVER_SPEED)) { + if (ConvertMs2KMh(speed) > examParam.cross_school_max_speed && !(rec & OVER_SPEED)) { SetTargetReduceRec(TargetReduceRec2, key, rec | OVER_SPEED); DEBUG("閫氳繃瀛︽牎鍖哄煙瓒呴�� %f kmh", ConvertMs2KMh(speed)); -- Gitblit v1.8.0