| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | void DriverTestInit(void) |
| | | { |
| | | ExamStart = false; |
| | | SetExamParamDefault(); |
| | | |
| | | CarModel = NULL; |
| | | CarModelList.clear(); |
| | |
| | | |
| | | 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) |
| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | #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 |
| | |
| | | } |
| | | 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); |
| | |
| | | return id; |
| | | } |
| | | |
| | | int PlayTTS(std::string &tts, void (*callback)(int)) |
| | | { |
| | | return PlayTTS(tts.c_str(), callback); |
| | | } |
| | | |
| | | void PlayRing(void) |
| | | { |
| | | JNIEnv *env; |
| | |
| | | #define RTKBASESTATION_NATIVE_LIB_H |
| | | |
| | | #include <cstdint> |
| | | #include <string> |
| | | |
| | | #include "test_common/Geometry.h" |
| | | |
| | | typedef struct { |
| | |
| | | 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 |
| | |
| | | }*/ |
| | | |
| | | if (RxBufLen > 0) { |
| | | #if 0 |
| | | #if 1 |
| | | const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen); |
| | | if(ptr != RxBuf) { |
| | | memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf)); |
| | |
| | | |
| | | if (length == 4) |
| | | MA_MainProcMsgEntry(c.a, NULL); |
| | | else |
| | | MA_MainProcMsgEntry(c.a, (char *)data + 4); |
| | | else { |
| | | MA_MainProcMsgEntry(c.a, (char *) data + 4); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | #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; |
| | |
| | | } 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("中途停车"); |
| | |
| | | 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; |
| | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | |
| | | |
| | | 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("中途停车"); |
| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | 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("停车超时"); |
| | |
| | | |
| | | 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; |
| | |
| | | |
| | | 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厘米,不合格"); |
| | |
| | | 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厘米"); |
| | | } |
| | |
| | | // 发生后滑 |
| | | 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厘米"); |
| | |
| | | |
| | | 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秒"); |
| | |
| | | |
| | | using namespace std; |
| | | |
| | | const uint32_t STOP_CAR_TIME = D_SEC(2); |
| | | |
| | | static bool testing; |
| | | static int mapIndex; |
| | | |
| | |
| | | } 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("中途停车"); |
| | |
| | | |
| | | #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; |
| | | |
| | |
| | | checkStartCarSignal = false; |
| | | checkDoor = false; |
| | | handBreakActive = false; |
| | | PlayTTS("请起步", cb); |
| | | PlayTTS(examParam.start_car_begin_tts, cb); |
| | | |
| | | DEBUG("车辆起步"); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | 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; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if (ReadCarStatus(ENGINE_RPM) > MAX_ENGINE_RPM && !checkEngineRPM) { |
| | | if (ReadCarStatus(ENGINE_RPM) > examParam.start_car_max_rpm && !checkEngineRPM) { |
| | | // 转速超标,不合格 |
| | | DEBUG("转速超标"); |
| | | AddExamFault(29, rtkTime); |
| | |
| | | |
| | | start = false; |
| | | originalLane = ori_lane; |
| | | PlayTTS("前方请变更车道", TtsBack); |
| | | PlayTTS(examParam.change_lane_begin_tts, TtsBack); |
| | | } |
| | | |
| | | bool TestChangeLane(int currLane, const struct RtkTime *rtkTime) |
| | |
| | | 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); |
| | |
| | | |
| | | #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; |
| | |
| | | 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) { |
| | |
| | | } 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); |
| | |
| | | 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); |
| | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | |
| | | setup = 0; |
| | | |
| | | PlayTTS("请进行加减挡位操作", TtsBack); |
| | | PlayTTS(examParam.shift_begin_tts, TtsBack); |
| | | } |
| | | |
| | | bool TestOperateGear(const struct RtkTime *rtkTime) |
| | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | |
| | | { |
| | | DEBUG("超越前方车辆"); |
| | | |
| | | PlayTTS("请超越前方车辆", TtsBack); |
| | | PlayTTS(examParam.overtake_begin_tts, TtsBack); |
| | | |
| | | setup = 0; |
| | | originalLane = ori_lane; |
| | |
| | | if (originalLane == currLane) { |
| | | |
| | | } else if (currLane == originalLane + 1) { |
| | | PlayTTS("完成超车", NULL); |
| | | PlayTTS(examParam.overtake_end_tts, NULL); |
| | | return false; |
| | | } else { |
| | | DEBUG("超车违规变道"); |
| | |
| | | } |
| | | } |
| | | |
| | | if (ReadOdo() - maxMoveDistance > 150) { |
| | | if (ReadOdo() - maxMoveDistance > examParam.overtake_limit_distance) { |
| | | // 超车未完成 |
| | | DEBUG("超车固定距离内未完成 当前里程 %f", ReadOdo()); |
| | | AddExamFault(3, rtkTime); |
| | |
| | | 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; |
| | | |
| | |
| | | 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); |
| | |
| | | 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; |
| | | // 长时间骑轧车道分界线行驶,不合格 |
| | |
| | | // 没打灯,不合格 |
| | | 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, |
| | |
| | | // 没打灯,不合格 |
| | | 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, |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | 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; |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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厘米"); |
| | |
| | | } |
| | | |
| | | 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; |
| | |
| | | // 没打灯,不合格 |
| | | AddExamFault(13, rtkTime); |
| | | } else if (TimeGetDiff(&beginTurnTime, &turnSignalStatus.time) < |
| | | TURN_SIGNAL_LAMP_ADVANCE) { |
| | | examParam.turn_signal_min_advance) { |
| | | DEBUG("转向灯时间不足"); |
| | | // 不足3秒,不合格 |
| | | AddExamFault(14, rtkTime); |
| | |
| | | // 没打灯,不合格 |
| | | AddExamFault(13, rtkTime); |
| | | } else if (TimeGetDiff(&beginTurnTime, &turnSignalStatus.time) < |
| | | TURN_SIGNAL_LAMP_ADVANCE) { |
| | | examParam.turn_signal_min_advance) { |
| | | DEBUG("转向灯时间不足"); |
| | | // 不足3秒,不合格 |
| | | AddExamFault(14, rtkTime); |
| | |
| | | |
| | | 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; |
| | |
| | | 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) { |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | |
| | | 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); |
| | |
| | | #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); |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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)); |