From efc508204e781a1ce1d3f55c2b986198c9e32509 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期二, 18 八月 2020 17:35:26 +0800
Subject: [PATCH] 坐标

---
 lib/src/main/cpp/driver_test.cpp            |   81 ++++++++++++++------------
 lib/src/main/cpp/test_items2/smart_item.h   |    8 ++
 lib/src/main/cpp/test_items2/smart_item.cpp |    8 ++
 lib/src/main/cpp/master/comm_if.cpp         |    4 +
 lib/src/main/cpp/test_items2/road_exam.cpp  |   35 +++++++++++
 lib/src/main/cpp/CMakeLists.txt             |    1 
 lib/src/main/cpp/rtk_platform/platform.cpp  |    4 
 7 files changed, 100 insertions(+), 41 deletions(-)

diff --git a/lib/src/main/cpp/CMakeLists.txt b/lib/src/main/cpp/CMakeLists.txt
index 7fb8102..57f1558 100644
--- a/lib/src/main/cpp/CMakeLists.txt
+++ b/lib/src/main/cpp/CMakeLists.txt
@@ -45,6 +45,7 @@
         test_items2/drive_straight.cpp
         test_items2/stop_car.cpp
         test_items2/operate_gear.cpp
+        test_items2/smart_item.cpp
 
         rtk_module/rtk.cpp
         rtk_module/virtual_rtk.cpp
diff --git a/lib/src/main/cpp/driver_test.cpp b/lib/src/main/cpp/driver_test.cpp
index 5c15aa1..9ffd1c0 100644
--- a/lib/src/main/cpp/driver_test.cpp
+++ b/lib/src/main/cpp/driver_test.cpp
@@ -505,47 +505,47 @@
     {
         static const char *NAME[] = {"OBD_SPEED",
                                      "ENGINE_RPM",
-                                     "GEAR",
-                                     "TURN_SIGNAL_LAMP",
-                                     "DIPPED_BEAM_LAMP",
-                                     "FOG_LAMP",
-                                     "CLEARANCE_LAMP",
-                                     "FLASH_BEAM_LAMP",
-                                     "MAIN_BEAM_LAMP",
-                                     "SEATBELT",
-                                     "ENGINE_START",
-                                     "BREAK",
-                                     "HAND_BREAK",
-                                     "SECOND_BREAK",
-                                     "DOOR",
-                                     "SURROUND_CAR_1",
-                                     "SURROUND_CAR_2",
-                                     "SURROUND_CAR_3",
-                                     "SURROUND_CAR_4",
+                                     "鎸′綅",
+                                     "杞悜鐏�",
+                                     "杩戝厜鐏�",
+                                     "闆剧伅",
+                                     "绀哄粨鐏�",
+                                     "杩滆繎鍏�",
+                                     "杩滃厜鐏�",
+                                     "瀹夊叏甯�",
+                                     "鍚姩寮曟搸",
+                                     "鍒硅溅",
+                                     "鎵嬪埞",
+                                     "鍓埞杞�",
+                                     "杞﹂棬",
+                                     "缁曡溅涓�",
+                                     "缁曡溅浜�",
+                                     "缁曡溅涓�",
+                                     "缁曡溅鍥�",
                                      "CAR_STATUS_END"};
 
         static const char *VALUE[] = {
-                "INACTIVE",
-                "HAZARD_LIGHTS",
-                "LEFT_TURN_LIGHT",
-                "RIGHT_TURN_LIGHT",
-                "CLEARANCE_LIGHT",
-                "DIPPED_BEAM_LIGHT",
-                "MAIN_BEAM_LIGHT",
-                "FLASH_BEAM_LIGHT",
-                "FOG_LIGHT",
-                "INSERT_SEATBELT",
-                "ENGINE_START_ACTIVE",
-                "GEAR_N",
-                "GEAR_1",
-                "GEAR_2",
-                "GEAR_3",
-                "GEAR_4",
-                "GEAR_5",
-                "GEAR_R",
-                "BREAK_ACTIVE",
-                "DOOR_CLOSE",
-                "SURROUND_CAR_ACTIVE"
+                "鍏抽棴",
+                "鍛婅鐏�",
+                "宸﹁浆淇″彿",
+                "鍙宠浆淇″彿",
+                "绀哄粨鐏寒",
+                "杩戝厜鐏寒",
+                "杩滃厜鐏寒",
+                "杩滆繎鍒囨崲",
+                "闆剧伅浜�",
+                "鎻掑叆",
+                "鍦ㄥ惎鍔ㄤ綅",
+                "绌烘。",
+                "涓�妗�",
+                "浜屾。",
+                "涓夋。",
+                "鍥涙。",
+                "浜旀。",
+                "鍊掓尅",
+                "韪╀笅",
+                "闂ㄥ叧闂�",
+                "缁曡溅鍙戠敓"
         };
 
 
@@ -574,6 +574,11 @@
                 DEBUG("杞﹁締鐘舵�� %s = %s", NAME[i], VALUE[ cs_temp[i] ]);
 
                 cs[i] = cs_temp[i];
+
+                char buff[128];
+
+                sprintf(buff, "%s锛�%s", NAME[i], VALUE[ cs_temp[i] ]);
+                PlayTTS(buff);
             }
         }
 
diff --git a/lib/src/main/cpp/master/comm_if.cpp b/lib/src/main/cpp/master/comm_if.cpp
index 1166297..e6c8db2 100644
--- a/lib/src/main/cpp/master/comm_if.cpp
+++ b/lib/src/main/cpp/master/comm_if.cpp
@@ -291,8 +291,10 @@
     writer.Int(brief->tripTime);
     writer.Key("cell_volt");
     writer.Double(brief->cellVolt);
