From 96ff5ab3c5c7d83d0444c422023f0d21521d4adc Mon Sep 17 00:00:00 2001
From: fctom1215 <fctom1215@outlook.com>
Date: 星期一, 02 三月 2020 22:56:32 +0800
Subject: [PATCH] 角度修正。
---
lib/src/main/cpp/test_items/driving_curve.cpp | 96 +++++++++++++++++++++++++++---------------------
1 files changed, 54 insertions(+), 42 deletions(-)
diff --git a/lib/src/main/cpp/test_items/driving_curve.cpp b/lib/src/main/cpp/test_items/driving_curve.cpp
index c924ced..b5294a1 100644
--- a/lib/src/main/cpp/test_items/driving_curve.cpp
+++ b/lib/src/main/cpp/test_items/driving_curve.cpp
@@ -3,12 +3,16 @@
//
#include "driving_curve.h"
+#include "../jni_log.h"
#include "../driver_test.h"
#include "../common/apptimer.h"
+#include "../utils/xconvert.h"
#include <vector>
using namespace std;
+
+#define DEBUG(fmt, args...) LOGD("<driving_curve> <%s>: " fmt, __func__, ##args)
enum {
DRIVING_ON_CURVE
@@ -16,62 +20,70 @@
const uint32_t STOP_CAR_TIME = D_SEC(2);
-static bool carStopEvent = false;
-static bool DCTesting = false;
-static int currTarget;
+static bool testing = false;
static uint32_t stopTimepoint = 0;
+
+static bool reportStopCarTimeout;
+static int prevMoveDirect;
+static bool crashRedLine;
+static struct {
+ int leftStart;
+ int leftEnd;
+ int rightStart;
+ int rightEnd;
+} calcZone;
static bool CrashRedLine(const Polygon *left, const Polygon *right, const car_model_cache_t *car);
static bool ExitTestArea(const Polygon *left, const Polygon *right, const car_model_cache_t *car);
-void StartDrivingCurve(void)
+void StartDrivingCurve(int moveDirect, const struct RtkTime *rtkTime)
{
- DCTesting = true;
- carStopEvent = false;
- currTarget = DRIVING_ON_CURVE;
+ DEBUG("杩涘叆鏇茬嚎琛岄┒鍦哄湴");
+
+ testing = true;
+
+ prevMoveDirect = moveDirect;
+ if (moveDirect == 0) {
+ stopTimepoint = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
+ }
+ reportStopCarTimeout = false;
+ crashRedLine = false;
+
+ calcZone.leftStart = calcZone.leftEnd = calcZone.rightStart = calcZone.rightEnd = -1;
}
-void StopDrivingCurve(void)
+int TestDrivingCurve(const Polygon *map, const Polygon *map2, const car_model *car, const car_model *carPrev, double speed, int moveDirect, const struct RtkTime *rtkTime)
{
- DCTesting = false;
-}
+ Line start, end;
+ Polygon zone;
-int TestDrivingCurve(vector<int>&err, const Polygon *map, const Polygon *map2, const car_model_cache_t *car, double speed, int run_status)
-{
- int status = 0;
-
- if (!DCTesting)
- return -2;
-
- if (currTarget == DRIVING_ON_CURVE) {
- if (CrashRedLine(map, map2, car)) {
- // 杞﹁疆鍘嬬嚎
- err.push_back(27);
- status = -1;
- }
-
- if (ExitTestArea(map, map2, car)) {
- // 娴嬭瘯瀹屾垚
- status = 1;
- }
-
- if (run_status != 0) {
- if (carStopEvent && AppTimer_GetTickCount() - stopTimepoint > D_SEC(2)) {
- // 涓�斿仠杞�
- err.push_back(28);
- }
- carStopEvent = false;
- } else {
- carStopEvent = true;
- stopTimepoint = AppTimer_GetTickCount();
- }
+ if (calcZone.leftStart == -1) {
+ calcZone.leftStart = 0;
+ }
+ if (calcZone.rightStart == -1) {
+ calcZone.rightStart = 0;
}
- if (status != 0) {
- StopDrivingCurve();
+ start.X1 = map->point[calcZone.leftStart].X;
+ start.Y1 = map->point[calcZone.leftStart].Y;
+
+ start.X2 = map->point[calcZone.rightStart].X;
+ start.Y2 = map->point[calcZone.rightStart].Y;
+
+ zone.num = 4;
+ zone.point = (PointF *) malloc(zone.num * sizeof(PointF));
+ zone.point[0] = car->carXY[car->left_front_tire[TIRE_OUTSIDE]];
+ zone.point[1] = car->carXY[car->right_front_tire[TIRE_OUTSIDE]];
+ zone.point[2] = car->carXY[car->right_rear_tire[TIRE_OUTSIDE]];
+ zone.point[3] = car->carXY[car->left_rear_tire[TIRE_OUTSIDE]];
+
+ if (IntersectionOf(start, &zone) == GM_None) {
+
}
- return status;
+ free(zone.point);
+
+ return testing ? 1 : 0;
}
// 杞﹁疆鏄惁鍘嬭竟绾�
--
Gitblit v1.8.0