From 4bd08f0355b6b2cf3c027202d5ad301b4e182953 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期五, 31 三月 2023 17:16:22 +0800
Subject: [PATCH] 科目二修改

---
 lib/src/main/cpp/driver_test.h |  181 +++++++++++++++++++++++----------------------
 1 files changed, 93 insertions(+), 88 deletions(-)

diff --git a/lib/src/main/cpp/driver_test.h b/lib/src/main/cpp/driver_test.h
index 878dafd..f773daa 100644
--- a/lib/src/main/cpp/driver_test.h
+++ b/lib/src/main/cpp/driver_test.h
@@ -5,13 +5,12 @@
 #ifndef RTKDRIVERTEST_DRIVER_TEST_H
 #define RTKDRIVERTEST_DRIVER_TEST_H
 
-#include "test_common/Geometry.h"
-#include "rtk_module/rtk.h"
-#include "test_items2/dummy_light.h"
-
 #include <vector>
 #include <string>
 #include <list>
+#include "test_common/Geometry.h"
+#include "rtk_module/rtk.h"
+#include "map.h"
 
 #define EXAM_AREA_NONE          0
 #define EXAM_AREA_START         1
@@ -23,68 +22,78 @@
 #define AXIAL_FRONT     0
 #define AXIAL_REAR      1
 