+    writer.Key("speed");
+    writer.Double(brief->speed);
     writer.Key("engine");
-    writer.Double(brief->engine);
+    writer.Int(brief->engine);
     writer.Key("sas");
     writer.Int(brief->sas);
     writer.Key("key");
diff --git a/lib/src/main/cpp/rtk_platform/platform.cpp b/lib/src/main/cpp/rtk_platform/platform.cpp
index 25b8f82..1862a03 100644
--- a/lib/src/main/cpp/rtk_platform/platform.cpp
+++ b/lib/src/main/cpp/rtk_platform/platform.cpp
@@ -425,8 +425,8 @@
         brief.odo = BUILD_UINT32(data[3], data[2], data[1], data[0]);
         brief.trip = BUILD_UINT32(data[7], data[6], data[5], data[4]);
         brief.tripTime = BUILD_UINT32(data[11], data[10], data[9], data[8]);
-        brief.cellVolt = (double)(BUILD_UINT16(data[13], data[12])) / 10.0;
-        brief.speed = (double)(BUILD_UINT16(data[15], data[14])) / 10.0;
+        brief.cellVolt = ((double) BUILD_UINT16(data[13], data[12])) / 10.0;
+        brief.speed = ((double) BUILD_UINT16(data[15], data[14])) / 10.0;
         brief.engine = BUILD_UINT16(data[17], data[16]);
         brief.sas = (short)BUILD_UINT16(data[19], data[18]);
         brief.key = data[x++];
diff --git a/lib/src/main/cpp/test_items2/road_exam.cpp b/lib/src/main/cpp/test_items2/road_exam.cpp
index a1e3357..8bb5cea 100644
--- a/lib/src/main/cpp/test_items2/road_exam.cpp
+++ b/lib/src/main/cpp/test_items2/road_exam.cpp
@@ -51,6 +51,7 @@
     int road;
     int sep;
     int no;
+    int total;
     int guide;
 } lane_t;
 
@@ -173,6 +174,8 @@
 static bool AllCmp(road_exam_map &map);
 
 static int CalcRoadIndex(int currRoadIndex, road_exam_map &RoadMap, const car_model *car);
+
+void AnalysisRoad(road_exam_map &RoadMap, int roadIndex, lane_t lane, const car_model *car);
 
 void InitRoadExam(road_exam_map &RoadMap)
 {
@@ -768,6 +771,7 @@
             lane.road = roadIndex;
             lane.sep = i;
             lane.no = CLP.size();
+            lane.total = CLP.size() + 1;
 
             for (int x = 0; x < CLP.size(); ++x) {
                 if (CLP[x].pos == 'L') {
@@ -779,6 +783,12 @@
             return true;
         }
     }
+
+    lane.road = roadIndex;
+    lane.sep = 0;
+    lane.no = 0;
+    lane.total = 0;
+    lane.guide = 0;
 
     return false;
 }
@@ -1380,6 +1390,8 @@
 
     oldid = Lane.guide;
     DetectLane(RoadMap, car, currExamMapIndex, rtkTime);
+
+//    DEBUG("Lane淇℃伅 road %d sep %d total %d no %d guide %d", Lane.road, Lane.sep, Lane.total, Lane.no, Lane.guide);
     if (Lane.guide > 0 && currExamMapIndex >= 0) {
         int stop_line;
 
@@ -1394,6 +1406,10 @@
 
     if (Lane.guide != oldid) {
         DEBUG("瀵煎悜绫诲瀷鍒囨崲 %d", Lane.guide);
+    }
+
+    if (currExamMapIndex >= 0) {
+        AnalysisRoad(RoadMap, currExamMapIndex, Lane, car);
     }
 
     // 妫�娴嬪帇绾跨姸鎬�
@@ -1792,3 +1808,22 @@
     }
     return true;
 }
+
+void AnalysisRoad(road_exam_map &RoadMap, int roadIndex, lane_t lane, const car_model *car)
+{
+    double distance = 0;
+
+    if (roadIndex < 0 || roadIndex >= RoadMap.roads.size())
+        return;
+
+    for (int i = 0; i < RoadMap.roads[roadIndex].rightEdge.size(); ++i) {
+        for (int j = 1; j < RoadMap.roads[roadIndex].rightEdge[i].points.size(); ++j) {
+            PointF point = RoadMap.roads[roadIndex].rightEdge[i].points[j];
+            distance = CalcDistanceReference(car->carXY[car->axial[AXIAL_FRONT]], point, RoadMap.roads[roadIndex].rightEdge);
+            if (distance > 1e-3) {
+                DEBUG("鐩撮亾鍓╀綑璺濈 %f", distance);
+                return;
+            }
+        }
+    }
+}
diff --git a/lib/src/main/cpp/test_items2/smart_item.cpp b/lib/src/main/cpp/test_items2/smart_item.cpp
new file mode 100644
index 0000000..72e98ef
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/smart_item.cpp
@@ -0,0 +1,8 @@
+//
+// Created by YY on 2020/8/18.
+//
+
+#include "smart_item.h"
+#include "../driver_test.h"
+
+
diff --git a/lib/src/main/cpp/test_items2/smart_item.h b/lib/src/main/cpp/test_items2/smart_item.h
new file mode 100644
index 0000000..9eb32a8
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/smart_item.h
@@ -0,0 +1,8 @@
+//
+// Created by YY on 2020/8/18.
+//
+
+#ifndef MYAPPLICATION2_SMART_ITEM_H
+#define MYAPPLICATION2_SMART_ITEM_H
+
+#endif //MYAPPLICATION2_SMART_ITEM_H

--
Gitblit v1.8.0