From 77966b874f5f0630645ad0695dccafa2c55b9c3e Mon Sep 17 00:00:00 2001 From: Glz <354338225@qq.com> Date: Sat, 23 Mar 2024 09:43:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=9A=9C=E7=A2=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gl_barrier.c | 15 +++++++++++++++ app/gl_barrier.h | 19 +++++++++++++++++++ app/gl_get_corners.c | 1 + app/gl_headfile.h | 1 + app/gl_tracking.c | 11 ++++++++++- 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/gl_barrier.c create mode 100644 app/gl_barrier.h diff --git a/app/gl_barrier.c b/app/gl_barrier.c new file mode 100644 index 0000000..d5b0e11 --- /dev/null +++ b/app/gl_barrier.c @@ -0,0 +1,15 @@ +#include "zf_common_headfile.h" +#include "gl_headfile.h" + +enum barrier_type_e barrier_type = BARRIER_NONE; + + +void CheckBarrier() { + if (barrier_type == BARRIER_NONE && Lpt0_found_barrier_in && !Lpt1_found_barrier_in && is_straight1) { + barrier_type = BARRIER_LEFT_BEGIN; + } + if (barrier_type == BARRIER_NONE && !Lpt0_found_barrier_in && Lpt1_found_barrier_in && is_straight0) { + barrier_type = BARRIER_RIGHT_BEGIN; + } +} + diff --git a/app/gl_barrier.h b/app/gl_barrier.h new file mode 100644 index 0000000..edd73ba --- /dev/null +++ b/app/gl_barrier.h @@ -0,0 +1,19 @@ +#ifndef BARRIER +#define BARRIER + +enum barrier_type_e { + BARRIER_NONE, + BARRIER_LEFT_BEGIN, + BARRIER_RIGHT_BEGIN, + BARRIER_LEFT_RUNNING, + BARRIER_RIGHT_RUNNING, + BARRIER_LEFT_OUT, + BARRIER_RIGHT_OUT, +}; + +extern enum barrier_type_e barrier_type; + +void CheckBarrier(void); + + +#endif /* COMMON_H_ */ \ No newline at end of file diff --git a/app/gl_get_corners.c b/app/gl_get_corners.c index b19d450..25a2441 100644 --- a/app/gl_get_corners.c +++ b/app/gl_get_corners.c @@ -32,6 +32,7 @@ void get_corners() { Lpt0_found_barrier = Lpt1_found_barrier = false; + Lpt0_found_barrier_in = Lpt1_found_barrier_in = false; for (int i = 0; i < pts_resample_left_count; i++) { if (angle_new_left_barrier[i] == 0) continue; int im1 = clip(i - (int) round(ANGLEDIST_barrier / RESAMPLEDIST), 0, pts_resample_left_count - 1); diff --git a/app/gl_headfile.h b/app/gl_headfile.h index 08c361b..289bd6f 100644 --- a/app/gl_headfile.h +++ b/app/gl_headfile.h @@ -13,5 +13,6 @@ #include "gl_cross.h" #include "gl_data.h" #include "math.h" +#include "gl_barrier.h" #endif /* STATE_H_ */ \ No newline at end of file diff --git a/app/gl_tracking.c b/app/gl_tracking.c index a911ef9..b4ff355 100644 --- a/app/gl_tracking.c +++ b/app/gl_tracking.c @@ -39,7 +39,10 @@ void ElementJudge() if (garage_type == GARAGE_NONE) { CheckCross(); if (cross_type == CROSS_NONE) { - CheckCircle(); + CheckBarrier(); + if (barrier_type == BARRIER_NONE){ + CheckCircle(); + } } } @@ -50,7 +53,13 @@ void ElementJudge() if (cross_type != CROSS_NONE) { circle_type = CIRCLE_NONE; + barrier_type = BARRIER_NONE; } + if (barrier_type != BARRIER_NONE) + { + circle_type = CIRCLE_NONE; + } + }