From 1c65b7752e8ce07c6b028e7cd1fdc44821e80790 Mon Sep 17 00:00:00 2001 From: Glz <354338225@qq.com> Date: Sun, 24 Mar 2024 16:07:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E9=9A=9C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gl_barrier.c | 45 +++++++++++++++++++++++++++++++++++++-------- app/gl_data.c | 2 ++ app/gl_data.h | 2 ++ app/gl_state.c | 2 +- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/app/gl_barrier.c b/app/gl_barrier.c index c9992bc..1a26d6b 100644 --- a/app/gl_barrier.c +++ b/app/gl_barrier.c @@ -14,24 +14,53 @@ void CheckBarrier() { } void RunBarrier() { - if (barrier_type == BARRIER_LEFT_BEGIN) // 左环开始,寻外直道右线 + if (barrier_type == BARRIER_LEFT_BEGIN) { track_type = TRACK_RIGHT; + if (Lpt0_found) + { + Lpt0_found_count++; + } + if (Lpt0_found_count >= 1) + { + Lpt0_found_count = 0; + barrier_type = BARRIER_LEFT_RUNNING; + track_type = TRACK_RIGHT; + } } - else if (barrier_type == BARRIER_LEFT_BEGIN && ((Lpt0_found_barrier && is_straight1) || Lpt0_found) ) + else if (barrier_type == BARRIER_LEFT_RUNNING) { - barrier_type = BARRIER_NONE; - track_type = TRACK_RIGHT; + track_type = TRACK_RIGHT; + if (Lpt0_found) + { + barrier_type = BARRIER_NONE; + track_type = TRACK_RIGHT; + } } + - if (barrier_type == BARRIER_RIGHT_BEGIN) // 左环开始,寻外直道右线 + if (barrier_type == BARRIER_RIGHT_BEGIN) { track_type = TRACK_LEFT; + if (Lpt1_found) + { + Lpt1_found_count++; + } + if (Lpt1_found_count >= 1) + { + Lpt1_found_count = 0; + barrier_type = BARRIER_RIGHT_RUNNING; + track_type = TRACK_LEFT; + } } - else if (barrier_type == BARRIER_RIGHT_BEGIN && ((Lpt1_found_barrier && is_straight0) || Lpt1_found) ) + else if (barrier_type == BARRIER_RIGHT_RUNNING) { - barrier_type = BARRIER_NONE; - track_type = TRACK_LEFT; + track_type = TRACK_LEFT; + if (Lpt1_found) + { + barrier_type = BARRIER_NONE; + track_type = TRACK_LEFT; + } } } diff --git a/app/gl_data.c b/app/gl_data.c index 2e9479c..76a1bc9 100644 --- a/app/gl_data.c +++ b/app/gl_data.c @@ -33,6 +33,8 @@ float pts_resample_left[PT_MAXLEN][2]; float pts_resample_right[PT_MAXLEN][2]; int32_t pts_resample_left_count; int32_t pts_resample_right_count; +int32_t Lpt0_found_count; +int32_t Lpt1_found_count; float pts_far_resample_left[PT_MAXLEN][2]; float pts_far_resample_right[PT_MAXLEN][2]; int32_t pts_far_resample_left_count; diff --git a/app/gl_data.h b/app/gl_data.h index 55c4bc8..a3aaa8d 100644 --- a/app/gl_data.h +++ b/app/gl_data.h @@ -111,6 +111,8 @@ extern bool Lpt0_found_barrier_in; extern bool Lpt1_found_barrier_in; extern int Lpt0_found_barrier_in_id; extern int Lpt1_found_barrier_in_id; +extern int32_t Lpt0_found_count; +extern int32_t Lpt1_found_count; extern bool is_turn0; extern bool is_turn1; diff --git a/app/gl_state.c b/app/gl_state.c index 6ec18f9..a489a08 100644 --- a/app/gl_state.c +++ b/app/gl_state.c @@ -5,5 +5,5 @@ enum state_type_e state_type =0; float cricle_aim=0.2f; float cross_aim=0.49f; float common_aim=0.35f; -float barrier_aim=0.1f; +float barrier_aim=0.5f; float barrier_offset=4.0f; \ No newline at end of file