feat: 增加避障状态计时清除

This commit is contained in:
2024-03-24 18:26:36 +08:00
parent 1c65b7752e
commit cbea30033a
5 changed files with 179 additions and 183 deletions

View File

@@ -2,9 +2,9 @@
#include "gl_headfile.h"
enum barrier_type_e barrier_type = BARRIER_NONE;
void CheckBarrier() {
uint16 time_barrier;
void CheckBarrier()
{
if (barrier_type == BARRIER_NONE && Lpt0_found_barrier_in && !Lpt1_found_barrier_in && is_straight1) {
barrier_type = BARRIER_LEFT_BEGIN;
}
@@ -13,54 +13,51 @@ void CheckBarrier() {
}
}
void RunBarrier() {
if (barrier_type == BARRIER_LEFT_BEGIN)
void RunBarrier()
{
if (barrier_type == BARRIER_LEFT_BEGIN) {
track_type = TRACK_RIGHT;
if (Lpt0_found)
{
if (Lpt0_found) {
Lpt0_found_count++;
}
if (Lpt0_found_count >= 1)
{
if (Lpt0_found_count >= 1 && time_barrier >= 5000) {
Lpt0_found_count = 0;
barrier_type = BARRIER_LEFT_RUNNING;
track_type = TRACK_RIGHT;
timer_clear(TIM_3);
timer_start(TIM_3);
}
}
else if (barrier_type == BARRIER_LEFT_RUNNING)
{
} else if (barrier_type == BARRIER_LEFT_RUNNING) {
track_type = TRACK_RIGHT;
if (Lpt0_found)
{
time_barrier = timer_get(TIM_3);
if (time_barrier >= 5000) {
barrier_type = BARRIER_NONE;
track_type = TRACK_RIGHT;
timer_start(TIM_3);
timer_clear(TIM_3);
}
}
if (barrier_type == BARRIER_RIGHT_BEGIN)
{
if (barrier_type == BARRIER_RIGHT_BEGIN) {
track_type = TRACK_LEFT;
if (Lpt1_found)
{
if (Lpt1_found) {
Lpt1_found_count++;
}
if (Lpt1_found_count >= 1)
{
if (Lpt1_found_count >= 1) {
Lpt1_found_count = 0;
barrier_type = BARRIER_RIGHT_RUNNING;
track_type = TRACK_LEFT;
timer_clear(TIM_3);
timer_start(TIM_3);
}
}
else if (barrier_type == BARRIER_RIGHT_RUNNING)
{
} else if (barrier_type == BARRIER_RIGHT_RUNNING) {
track_type = TRACK_LEFT;
if (Lpt1_found)
{
time_barrier = timer_get(TIM_3);
if (time_barrier >= 5000) {
timer_start(TIM_3);
timer_clear(TIM_3);
barrier_type = BARRIER_NONE;
track_type = TRACK_LEFT;
}
}
}

View File

@@ -10,7 +10,7 @@ enum barrier_type_e {
BARRIER_LEFT_OUT,
BARRIER_RIGHT_OUT,
};
extern uint16 time_barrier;
extern enum barrier_type_e barrier_type;
void CheckBarrier(void);

View File

@@ -3,7 +3,6 @@
enum circle_type_e circle_type = CIRCLE_NONE;
int32_t Left_Border_None_Circle = 0;
int32_t Right_Border_None_Circle = 0;
@@ -16,8 +15,8 @@ int32_t Right_Border_ToLeft_Circle = 0;
int32_t Left_Border_ToRight_Circle = 0;
int32_t Right_Border_ToRight_Circle = 0;
void CheckCircle() {
void CheckCircle()
{
// 非圆环模式下单边L角点, 单边长直道
if (circle_type == CIRCLE_NONE && Lpt0_found && !Lpt1_found && is_straight1) {
circle_type = CIRCLE_LEFT_BEGIN;
@@ -27,8 +26,8 @@ void CheckCircle() {
}
}
void RunCircle() {
void RunCircle()
{
if (circle_type == CIRCLE_LEFT_BEGIN) // 左环开始,寻外直道右线
{
track_type = TRACK_RIGHT;
@@ -93,7 +92,6 @@ void RunCircle() {
Right_Border_ToRight_Circle = 0;
}
} else if (circle_type == CIRCLE_RIGHT_BEGIN) // 右环控制,前期寻左直道
{
track_type = TRACK_LEFT;
@@ -126,8 +124,8 @@ void RunCircle() {
}
} else if (circle_type == CIRCLE_RIGHT_RUNNING) // 正常巡线,寻外圆左线
{
track_type = TRACK_LEFT;
// track_type = TRACK_RIGHT; // 看看加一个如果丢线才切换
// track_type = TRACK_RIGHT;
track_type = TRACK_LEFT; // 看看加一个如果丢线才切换
if (Lpt0_found) // 外环存在拐点,可再加拐点距离判据 (左 L 点)
{
pts_resample_left_count = mid_left_count = Lpt0_rpts0s_id;

View File

@@ -49,7 +49,7 @@ int main(void)
Page_Init();
pit_ms_init(TIM1_PIT, 10);
timer_init(TIM_3, TIMER_MS);
by_frame_init();
printf("start running\r\n");

View File

@@ -62,6 +62,7 @@ static void Loop()
ips200_show_uint(160, 205, Lpt0_found_barrier_in, 3);
ips200_show_uint(160, 224, Lpt1_found_barrier_in, 3);
ips200_show_uint(200, 165, barrier_type, 3);
ips200_show_uint(200, 185, time_barrier, 5);
}
/**