From 8a09b209f1c546a2fa15329e8f69b4a4f89557c9 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期五, 21 八月 2020 18:59:19 +0800
Subject: [PATCH] 自适应触发和个子项修改。
---
lib/src/main/cpp/test_items2/drive_straight.cpp | 173 ++---------
lib/src/main/cpp/test_items2/drive_straight.h | 7
lib/src/main/cpp/test_items2/stop_car.h | 7
lib/src/main/cpp/test_items2/overtake.h | 12
lib/src/main/cpp/test_items2/overtake.cpp | 70 +++++
lib/src/main/cpp/test_items2/road_exam.cpp | 215 +++++----------
lib/src/main/cpp/test_items2/change_lane.h | 12
lib/src/main/cpp/test_items2/stop_car.cpp | 251 +++++------------
lib/src/main/cpp/CMakeLists.txt | 2
lib/src/main/cpp/test_common/car_sensor.cpp | 4
lib/src/main/cpp/test_items2/change_lane.cpp | 50 +++
lib/src/main/cpp/test_items2/operate_gear.cpp | 11
12 files changed, 352 insertions(+), 462 deletions(-)
diff --git a/lib/src/main/cpp/CMakeLists.txt b/lib/src/main/cpp/CMakeLists.txt
index 7391283..ccc572d 100644
--- a/lib/src/main/cpp/CMakeLists.txt
+++ b/lib/src/main/cpp/CMakeLists.txt
@@ -47,6 +47,8 @@
test_items2/operate_gear.cpp
test_items2/smart_item.cpp
test_items2/car_start.cpp
+ test_items2/overtake.cpp
+ test_items2/change_lane.cpp
rtk_module/rtk.cpp
rtk_module/virtual_rtk.cpp
diff --git a/lib/src/main/cpp/test_common/car_sensor.cpp b/lib/src/main/cpp/test_common/car_sensor.cpp
index 8e35440..7eaeef8 100644
--- a/lib/src/main/cpp/test_common/car_sensor.cpp
+++ b/lib/src/main/cpp/test_common/car_sensor.cpp
@@ -377,9 +377,9 @@
}
case SENSOR_DOOR: {
if (value == 0) {
- WriteCarStatus(DOOR, DOOR_OPEN);
- } else {
WriteCarStatus(DOOR, DOOR_CLOSE);
+ } else {
+ WriteCarStatus(DOOR, DOOR_OPEN);
}
break;
}
diff --git a/lib/src/main/cpp/test_items2/change_lane.cpp b/lib/src/main/cpp/test_items2/change_lane.cpp
new file mode 100644
index 0000000..fde4995
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/change_lane.cpp
@@ -0,0 +1,50 @@
+//
+// Created by YY on 2020/8/21.
+//
+
+#include "change_lane.h"
+#include "../test_common/odo_graph.h"
+#include "../native-lib.h"
+#include "../jni_log.h"
+#include "../driver_test.h"
+
+#define DEBUG(fmt, args...) LOGD("<change_lane> <%s>: " fmt, __func__, ##args)
+
+static double maxMoveDistance;
+static int originalLane;
+static bool start;
+
+static void TtsBack(int seq)
+{
+ maxMoveDistance = ReadOdo();
+ start = true;
+}
+
+void StartChaneLaneExam(int ori_lane)
+{
+ DEBUG("鍙樻洿杞﹂亾");
+
+ start = false;
+ originalLane = ori_lane;
+ PlayTTS("鍓嶆柟璇峰彉鏇磋溅閬�", TtsBack);
+}
+
+bool TestChangeLane(int currLane, const struct RtkTime *rtkTime)
+{
+ if (!start)
+ return true;
+ if (originalLane != currLane) {
+ DEBUG("瀹屾垚鍙橀亾");
+ PlayTTS("瀹屾垚鍙橀亾", NULL);
+ return false;
+ }
+
+ if (ReadOdo() - maxMoveDistance > 100) {
+ // 瓒呰溅鏈畬鎴�
+ DEBUG("瓒呰溅鍥哄畾璺濈鍐呮湭瀹屾垚");
+ AddExamFault(3, rtkTime);
+ return false;
+ }
+
+ return true;
+}
diff --git a/lib/src/main/cpp/test_items2/change_lane.h b/lib/src/main/cpp/test_items2/change_lane.h
new file mode 100644
index 0000000..efa7d95
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/change_lane.h
@@ -0,0 +1,12 @@
+//
+// Created by YY on 2020/8/21.
+//
+
+#ifndef MYAPPLICATION2_CHANGE_LANE_H
+#define MYAPPLICATION2_CHANGE_LANE_H
+
+void StartChaneLaneExam(int ori_lane);
+
+bool TestChangeLane(int currLane, const struct RtkTime *rtkTime);
+
+#endif //MYAPPLICATION2_CHANGE_LANE_H
diff --git a/lib/src/main/cpp/test_items2/drive_straight.cpp b/lib/src/main/cpp/test_items2/drive_straight.cpp
index 3f26008..8c69204 100644
--- a/lib/src/main/cpp/test_items2/drive_straight.cpp
+++ b/lib/src/main/cpp/test_items2/drive_straight.cpp
@@ -9,6 +9,7 @@
#include "road_exam.h"
#include "../master/comm_if.h"
#include "../common/apptimer.h"
+#include "../test_common/odo_graph.h"
#include <cmath>
#define DEBUG(fmt, args...) LOGD("<drive_straight> <%s>: " fmt, __func__, ##args)
@@ -16,148 +17,56 @@
static const double CHECK_STAGE_DISTANCE = 100.0;
static const double MAX_OFFSET_DISTANCE = 0.3;
-static int ttsPlayEnd;
-static bool crossStartLine;
-static bool reportOffsetOver;
-static double edgeDistance;
-static double distanceToStartSum;
-static int examTtsSeq;
+static int setup;
+static double beginOdo;
+static int yaw_stat;
-static double CalcDistance2Edge(road_t &road, const car_model *car);
-static void PlayTTSTimeout(union sigval sig);
+static void TtsBack(int seq)
+{
+ setup = 1;
+}
-void StartDriveStraightExam(std::string tts) {
+void StartDriveStraightExam(void) {
DEBUG("寮�濮嬬洿绾胯椹�");
-
- ttsPlayEnd = 0;
- if (!tts.empty()) {
- examTtsSeq = PlayTTS(tts.c_str(), NULL);
- } else {
- examTtsSeq = PlayTTS("璇蜂繚鎸佺洿绾胯椹�", NULL);
- }
-
- distanceToStartSum = 0;
- reportOffsetOver = false;
-
- AppTimer_delete(PlayTTSTimeout);
- AppTimer_add(PlayTTSTimeout, D_SEC(5));
+ setup = 0;
+ yaw_stat = 0;
+ PlayTTS("璇蜂繚鎸佺洿绾胯椹�", TtsBack);
}
-int ExecuteDriveStraightExam(road_t &road, const car_model *car,
- const trigger_line_t *item, const struct RtkTime *rtkTime) {
- static PointF startPoint;
+bool TestDriveStraight(const car_model *car, const struct RtkTime *rtkTime) {
+ static double yaw;
+ static Line baseLine;
- double dis2roadEdge = 0;
+ if (setup == 1) {
+ // 鍋忚埅瑙掑钩鍧囧��
+ if (yaw_stat == 0) {
+ yaw = car->yaw;
+ } else {
+ yaw += car->yaw;
+ }
+ yaw_stat++;
+ if (yaw_stat == 5) {
+ yaw = fmod(yaw, 360) / 5;
- if (ttsPlayEnd == 1) {
- ttsPlayEnd = 2;
- startPoint = car->basePoint;
- edgeDistance = CalcDistance2Edge(road, car); // 鍩哄噯杈硅窛
-
- DEBUG("褰撳墠鍩哄噯璺竟闂磋窛 %f", edgeDistance);
+ PointF extPoint = PointExtend(car->basePoint, 100, yaw);
+ MakeLine(&baseLine, &car->basePoint, &extPoint);
+ beginOdo = ReadOdo();
+ setup = 2;
+ }
+ } else if (setup == 2) {
+ if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], baseLine) > MAX_OFFSET_DISTANCE) {
+ DEBUG("鐩寸嚎鍋忕Щ澶т簬30鍘樼背");
+ // 鍋忕Щ澶т簬30鍘樼背锛屼笉鍚堟牸
+ AddExamFault(30, rtkTime);
+ return false;
+ }
}
- if (ttsPlayEnd != 2)
- return 1;
-
- double distanceToStart = DistanceOf(car->basePoint, startPoint);
- dis2roadEdge = CalcDistance2Edge(road, car);
-
- DEBUG("璺竟闂磋窛 %f --- %f", dis2roadEdge, edgeDistance);
-
- if (!reportOffsetOver && fabs(dis2roadEdge - edgeDistance) > MAX_OFFSET_DISTANCE) {
- DEBUG("鐩寸嚎鍋忕Щ澶т簬30鍘樼背");
- // 鍋忕Щ澶т簬30鍘樼背锛屼笉鍚堟牸
- AddExamFault(30, rtkTime);
- reportOffsetOver = true;
-
- //////////////////////////////////////////////
-// startPoint = car->basePoint;
-// edgeDistance = dis2roadEdge;
-// reportOffsetOver = false;
- }
-
- if (distanceToStart > CHECK_STAGE_DISTANCE) {
- DEBUG("澶嶄綅杈硅窛鍋忕Щ閲�");
- startPoint = car->basePoint;
- edgeDistance = dis2roadEdge;
- reportOffsetOver = false;
- distanceToStartSum += distanceToStart;
- distanceToStart = 0;
- }
-
- if (distanceToStart + distanceToStartSum > 105) {
- DEBUG("绂诲紑鐩寸嚎琛岄┒鍖哄煙");
+ if (setup == 2 && ReadOdo() - beginOdo > CHECK_STAGE_DISTANCE) {
+ DEBUG("鐩寸嚎琛岄┒缁撴潫");
PlayTTS("鐩寸嚎琛岄┒缁撴潫", NULL);
- return -1;
- }
- return 1;
-}
-
-void DriveStraightTTSDone(int id)
-{
- // 绛夎闊虫挱鎶ュ畬姣曞悗璁℃椂
- if (id == examTtsSeq) {
- DEBUG("StopCarTTSDone %d", id);
- ttsPlayEnd = 1;
- AppTimer_delete(PlayTTSTimeout);
- }
-}
-
-void TerminateDriveStraightExam(void)
-{
- AppTimer_delete(PlayTTSTimeout);
-}
-
-static void PlayTTSTimeout(union sigval sig)
-{
- AppTimer_delete(PlayTTSTimeout);
-
- ttsPlayEnd = 1;
-}
-
-static double CalcDistance2Edge(road_t &road, const car_model *car)
-{
- PointF vp;
- bool get_vp = false;
- double distance = 0;
-
- // 妫�娴嬮亾璺竟缂樼嚎
- for (int i = 0; i < road.leftEdge.size(); ++i) {
- PointF p1, p2;
- Line edge;
-
- p1 = road.leftEdge[i].points[0];
- for (int j = 1; j < road.leftEdge[i].points.size(); ++j) {
- p2 = road.leftEdge[i].points[j];
- MakeLine(&edge, &p1, &p2);
-
- if (VerticalPointOnLine(car->basePoint, edge, vp)) {
- get_vp = true;
- goto FIND_VP_END;
- }
-
- p1 = p2;
- }
+ return false;
}
-FIND_VP_END:
- if (get_vp) {
- DEBUG("寰楀埌鍨傜偣 %d: %f, %f -- %f, %f", road.id, car->basePoint.X, car->basePoint.Y, vp.X, vp.Y);
- distance = DistanceOf(car->basePoint, vp);
- } else {
- // 娌℃湁鎵惧埌鍖归厤绾跨锛屾寜鏈�灏忚窛绂婚《鐐硅绠�
- DEBUG("鏃犲瀭鐐�");
- distance = 100;
- for (int i = 0; i < road.leftEdge.size(); ++i) {
- for (int j = 0; j < road.leftEdge[i].points.size(); ++j) {
- double x;
- if (distance > (x = DistanceOf(car->basePoint, road.leftEdge[i].points[j]))) {
- distance = x;
- }
- }
- }
- }
-
- return distance;
+ return true;
}
diff --git a/lib/src/main/cpp/test_items2/drive_straight.h b/lib/src/main/cpp/test_items2/drive_straight.h
index 1187221..cda3f2a 100644
--- a/lib/src/main/cpp/test_items2/drive_straight.h
+++ b/lib/src/main/cpp/test_items2/drive_straight.h
@@ -7,10 +7,7 @@
#include "../driver_test.h"
-void StartDriveStraightExam(std::string tts);
-int ExecuteDriveStraightExam(road_t &road, const car_model *car,
- const trigger_line_t *item, const struct RtkTime *rtkTime);
-void DriveStraightTTSDone(int id);
-void TerminateDriveStraightExam(void);
+void StartDriveStraightExam(void);
+bool TestDriveStraight(const car_model *car, const struct RtkTime *rtkTime);
#endif //MYAPPLICATION2_DRIVE_STRAIGHT_H
diff --git a/lib/src/main/cpp/test_items2/operate_gear.cpp b/lib/src/main/cpp/test_items2/operate_gear.cpp
index 564cbee..5a81d6b 100644
--- a/lib/src/main/cpp/test_items2/operate_gear.cpp
+++ b/lib/src/main/cpp/test_items2/operate_gear.cpp
@@ -19,7 +19,6 @@
static int setup;
static double maxMoveDistance;
-static double gearMoveDistance;
static void TtsBack(int seq)
{
@@ -37,6 +36,8 @@
bool TestOperateGear(const struct RtkTime *rtkTime)
{
+ static struct RtkTime shiftTime;
+
car_sensor_value_t sensor = ReadCarSensorValue(GEAR);
if (sensor.name != GEAR)
@@ -92,11 +93,11 @@
return false;
} else {
// 鍦ㄦ鎸′綅琛岄┒涓�瀹氳窛绂伙紝鍐嶆墽琛屼笅涓�涓�
- gearMoveDistance = ReadOdo();
+ shiftTime = *rtkTime;
setup = 3;
}
} else if (setup == 3) {
- if (ReadOdo() - gearMoveDistance > 10) {
+ if (TimeGetDiff(&shiftTime, rtkTime) >= D_SEC(5)) {
setup = 4;
char buff[128];
expectGear += 0 - upDownShift;
@@ -113,11 +114,11 @@
return false;
} else {
// 鍦ㄦ鎸′綅琛岄┒涓�瀹氳窛绂伙紝鍐嶆墽琛屼笅涓�涓�
- gearMoveDistance = ReadOdo();
+ shiftTime = *rtkTime;
setup = 5;
}
} else if (setup == 5) {
- if (ReadOdo() - gearMoveDistance > 10) {
+ if (TimeGetDiff(&shiftTime, rtkTime) >= D_SEC(5)) {
PlayTTS("鍔犲噺鎸′綅鎿嶄綔缁撴潫", NULL);
return false;
}
diff --git a/lib/src/main/cpp/test_items2/overtake.cpp b/lib/src/main/cpp/test_items2/overtake.cpp
new file mode 100644
index 0000000..ad97bce
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/overtake.cpp
@@ -0,0 +1,70 @@
+//
+// Created by YY on 2020/8/21.
+//
+
+#include "overtake.h"
+#include "../native-lib.h"
+#include "../jni_log.h"
+#include "../test_common/odo_graph.h"
+#include "../driver_test.h"
+
+#define DEBUG(fmt, args...) LOGD("<overtake> <%s>: " fmt, __func__, ##args)
+
+static double maxMoveDistance;
+static int setup;
+static int originalLane;
+
+static void TtsBack(int seq)
+{
+ maxMoveDistance = ReadOdo();
+ setup = 1;
+}
+
+void StartOvertakeExam(int ori_lane)
+{
+ DEBUG("瓒呰秺鍓嶆柟杞﹁締");
+
+ PlayTTS("璇疯秴瓒婂墠鏂硅溅杈�", TtsBack);
+
+ setup = 0;
+ originalLane = ori_lane;
+}
+
+bool TestOvertake(int currLane, const struct RtkTime *rtkTime)
+{
+ if (setup == 0) {
+ return true;
+ }
+ if (setup == 1) {
+ if (originalLane == currLane) {
+
+ } else if (currLane + 1 == originalLane) {
+ setup = 2;
+ originalLane = currLane;
+ } else {
+ DEBUG("鍙充晶瓒呰溅");
+ AddExamFault(3, rtkTime);
+ return false;
+ }
+ } else if (setup == 2) {
+ if (originalLane == currLane) {
+
+ } else if (currLane == originalLane + 1) {
+ PlayTTS("瀹屾垚瓒呰溅", NULL);
+ return false;
+ } else {
+ DEBUG("瓒呰溅杩濊鍙橀亾");
+ AddExamFault(3, rtkTime);
+ return false;
+ }
+ }
+
+ if (ReadOdo() - maxMoveDistance > 150) {
+ // 瓒呰溅鏈畬鎴�
+ DEBUG("瓒呰溅鍥哄畾璺濈鍐呮湭瀹屾垚");
+ AddExamFault(3, rtkTime);
+ return false;
+ }
+
+ return true;
+}
diff --git a/lib/src/main/cpp/test_items2/overtake.h b/lib/src/main/cpp/test_items2/overtake.h
new file mode 100644
index 0000000..4ac10f9
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/overtake.h
@@ -0,0 +1,12 @@
+//
+// Created by YY on 2020/8/21.
+//
+
+#ifndef MYAPPLICATION2_OVERTAKE_H
+#define MYAPPLICATION2_OVERTAKE_H
+
+void StartOvertakeExam(int ori_lane);
+
+bool TestOvertake(int currLane, const struct RtkTime *rtkTime);
+
+#endif //MYAPPLICATION2_OVERTAKE_H
diff --git a/lib/src/main/cpp/test_items2/road_exam.cpp b/lib/src/main/cpp/test_items2/road_exam.cpp
index 3f2955a..e4e8c9a 100644
--- a/lib/src/main/cpp/test_items2/road_exam.cpp
+++ b/lib/src/main/cpp/test_items2/road_exam.cpp
@@ -17,6 +17,8 @@
#include "operate_gear.h"
#include "../test_common/odo_graph.h"
#include "car_start.h"
+#include "overtake.h"
+#include "change_lane.h"
#include <cmath>
#include <vector>
@@ -30,19 +32,6 @@
using namespace std;
-#define TURN_CHECK_CNT 6
-
-enum {
- START_CAR_NOT_DO,
- START_CAR_DOING,
- START_CAR_DONE
-};
-
-enum {
- STOP_CAR_NOT_DO,
- STOP_CAR_DOING,
- STOP_CAR_DONE
-};
enum {
CROSSING_NOT_HINT,
@@ -79,25 +68,15 @@
static const int CROSSING_TURN_THRESHOLD = 45;
static const int TURN_THRESHOLD = 3;
-static const int TURN_CHECK_INTERVAL = 500;
+
const double SLIDE_DISTANCE_THRESHOLD_RED = 0.3;
const double SLIDE_DISTANCE_THRESHOLD_YELLOW = 0.1;
-const double CHANGE_LANE_RANGE = 100.0;
-const double OVERTAKE_RANGE = 150.0;
-const int OVERTAKE_HOLD_TIME = D_SEC(3); // 鍦ㄨ秴杞﹂亾琛岄┒鐨勪竴娈垫椂闂�
+
const double EXAM_RANGE = 3000.0; // 鑷冲皯椹鹃┒璺濈
-static const double NEXT_ROAD_TIP = 100.0; // 鍒拌揪璺彛鍓嶆彁绀轰笅涓�涓�庝箞璧�
-
-
-static bool occurCrashRedLine;
-static bool occurCrashGreenLine;
static bool occurOverSpeed;
static bool occurSecondBreak;
-static char carIntersectionOfGreenLine;
-static int currTurnSignalStatus;
-static int turnSignalStatusWhenCrashGreenLine;
static int prevMoveDirect;
static uint32_t stopTimepoint = 0;
@@ -114,19 +93,11 @@
static struct drive_timer gearErrorTimePoint;
static struct drive_timer gearNSlideTimePoint;
-static struct drive_timer startCarLeftTurnSignalTime;
-static struct drive_timer overTakeCmpTime;
static int gearErrorTime;
static int gearNSlideTime;
-static int stopCar;
static int currExamMapIndex;
-static trigger_line_t *currRoadItem;
-static PointF roadItemStartPoint;
-static struct drive_timer roadItemStartTime;
-static bool overtake = false;
-static bool checkTurn = false;
static lane_t Lane;
static change_lane_t ChangeLane;
@@ -170,16 +141,12 @@
static const uint32_t CRASH_DOTTED_LINE_TIMEOUT = D_SEC(10);
static const uint32_t TURN_SIGNAL_LAMP_ADVANCE = D_SEC(3);
-static const int CRL_NONE = 0;
-static const int CRL_SEP_DOTTED = 1;
-static const int CRL_SEP_SOLID = 2;
-static const int CRL_EDGE_DOTTED = 3;
-static const int CRL_EDGE_SOLID = 4;
-static const double MAX_SPEED = 60.0 * 1000.0 / 3600.0;
+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, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime, double straight, double road_end);
+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 int isTurn(int currYaw, int prevYaw, int thres);
static void ResetTurnDetect(const car_model *car);
static void DetectTurn(const car_model *car, int moveDirect, const struct RtkTime *rtkTime);
@@ -187,8 +154,6 @@
static int NearbyCrossingGuide(int &stopLineIndex, int roadIndex, road_t &road, const car_model *car);
static trigger_line_t * EntryItem(int index, road_exam_map &RoadMap, const car_model *car, LIST_CAR_MODEL &CarModelList);
-
-static bool AllCmp(road_exam_map &map);
static int CalcRoadIndex(int currRoadIndex, road_exam_map &RoadMap, const car_model *car);
@@ -198,15 +163,10 @@
{
DEBUG("Start road_exam");
- occurCrashRedLine = false;
- occurCrashGreenLine = false;
occurOverSpeed = false;
occurSecondBreak = false;
- carIntersectionOfGreenLine = 0;
-
- currTurnSignalStatus = OFF_LIGHT;
prevMoveDirect = 0;
reportStopCarOnRedArea = false;
@@ -220,14 +180,9 @@
currExamMapIndex = -1;
- stopCar = STOP_CAR_NOT_DO;
-
- currRoadItem = NULL;
-
Lane.road = Lane.sep = Lane.no = -1;
Lane.guide = 0;
- checkTurn = false;
CrashLineType = -1;
turnCnt = -1;
@@ -934,7 +889,7 @@
DEBUG("鍙樿皟鏈墦鐏�!!");
// 娌℃墦鐏紝涓嶅悎鏍�
AddExamFault(13, rtkTime);
- } else if (TimeGetDiff(&crashGreenStartTime, &lamp.time) >= D_SEC(3)) {
+ } else if (TimeGetDiff(&crashGreenStartTime, &lamp.time) >= TURN_SIGNAL_LAMP_ADVANCE) {
DEBUG("杞悜鐏椂闂翠笉瓒�");
// 涓嶈冻3绉掞紝涓嶅悎鏍�
AddExamFault(14, rtkTime);
@@ -944,7 +899,7 @@
DEBUG("鍙樿皟鏈墦鐏�!!");
// 娌℃墦鐏紝涓嶅悎鏍�
AddExamFault(13, rtkTime);
- } else if (TimeGetDiff(&crashGreenStartTime, &lamp.time) >= D_SEC(3)) {
+ } else if (TimeGetDiff(&crashGreenStartTime, &lamp.time) >= TURN_SIGNAL_LAMP_ADVANCE) {
DEBUG("杞悜鐏椂闂翠笉瓒�");
// 涓嶈冻3绉掞紝涓嶅悎鏍�
AddExamFault(14, rtkTime);
@@ -1206,9 +1161,6 @@
return guide;
}
-static uint8_t itemExec[4] = {0};
-static double odo;
-
void TestRoadGeneral(road_exam_map &RoadMap, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime)
{
double BigStraightRoadFree = 0, RoadCrossingFree = 0;
@@ -1218,14 +1170,14 @@
UpdataOdo(speed, moveDirect, rtkTime);
// 瓒呴�熸娴�
- if (moveDirect != 0 && speed > MAX_SPEED) {
+ if (speed > MAX_SPEED) {
if (!occurOverSpeed) {
occurOverSpeed = true;
// 瓒呴�燂紝涓嶅悎鏍�
- DEBUG("瓒呴�� %f", speed);
+ DEBUG("瓒呴�� %f", ConvertMs2KMh(speed));
AddExamFault(10, rtkTime);
}
- } else {
+ } else if (speed < DEC_MAX_SPEED ) {
occurOverSpeed = false;
}
@@ -1433,7 +1385,7 @@
RoadCrossingFree = freeSepDis;
- DEBUG("鐩撮亾鍓╀綑璺濈 %f, 杞﹂亾鍓╀綑璺濈 %f", BigStraightRoadFree, RoadCrossingFree);
+// DEBUG("绱琛岄┒璺濈 %f, 鐩撮亾鍓╀綑璺濈 %f, 杞﹂亾鍓╀綑璺濈 %f", ReadOdo(), BigStraightRoadFree, RoadCrossingFree);
}
// 妫�娴嬪帇绾跨姸鎬�
@@ -1441,75 +1393,14 @@
// 棰濆鐨勮浆鍚戞娴�
DetectTurn(car, moveDirect, rtkTime);
- ItemExam(RoadMap, car, CarModelList, speed, moveDirect, rtkTime, BigStraightRoadFree, RoadCrossingFree);
-
- if (ReadOdo() > EXAM_RANGE && currRoadItem == NULL && AllCmp(RoadMap) && stopCar == STOP_CAR_NOT_DO) {
- // 鍦ㄥ悎閫傛潯浠朵笅鍋滆溅缁撴潫鑰冭瘯
- StartStopCarExam("璇烽潬杈瑰仠杞�");
- stopCar = STOP_CAR_DOING;
- } else if (stopCar == STOP_CAR_DOING) {
- if (ExecuteStopCarExam(RoadMap.roads[currExamMapIndex], car, CarModelList, speed, moveDirect, rtkTime) < 0)
- stopCar = STOP_CAR_DONE;
- }
-
- // 鎵ц鏌愪釜椤圭洰
- /*if (currRoadItem != NULL) {
- if (currRoadItem->active == ROAD_ITEM_CHANGE_LANE) {
- if (DistanceOf(car->basePoint, roadItemStartPoint) > CHANGE_LANE_RANGE) {
- DEBUG("鍙橀亾璺濈瓒呮爣");
- AddExamFault(3, rtkTime);
- currRoadItem = NULL;
- }
- } else if (currRoadItem->active == ROAD_ITEM_OVERTAKE) {
- if (!overtake && DistanceOf(car->basePoint, roadItemStartPoint) > OVERTAKE_RANGE) {
- DEBUG("瓒呰溅璺濈瓒呮爣");
- AddExamFault(3, rtkTime);
- currRoadItem = NULL;
- } else if (overtake && TimeGetDiff(rtkTime->hh, rtkTime->mm, rtkTime->ss,
- rtkTime->mss * 10,
- overTakeCmpTime.hour, overTakeCmpTime.min,
- overTakeCmpTime.sec, overTakeCmpTime.msec * 10) > OVERTAKE_HOLD_TIME) {
- DEBUG("鍥炲師杞﹂亾");
- PlayTTS("璇疯繑鍥炲師杞﹂亾");
- currRoadItem = NULL;
- }
- } else if (currRoadItem->active == ROAD_ITEM_OPERATE_GEAR) {
- if (ExecuteOperateGearExam(rtkTime) < 0) {
- currRoadItem = NULL;
- }
- } else if (currRoadItem->active == ROAD_ITEM_STRAIGHT) {
- if (ExecuteDriveStraightExam(RoadMap.roads[currExamMapIndex], car, currRoadItem, rtkTime) < 0) {
- currRoadItem = NULL;
- }
- }
- } // 妫�娴嬬敱瑙﹀彂绾挎帶鍒剁殑椤圭洰
- else if (currExamMapIndex >= 0) {
- trigger_line_t *new_item = EntryItem(currExamMapIndex, RoadMap, car, CarModelList);
-
- if (new_item != NULL && !new_item->cmp) {
- currRoadItem = new_item;
- if (!currRoadItem->tts.empty())
- PlayTTS(currRoadItem->tts.c_str());
-
- // 鍒濆鏃堕棿鍜岃窛绂婚檺鍒�
- roadItemStartPoint = car->basePoint;
- Rtk2DriveTimer(roadItemStartTime, rtkTime);
-
- if (currRoadItem->active == ROAD_ITEM_OVERTAKE) {
- overtake = false;
- } else if (currRoadItem->active == ROAD_ITEM_OPERATE_GEAR) {
- StartOperateGearExam(rtkTime);
- } else if (currRoadItem->active == ROAD_ITEM_STRAIGHT) {
- StartDriveStraightExam(currRoadItem->tts);
- }
- }
- }*/
+ ItemExam(RoadMap, currExamMapIndex, car, CarModelList, speed, moveDirect, rtkTime, BigStraightRoadFree, RoadCrossingFree);
}
-static void ItemExam(road_exam_map &RoadMap, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime, double straight, double road_end)
+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 double freeRunDistance;
static double totalRunDistance;
+ static double freeRunExceptDistance = 50.0;
if (RoadExamStatus == ROAD_EXAM_READY_NEXT) {
if (RoadExamItem[ROAD_EXAM_ITEM_CAR_START] == ROAD_EXAM_ITEM_NOT_EXEC) {
@@ -1517,28 +1408,59 @@
totalRunDistance = ReadOdo();
RoadExamStatus = ROAD_EXAM_ITEM_CAR_START;
} else {
- if (RoadExamItem[ROAD_EXAM_ITEM_STRAIGHT] == ROAD_EXAM_ITEM_NOT_EXEC) {
- if (straight > 170 && road_end > 170) {
+ bool not_complete = false;
+ if (RoadExamItem[ROAD_EXAM_ITEM_STRAIGHT] == ROAD_EXAM_ITEM_NOT_EXEC) {
+ not_complete = true;
+ if (straight > 170 && road_end > 170) {
+ StartDriveStraightExam();
+ RoadExamStatus = ROAD_EXAM_ITEM_STRAIGHT;
+ return;
}
}
if (RoadExamItem[ROAD_EXAM_ITEM_OP_GEAR] == ROAD_EXAM_ITEM_NOT_EXEC) {
- if (straight > 150 && road_end > 150) {
+ not_complete = true;
+ if (road_end > 170) {
StartOperateGearExam();
RoadExamStatus = ROAD_EXAM_ITEM_OP_GEAR;
+ return;
}
}
if (RoadExamItem[ROAD_EXAM_ITEM_CHANGE_LANE] == ROAD_EXAM_ITEM_NOT_EXEC) {
-
+ not_complete = true;
+ if (road_end > 150 && Lane.total > 1) {
+ StartChaneLaneExam(Lane.no);
+ RoadExamStatus = ROAD_EXAM_ITEM_CHANGE_LANE;
+ return;
+ }
}
if (RoadExamItem[ROAD_EXAM_ITEM_OVER_TAKE] == ROAD_EXAM_ITEM_NOT_EXEC) {
-
+ not_complete = true;
+ if (road_end > 200 && Lane.total > 1) {
+ if (Lane.no == 0) {
+ // 宸插湪鏈�宸﹁溅閬擄紝鍏堝彉鏇磋溅閬擄紵
+ StartChaneLaneExam(Lane.no);
+ RoadExamStatus = ROAD_EXAM_ITEM_CHANGE_LANE;
+ } else {
+ StartOvertakeExam(Lane.no);
+ RoadExamStatus = ROAD_EXAM_ITEM_OVER_TAKE;
+ }
+ return;
+ }
}
+ if (!not_complete) {
+ if (road_end > 200 && ReadOdo() > EXAM_RANGE) {
+ RoadExamStatus = ROAD_EXAM_ITEM_CAR_STOP;
+ StartStopCarExam();
+ return;
+ }
+ }
}
} else if (RoadExamStatus == ROAD_EXAM_FREE_RUN) {
- if (ReadOdo() - freeRunDistance > 300) {
+ if (ReadOdo() - freeRunDistance > freeRunExceptDistance) {
RoadExamStatus = ROAD_EXAM_READY_NEXT;
+
}
} else {
bool testing = false;
@@ -1550,17 +1472,33 @@
case ROAD_EXAM_ITEM_OP_GEAR:
testing = TestOperateGear(rtkTime);
break;
+ case ROAD_EXAM_ITEM_CHANGE_LANE:
+ testing = TestChangeLane(Lane.no, rtkTime);
+ break;
+ case ROAD_EXAM_ITEM_OVER_TAKE:
+ testing = TestOvertake(Lane.no, rtkTime);
+ break;
+ case ROAD_EXAM_ITEM_STRAIGHT:
+ testing = TestDriveStraight(car, rtkTime);
+ break;
+ case ROAD_EXAM_ITEM_CAR_STOP:
+ testing = TestStopCar(RoadMap, roadIndex, car, moveDirect, rtkTime);
+ break;
default:break;
}
if (!testing) {
RoadExamItem[RoadExamStatus] = ROAD_EXAM_ITEM_EXECED;
+ if (RoadExamStatus == ROAD_EXAM_ITEM_CAR_START) {
+ freeRunExceptDistance = 60.0;
+ } else {
+ freeRunExceptDistance = 200.0;
+ }
RoadExamStatus = ROAD_EXAM_FREE_RUN;
freeRunDistance = ReadOdo();
}
}
-
}
void Rtk2DriveTimer(struct drive_timer &tm, const struct RtkTime *rtkTime)
@@ -1666,7 +1604,7 @@
DEBUG("鍙樿皟鏈墦鐏�!!");
// 娌℃墦鐏紝涓嶅悎鏍�
AddExamFault(13, rtkTime);
- } else if (TimeGetDiff(&beginTurnTime, &lamp.time) >= D_SEC(3)) {
+ } else if (TimeGetDiff(&beginTurnTime, &lamp.time) >= TURN_SIGNAL_LAMP_ADVANCE) {
DEBUG("杞悜鐏椂闂翠笉瓒�");
// 涓嶈冻3绉掞紝涓嶅悎鏍�
AddExamFault(14, rtkTime);
@@ -1676,7 +1614,7 @@
DEBUG("鍙樿皟鏈墦鐏�!!");
// 娌℃墦鐏紝涓嶅悎鏍�
AddExamFault(13, rtkTime);
- } else if (TimeGetDiff(&beginTurnTime, &lamp.time) >= D_SEC(3)) {
+ } else if (TimeGetDiff(&beginTurnTime, &lamp.time) >= TURN_SIGNAL_LAMP_ADVANCE) {
DEBUG("杞悜鐏椂闂翠笉瓒�");
// 涓嶈冻3绉掞紝涓嶅悎鏍�
AddExamFault(14, rtkTime);
@@ -1790,15 +1728,6 @@
}
return NULL;
-}
-
-static bool AllCmp(road_exam_map &map)
-{
- for (int i = 0; i < map.triggerLines.size(); ++i) {
- if (!map.triggerLines[i].cmp)
- return false;
- }
- return true;
}
static double AnalysisRoad(road_exam_map &RoadMap, int roadIndex, lane_t lane, const car_model *car)
diff --git a/lib/src/main/cpp/test_items2/stop_car.cpp b/lib/src/main/cpp/test_items2/stop_car.cpp
index 6526861..2ec36c9 100644
--- a/lib/src/main/cpp/test_items2/stop_car.cpp
+++ b/lib/src/main/cpp/test_items2/stop_car.cpp
@@ -11,221 +11,132 @@
#include "../common/apptimer.h"
#include "../test_common/car_sensor.h"
#include "../defs.h"
+#include "../test_common/odo_graph.h"
#define DEBUG(fmt, args...) LOGD("<stop_car> <%s>: " fmt, __func__, ##args)
-static bool inactiveBreakHandbreakTogether, notCloseEngine, inactiveHandBreakAfterOpenDoor, occurOpenDoor, doorNotClose, checkRoadDistance;
-static int examTtsSeq = 0;
-static int ttsPlayEnd;
-static double moveDistance;
-static double prevSpeed;
-static struct drive_timer prevPointTime;
-static int prevMoveDirect;
-static uint32_t stopTimepoint = 0;
-static uint32_t openDoorTimepoint;
+static bool BreakHandbreakReleaseSametime, OpenDoor;
-const int ENGINE_MIN_ROTATE = 200;
+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 void PlayTTSTimeout(union sigval sig);
+static double beginOdo;
+static int setup;
-void StartStopCarExam(std::string tts) {
+static void TtsBack(int seq)
+{
+ setup = 1;
+}
+
+void StartStopCarExam(void) {
DEBUG("闈犺竟鍋滆溅");
- ttsPlayEnd = 0;
- moveDistance = 0;
- prevMoveDirect = 0;
- inactiveBreakHandbreakTogether = false;
- notCloseEngine = false;
- inactiveHandBreakAfterOpenDoor = false;
- occurOpenDoor = false;
- doorNotClose = false;
- checkRoadDistance = false;
-
- if (!tts.empty()) {
- examTtsSeq = PlayTTS(tts.c_str(), NULL);
- } else {
- examTtsSeq = PlayTTS("璇烽潬杈瑰仠杞�", NULL);
- }
-
- AppTimer_delete(PlayTTSTimeout);
- AppTimer_add(PlayTTSTimeout, D_SEC(8));
+ BreakHandbreakReleaseSametime = false;
+ setup = 0;
+ OpenDoor = false;
+ PlayTTS("璇烽潬杈瑰仠杞�", TtsBack);
}
-void StopCarTTSDone(int id)
-{
- // 绛夎闊虫挱鎶ュ畬姣曞悗璁℃椂
- if (id == examTtsSeq) {
- DEBUG("StopCarTTSDone %d", id);
- ttsPlayEnd = 1;
- }
-}
+bool TestStopCar(road_exam_map &RoadMap, int roadIndex, const car_model *car, int moveDirect, const struct RtkTime *rtkTime) {
+ struct RtkTime time;
-void TerminateStopCarExam(void)
-{
- AppTimer_delete(PlayTTSTimeout);
-}
+ if (setup == 0)
+ return true;
-int ExecuteStopCarExam(road_t &road, const car_model *car,
- LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime) {
- if (ttsPlayEnd == 1) {
- ttsPlayEnd = 2;
- prevSpeed = speed;
- Rtk2DriveTimer(prevPointTime, rtkTime);
- }
-
- if (ttsPlayEnd != 2)
- return 1;
-
- uint32_t diff = TimeGetDiff(rtkTime->hh, rtkTime->mm, rtkTime->ss,
- rtkTime->mss * 10,
- prevPointTime.hour, prevPointTime.min,
- prevPointTime.sec, prevPointTime.msec * 10);
- if (diff >= D_SEC(1)) {
- moveDistance += (double)diff * (speed + prevSpeed) / 2.0 / 1000.0;
- prevSpeed = speed;
- Rtk2DriveTimer(prevPointTime, rtkTime);
- DEBUG("鍋滆溅宸茶椹惰窛绂� %f", moveDistance);
- }
-
- if (moveDistance > 150) {
- // 150绫冲唴鏈仠杞︼紝涓嶅悎鏍�
+ if (roadIndex < 0) {
DEBUG("鍋滆溅璺濈瓒呮爣锛岄潬杈瑰仠杞︾粨鏉�");
AddExamFault(33, rtkTime);
- return -1;
+ return false;
}
- if (moveDirect != prevMoveDirect) {
+ if (setup == 1) {
+ beginOdo = ReadOdo();
+ setup = 2;
+ } else if (setup == 2) {
if (moveDirect == 0) {
- stopTimepoint = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
- DEBUG("####### 闈犺竟鍋滆溅锛屽仠杞︿簡 %d %d %d %d %d %d %d ######", rtkTime->YY, rtkTime->MM, rtkTime->DD, rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss);
+ time = *rtkTime;
+ setup = 3;
}
- prevMoveDirect = moveDirect;
- } else if (moveDirect == 0) {
- uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
-
- if (tp - stopTimepoint >= STOP_CAR_TIME && !checkRoadDistance) {
+ } else if (setup == 3) {
+ if (moveDirect != 0) {
+ setup = 2;
+ } else if (TimeGetDiff(rtkTime, &time) >= D_SEC(2)) {
// 鍋滆溅瓒�2绉掞紝寮�濮嬪垽鏂�
DEBUG("妫�娴嬪拰璺竟鐨勮窛绂�");
- PointF pc, vp;
- bool get_vp = false;
- double dis2roadEdge = 0;
- checkRoadDistance = true;
- // 鍓嶅悗杞殑涓偣
- pc.X = (car->carXY[car->right_front_tire[TIRE_OUTSIDE]].X + car->carXY[car->right_rear_tire[TIRE_OUTSIDE]].X) / 2;
- pc.Y = (car->carXY[car->right_front_tire[TIRE_OUTSIDE]].Y + car->carXY[car->right_rear_tire[TIRE_OUTSIDE]].Y) / 2;
+ 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] ]);
- // 妫�娴嬮亾璺竟缂樼嚎
- for (int i = 0; i < road.rightEdge.size(); ++i) {
- PointF p1, p2;
- Line edge;
-
- p1 = road.rightEdge[i].points[0];
- for (int j = 1; j < road.rightEdge[i].points.size(); ++j) {
- p2 = road.rightEdge[i].points[j];
- MakeLine(&edge, &p1, &p2);
-
-
- if (VerticalPointOnLine(pc, edge, vp)) {
- get_vp = true;
- goto FIND_VP_END;
- }
-
- p1 = p2;
- }
- }
-
-FIND_VP_END:
- if (get_vp) {
- dis2roadEdge = DistanceOf(pc, vp);
- } else {
- // 娌℃湁鎵惧埌鍖归厤绾跨锛屾寜鏈�灏忚窛绂婚《鐐硅绠�
- dis2roadEdge = 100;
- for (int i = 0; i < road.rightEdge.size(); ++i) {
- for (int j = 0; j < road.rightEdge[i].points.size(); ++j) {
- double dis;
- if (dis2roadEdge > (dis = DistanceOf(pc, road.rightEdge[i].points[j]))) {
- dis2roadEdge = dis;
- }
- }
- }
- }
-
- DEBUG("鍋滆溅璺濊矾杈硅窛绂� %f", dis2roadEdge);
-
- if (dis2roadEdge > DISTANCE_TO_ROAD_EDGE_1) {
+ 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) {
DEBUG("鍋滆溅瓒呭嚭璺竟0.5绫�");
// 鍋滆溅璺濈瓒呰繃50鍘樼背锛屼笉鍚堟牸
AddExamFault(36, rtkTime);
- } else if (dis2roadEdge > DISTANCE_TO_ROAD_EDGE_2) {
+ 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) {
DEBUG("鍋滆溅瓒呭嚭璺竟0.3绫�");
// 鍋滆溅璺濈瓒呰繃30鍘樼背锛屾墸10鍒�
AddExamFault(37, rtkTime);
+ return false;
}
+
+ setup = 4;
}
- }
+ } else if (setup == 4) {
+ car_sensor_value_t brk = ReadCarSensorValue(BREAK);
+ car_sensor_value_t hbrk = ReadCarSensorValue(HAND_BREAK);
+ car_sensor_value_t door = ReadCarSensorValue(DOOR);
+ car_sensor_value_t rpm = ReadCarSensorValue(ENGINE_RPM);
- if (!inactiveBreakHandbreakTogether && ReadCarStatus(BREAK) == BREAK_INACTIVE && ReadCarStatus(HAND_BREAK) == BREAK_INACTIVE) {
- // 鎷夋墜鍒瑰墠锛屾澗鑴氬埞锛屾墸10鍒�
- DEBUG("鎷夋墜鍒瑰墠锛屾澗鑴氬埞");
- AddExamFault(39, rtkTime);
- inactiveBreakHandbreakTogether = true;
- }
+ if (!BreakHandbreakReleaseSametime && brk.value == BREAK_INACTIVE && hbrk.value == BREAK_INACTIVE) {
+ // 鎷夋墜鍒瑰墠锛屾澗鑴氬埞锛屾墸10鍒�
+ DEBUG("鎷夋墜鍒瑰墠锛屾澗鑴氬埞");
+ AddExamFault(39, rtkTime);
+ BreakHandbreakReleaseSametime = true;
+ }
- if (!notCloseEngine && ReadCarStatus(ENGINE_RPM) < ENGINE_MIN_ROTATE && ReadCarStatus(DOOR) == DOOR_OPEN) {
- // 涓嬭溅鍓嶏紝涓嶇唲鐏紝鎵�5鍒�
- DEBUG("涓嬭溅鍓嶏紝涓嶇唲鐏�");
- AddExamFault(40, rtkTime);
+ if (door.value == DOOR_OPEN) {
+ if (!OpenDoor) {
+ if (rpm.value < ENGINE_MIN_ROTATE) {
+ // 涓嬭溅鍓嶏紝涓嶇唲鐏紝鎵�5鍒�
+ DEBUG("涓嬭溅鍓嶏紝涓嶇唲鐏�");
+ AddExamFault(40, rtkTime);
+ }
+ if (hbrk.value == BREAK_INACTIVE) {
+ // 寮�闂ㄥ墠锛屾湭鎷夋墜鍒癸紝 鎵�10鍒�
+ DEBUG("寮�闂ㄥ墠锛屾湭鎷夋墜鍒�");
+ AddExamFault(38, rtkTime);
+ }
+ time = *rtkTime;
+ OpenDoor = true;
+ }
- notCloseEngine = true;
- }
-
- if (!inactiveHandBreakAfterOpenDoor && ReadCarStatus(DOOR) == DOOR_OPEN && ReadCarStatus(HAND_BREAK) == BREAK_INACTIVE) {
- // 寮�闂ㄥ墠锛屾湭鎷夋墜鍒癸紝 鎵�10鍒�
- DEBUG("寮�闂ㄥ墠锛屾湭鎷夋墜鍒�");
- AddExamFault(38, rtkTime);
-
- inactiveHandBreakAfterOpenDoor = true;
- }
-
- if (ReadCarStatus(DOOR) == DOOR_OPEN) {
- if (!occurOpenDoor) {
- occurOpenDoor = true;
- openDoorTimepoint = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
- } else {
- uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
-
- if (!doorNotClose && tp - openDoorTimepoint >= OPEN_DOOR_TIMEOUT) {
+ if (TimeGetDiff(rtkTime, &time) > OPEN_DOOR_TIMEOUT) {
// 寮�闂ㄦ椂闂磋秴杩�15绉掞紝涓嶅悎鏍�
DEBUG("寮�闂ㄦ椂闂磋秴杩�15绉�");
AddExamFault(35, rtkTime);
- doorNotClose = true;
+ return false;
}
}
- } else if (occurOpenDoor) {
- DEBUG("寮�杞﹂棬锛岄潬杈瑰仠杞︾粨鏉�");
- return -1;
- }
- if (occurOpenDoor) {
- uint32_t tp = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
-
- if (tp - openDoorTimepoint >= OPEN_DOOR_TIMEOUT + D_SEC(5)) {
- DEBUG("寮�闂ㄦ椂闂村ぇ浜�20绉掞紝闈犺竟鍋滆溅缁撴潫");
- return -1;
+ if (OpenDoor && door.value == DOOR_CLOSE) {
+ DEBUG("瀹屾垚鍋滆溅");
+ PlayTTS("闈犺竟鍋滆溅缁撴潫", NULL);
+ return false;
}
}
- return 1;
-}
+ if (ReadOdo() - beginOdo > MAX_STOP_DISTANCE) {
+ // 150绫冲唴鏈仠杞︼紝涓嶅悎鏍�
+ DEBUG("鍋滆溅璺濈瓒呮爣锛岄潬杈瑰仠杞︾粨鏉�");
+ AddExamFault(33, rtkTime);
+ return false;
+ }
-static void PlayTTSTimeout(union sigval sig)
-{
- AppTimer_delete(PlayTTSTimeout);
-
- ttsPlayEnd = 1;
+ return true;
}
diff --git a/lib/src/main/cpp/test_items2/stop_car.h b/lib/src/main/cpp/test_items2/stop_car.h
index 4519ef0..89619d7 100644
--- a/lib/src/main/cpp/test_items2/stop_car.h
+++ b/lib/src/main/cpp/test_items2/stop_car.h
@@ -7,10 +7,7 @@
#include "../driver_test.h"
-void StartStopCarExam(std::string tts);
-int ExecuteStopCarExam(road_t &road, const car_model *car,
- LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime);
-void TerminateStopCarExam(void);
-void StopCarTTSDone(int id);
+void StartStopCarExam(void);
+bool TestStopCar(road_exam_map &RoadMap, int roadIndex, const car_model *car, int moveDirect, const struct RtkTime *rtkTime);
#endif //MYAPPLICATION2_STOP_CAR_H
--
Gitblit v1.8.0