-#define MAP_TYPE_PARK_BUTTOM        1
-#define MAP_TYPE_STOP_START         2
-#define MAP_TYPE_PART_EDGE          3
-#define MAP_TYPE_CURVE              4
-#define MAP_TYPE_TURN_90            5
-
-using namespace std;
-
-struct car_desc_ {
-    double distance;            // 璺濈涓诲ぉ绾跨殑璺濈
-    double angle;               // 浠庝腑杞寸嚎閫嗘椂閽堝舰鎴愮殑瑙掑害
-};
-
-struct RtkTime {
-    int YY;             // 2浣嶆暟
-    int MM;
-    int DD;
-    int hh;
-    int mm;
-    int ss;
-    int mss;
-};
+typedef enum {
+    MAP_TYPE_NONE,
+    MAP_TYPE_PARK_BUTTOM,
+    MAP_TYPE_UPHILL,
+    MAP_TYPE_PARK_EDGE,
+    MAP_TYPE_CURVE,
+    MAP_TYPE_TURN_90
+} map_type_t;
 
 typedef struct {
-    struct RtkTime tm;
+    double distance;            // 璺濈涓诲ぉ绾跨殑璺濈
+    double angle;               // 浠庝腑杞寸嚎閫嗘椂閽堝舰鎴愮殑瑙掑害
+} car_desc_t;
+
+typedef struct {
+//    struct RtkTime tm;
     PointF basePoint;               // 鐜板満娴嬮噺鐨勪富澶╃嚎鍧愭爣
     int axial[2];
     int left_front_tire[2];
     int right_front_tire[2];
     int left_rear_tire[2];
     int right_rear_tire[2];
-    int bodyNum;
-    int *body;
-    int pointNum;
+//    int bodyNum;
+    std::vector<int> body;
+//    int pointNum;
     double antPitch;                // 鍓嶅悗澶╃嚎鍥犲畨瑁呬綅缃箣鍥烘湁pitch瑙�
     double antHeight;               // 杞﹂《澶╃嚎楂樼▼
     double groundHeight;            // 澶у湴楂樼▼
     double yaw;
     double pitch;
-    struct car_desc_ *carDesc;      // 缁忕幇鍦烘祴閲忕偣璁$畻鍚庣殑鍊�
-    PointF *carXY;                  // 璁$畻鍚庣殑杞﹁韩鍚勭偣鍧愭爣
-} car_model;
-
-// 鎬绘暟
-// 涓酱绾垮墠鐐�,id 0锛屼腑杞寸嚎鍚庣偣id
-// 宸﹀寘鍥达紝 鍙冲寘鍥�
-// 宸﹀墠杞紝澶栧唴
-typedef struct {
-    int body_num;
-    int body[64];
-    int front_left_tire[2];
-    int front_right_tire[2];
-    int rear_left_tire[2];
-    int rear_right_tire[2];
-} carModelDesc_t;
+    std::vector<car_desc_t> carDesc;
+//    struct car_desc_ *carDesc;      // 缁忕幇鍦烘祴閲忕偣璁$畻鍚庣殑鍊�
+//    PointF *carXY;                  // 璁$畻鍚庣殑杞﹁韩鍚勭偣鍧愭爣
+} car_model_t;
 
 typedef struct {
-    uint32_t uptime;
-    int point_num;
-    PointF *points;
-    carModelDesc_t *desc;
-} car_model_cache_t;
+    int64_t utc_time = 0;
+    double yaw;
+    double pitch;
+    double roll;
+    PointF base_point;
+    std::vector<PointF> points;
+} modeling_t;
+
+typedef enum {
+    BACKWARD = -1,
+    STOP = 0,
+    FORWARD = 1
+} move_status_t;
+
+typedef struct {
+    int64_t timestamp = 0;
+    double speed = 0;
+    move_status_t move = STOP;
+} motion_t;
+
+typedef struct {
+    map_type_t type;
+    int map_idx;        // 瀵瑰簲绉戠洰鍦板浘闆嗗悎涓殑搴忓彿
+} map_t;
+
+typedef struct {
+    bool examing = false;
+    int curr_modeling_index = -1;
+    int prev_modeling_index = -1;
+    area_map_t *pMap;
+    car_model_t *pModel;
+    modeling_t *pModeling;
+    motion_t *pMotion;
+    map_t curr_exam_map;
+    map_t arriving_map;
+} prime_t;
 
 struct ExamFault {
     int sn;
@@ -236,7 +245,7 @@
     double road_slide_red_distance;
     int road_total_distance;
     int road_max_speed;                     // Km per hour
-    vector<vector<int>> gear_speed_table;
+    std::vector<std::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
@@ -248,69 +257,67 @@
     int start_car_limit_distance;
     double open_door_drive_allow_distance;
 
-    string prepare_tts;
-    string touch_leftfront_tts;
-    string touch_leftrear_tts;
-    string touch_rightfront_tts;
-    string touch_rightrear_tts;
-    string start_engine_tts;
+    std::string prepare_tts;
+    std::string touch_leftfront_tts;
+    std::string touch_leftrear_tts;
+    std::string touch_rightfront_tts;
+    std::string touch_rightrear_tts;
+    std::string start_engine_tts;
 
-    string start_car_begin_tts;
-    string start_car_end_tts;
+    std::string start_car_begin_tts;
+    std::string start_car_end_tts;
 
     int change_lane_limit_distance;
-    string change_lane_begin_tts;
-    string change_lane_end_tts;
+    std::string change_lane_begin_tts;
+    std::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;
+    std::string shift_begin_tts;
+    std::string shift_end_tts;
+    std::string shift_up_tts;
+    std::string shift_down_tts;
 
-    string straight_begin_tts;
-    string straight_end_tts;
+    std::string straight_begin_tts;
+    std::string straight_end_tts;
     int straight_limit_distance;
     double straight_max_offset;
 
     int overtake_limit_distance;
-    string overtake_begin_tts;
-    string overtake_end_tts;
+    std::string overtake_begin_tts;
+    std::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;
+    std::string stop_car_begin_tts;
+    std::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;
+    std::string crossing_go_straight_tts;
+    std::string crossing_turn_left_tts;
+    std::string crossing_turn_right_tts;
+    std::string crossing_turn_back_tts;
+    std::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;
 
 void DriverTestInit(void);
 void ReadDriverExamPrimer(void);
 
 void ClearAreaMap(void);
 void AddAreaMap(int id, int type, const double (*map)[2], int pointNum, const double (*map2)[2], int pointNum2);
-
+void AddCurveMap(curve_map_t &map);
+void AddParkButtonMap(park_button_map_t &map);
+void AddParkEdgeMap(park_edge_map_t &map);
 
 void CleanRoadMap(void);
-void SetRoadMap(road_exam_map &map, vector<scheme_t> &scheme);
-void SetRoadExamScheme(vector<scheme_t> &scheme);
+void SetRoadMap(road_exam_map &map, std::vector<scheme_t> &scheme);
+void SetRoadExamScheme(std::vector<scheme_t> &scheme);
 
 void SetCarMeasurePoint(double *basePoint, int *axial, int *left_front_tire,
                         int *right_front_tire, int *left_rear_tire, int *right_rear_tire,
@@ -318,16 +325,14 @@
 
 void StartDriverExam(int start, int type);
 
-void UpdateRTKInfo(const rtk_info *s);
-void AddExamFault(int wrong, const struct RtkTime *rtkTime);
+void UpdateRTKInfo(const rtk_info_t *s);
+void AddExamFault(int wrong);
 void RoadChange(int road, int status);
 void CrossingChange(int road, int crossing, int status);
 
 void SystemShutdown(int event, int timeout);
 
 void SetDummyLightExam(int n, struct dummy_light_exam *cfg);
-
-uint32_t TimeGetDiff(const struct RtkTime *rtkTime1, const struct RtkTime *rtkTime2);
 
 void MasterInqRoadStatus(void);
 

--
Gitblit v1.8.0