日常更新
This commit is contained in:
149
app/gl_barrier.c
149
app/gl_barrier.c
@@ -25,6 +25,26 @@ void RunBarrier()
|
||||
{
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
track_type = TRACK_RIGHT;
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN)
|
||||
{
|
||||
timer_clear(TIM_2);
|
||||
timer_start(TIM_2);
|
||||
barrier_type = BARRIER_LEFT_RUNNING;
|
||||
}
|
||||
if (barrier_type == BARRIER_LEFT_RUNNING)
|
||||
{
|
||||
if (timer_get(TIM_2) >= 500)
|
||||
{
|
||||
barrier_type = BARRIER_NONE;
|
||||
timer_stop(TIM_2);
|
||||
timer_clear(TIM_2);
|
||||
}
|
||||
else{
|
||||
barrier_type = BARRIER_LEFT_RUNNING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (barrier_begin_flag == 0) {
|
||||
// timer_clear(TIM_3);
|
||||
// timer_start(TIM_3);
|
||||
@@ -46,31 +66,35 @@ void RunBarrier()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (pts_resample_left_count >= 5)
|
||||
{
|
||||
if (Lpt0_found) {
|
||||
Lpt0_found_count++;
|
||||
}
|
||||
if (Lpt0_found_count >= 1 && barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
Lpt0_found_count = 0;
|
||||
barrier_type = BARRIER_LEFT_RUNNING;
|
||||
track_type = TRACK_RIGHT;
|
||||
timer_clear(TIM_2);
|
||||
timer_start(TIM_2);
|
||||
} else if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
track_type = TRACK_RIGHT;
|
||||
if (timer_get(TIM_2) >= 500) {
|
||||
barrier_type = BARRIER_NONE;
|
||||
track_type = TRACK_RIGHT;
|
||||
timer_stop(TIM_2);
|
||||
timer_clear(TIM_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
track_type = TRACK_RIGHT;
|
||||
barrier_type = BARRIER_NONE;
|
||||
}
|
||||
// if (pts_resample_left_count >= 5) {
|
||||
// if (Lpt0_found) {
|
||||
// Lpt0_found_count++;
|
||||
// }
|
||||
// if (Lpt0_found_count >= 1 && barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
// Lpt0_found_count = 0;
|
||||
// barrier_type = BARRIER_LEFT_RUNNING;
|
||||
// track_type = TRACK_RIGHT;
|
||||
// timer_clear(TIM_2);
|
||||
// timer_start(TIM_2);
|
||||
// } else if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
// track_type = TRACK_RIGHT;
|
||||
// if (timer_get(TIM_2) >= 500) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// track_type = TRACK_RIGHT;
|
||||
// timer_stop(TIM_2);
|
||||
// timer_clear(TIM_2);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// track_type = TRACK_RIGHT;
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
|
||||
// if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
// if (pts_resample_left_count >= 5 && pts_resample_right_count >= 5) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (Lpt0_found) {
|
||||
// Lpt0_found_count++;
|
||||
@@ -94,6 +118,24 @@ void RunBarrier()
|
||||
|
||||
if (barrier_type == BARRIER_RIGHT_BEGIN || barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
track_type = TRACK_LEFT;
|
||||
if (barrier_type == BARRIER_RIGHT_BEGIN)
|
||||
{
|
||||
timer_clear(TIM_2);
|
||||
timer_start(TIM_2);
|
||||
barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
}
|
||||
if (barrier_type == BARRIER_RIGHT_RUNNING)
|
||||
{
|
||||
if (timer_get(TIM_2) >= 500)
|
||||
{
|
||||
barrier_type = BARRIER_NONE;
|
||||
timer_stop(TIM_2);
|
||||
timer_clear(TIM_2);
|
||||
}
|
||||
else{
|
||||
barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
}
|
||||
}
|
||||
// if (barrier_begin_flag == 0) {
|
||||
// timer_clear(TIM_3);
|
||||
// timer_start(TIM_3);
|
||||
@@ -115,31 +157,35 @@ void RunBarrier()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (pts_resample_right_count >= 5)
|
||||
{
|
||||
if (Lpt1_found) {
|
||||
Lpt1_found_count++;
|
||||
}
|
||||
if (Lpt1_found_count >= 1 && barrier_type == BARRIER_RIGHT_BEGIN) {
|
||||
Lpt1_found_count = 0;
|
||||
barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
track_type = TRACK_LEFT;
|
||||
timer_clear(TIM_2);
|
||||
timer_start(TIM_2);
|
||||
} else if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
track_type = TRACK_LEFT;
|
||||
if (timer_get(TIM_2) >= 500) {
|
||||
timer_stop(TIM_2);
|
||||
timer_clear(TIM_2);
|
||||
barrier_type = BARRIER_NONE;
|
||||
track_type = TRACK_LEFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
track_type = TRACK_LEFT;
|
||||
barrier_type = BARRIER_NONE;
|
||||
}
|
||||
// if (pts_resample_right_count >= 5) {
|
||||
// if (Lpt1_found) {
|
||||
// Lpt1_found_count++;
|
||||
// }
|
||||
// if (Lpt1_found_count >= 1 && barrier_type == BARRIER_RIGHT_BEGIN) {
|
||||
// Lpt1_found_count = 0;
|
||||
// barrier_type = BARRIER_RIGHT_RUNNING;
|
||||
// track_type = TRACK_LEFT;
|
||||
// timer_clear(TIM_2);
|
||||
// timer_start(TIM_2);
|
||||
// } else if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
// track_type = TRACK_LEFT;
|
||||
// if (timer_get(TIM_2) >= 500) {
|
||||
// timer_stop(TIM_2);
|
||||
// timer_clear(TIM_2);
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// track_type = TRACK_LEFT;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// track_type = TRACK_LEFT;
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
|
||||
// if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
// if (pts_resample_left_count >= 5 && pts_resample_right_count >= 5) {
|
||||
// barrier_type = BARRIER_NONE;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +226,6 @@ void RunS()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// void Check_shield(){
|
||||
// if (begin_flag == 1)
|
||||
// {
|
||||
@@ -196,6 +241,4 @@ void RunS()
|
||||
// timer_clear(TIM_3);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
@@ -15,6 +15,8 @@ int32_t Right_Border_ToLeft_Circle = 0;
|
||||
int32_t Left_Border_ToRight_Circle = 0;
|
||||
int32_t Right_Border_ToRight_Circle = 0;
|
||||
|
||||
int32_t ceshi = 0;
|
||||
|
||||
void CheckCircle()
|
||||
{
|
||||
// 非圆环模式下,单边L角点, 单边长直道
|
||||
@@ -149,13 +151,13 @@ void RunCircle()
|
||||
{
|
||||
Right_Border_None_Circle++;
|
||||
}
|
||||
if (pts_resample_right_count > 0.7 / RESAMPLEDIST &&
|
||||
Right_Border_None_Circle > FRAMENONE) {
|
||||
if (pts_resample_right_count > (0.7 / RESAMPLEDIST) && Right_Border_None_Circle > FRAMENONE) {
|
||||
circle_type = CIRCLE_NONE;
|
||||
Right_Border_None_Circle = 0;
|
||||
Right_Border_Have_Circle = 0;
|
||||
Left_Border_ToLeft_Circle = 0;
|
||||
Left_Border_ToRight_Circle = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ enum circle_type_e {
|
||||
};
|
||||
|
||||
extern enum circle_type_e circle_type;
|
||||
extern int32_t ceshi;
|
||||
|
||||
void CheckCircle(void);
|
||||
void RunCircle(void);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define SELFADAPT_OFFSET (8) // 适应性块大小
|
||||
#define PIXPERMETER (70.0f)
|
||||
#define PIXPERMETER_ACROSS (72.0f)
|
||||
#define PIXPERMETER_ACROSS_BARRIER (10.0f)
|
||||
#define RESAMPLEDIST (0.02f)
|
||||
#define ANGLEDIST (0.2f)
|
||||
#define ANGLEDIST_barrier (0.06f)
|
||||
|
||||
@@ -69,9 +69,9 @@ void cross_farline(){
|
||||
}
|
||||
}
|
||||
/*如果一行全为白色没写*/
|
||||
if (far_x1 <= 30)
|
||||
if (far_x1 <= 4)
|
||||
{
|
||||
far_x1 = 30;
|
||||
far_x1 = 4;
|
||||
}
|
||||
|
||||
for (; h1 > 0; h1--) {
|
||||
@@ -98,9 +98,9 @@ void cross_farline(){
|
||||
}
|
||||
}
|
||||
/*如果一行全为白色没写*/
|
||||
if (far_x2 >= 120)
|
||||
if (far_x2 >= 136)
|
||||
{
|
||||
far_x2 = 120;
|
||||
far_x2 = 136;
|
||||
}
|
||||
|
||||
for (; h2 > 0; h2--) {
|
||||
|
||||
@@ -47,11 +47,15 @@ int32_t pts_far_resample_right_count;
|
||||
|
||||
float mid_left[PT_MAXLEN][2];
|
||||
float mid_right[PT_MAXLEN][2];
|
||||
float mid_left_barrier[PT_MAXLEN][2];
|
||||
float mid_right_barrier[PT_MAXLEN][2];
|
||||
|
||||
float mid_s[PT_MAXLEN][2];
|
||||
|
||||
int32_t mid_left_count;
|
||||
int32_t mid_right_count;
|
||||
int32_t mid_left_barrier_count;
|
||||
int32_t mid_right_barrier_count;
|
||||
|
||||
float angle_new_left[PT_MAXLEN];
|
||||
float angle_new_right[PT_MAXLEN];
|
||||
|
||||
@@ -57,9 +57,14 @@ extern int32_t pts_far_resample_right_count;
|
||||
extern float mid_left[PT_MAXLEN][2];
|
||||
extern float mid_right[PT_MAXLEN][2];
|
||||
extern float mid_s[PT_MAXLEN][2];
|
||||
extern float mid_left_barrier[PT_MAXLEN][2];
|
||||
extern float mid_right_barrier[PT_MAXLEN][2];
|
||||
|
||||
extern int32_t mid_left_count;
|
||||
extern int32_t mid_right_count;
|
||||
extern int32_t mid_left_barrier_count;
|
||||
extern int32_t mid_right_barrier_count;
|
||||
|
||||
|
||||
extern float angle_new_left[PT_MAXLEN];
|
||||
extern float angle_new_right[PT_MAXLEN];
|
||||
|
||||
@@ -44,7 +44,7 @@ void CheckGarage()
|
||||
int banmaxian_hangshu = 0;//斑马线行数
|
||||
|
||||
//从下往上扫描
|
||||
for (int y = BEGINH_L + 2; y >= BEGINH_L - 2; y--)
|
||||
for (int y = BEGINH_L + 4; y >= BEGINH_L - 4; y--)
|
||||
{
|
||||
int banmaxian_kuandu=0;
|
||||
//int banmaxian_hangshu=0;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
enum garage_type_e {
|
||||
GARAGE_NONE, // 非车库模式
|
||||
GARAGE_FOUND,
|
||||
OUT_STOP,
|
||||
};
|
||||
extern enum garage_type_e garage_type;
|
||||
|
||||
|
||||
@@ -146,5 +146,11 @@ void img_processing() {
|
||||
GetMidLine_Right(pts_resample_right, pts_resample_right_count, mid_right, (int) round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER_ACROSS * ROADWIDTH / 2);
|
||||
mid_right_count = pts_resample_right_count;
|
||||
|
||||
// 左右中线跟踪(避障专属)
|
||||
GetMidLine_Left(pts_resample_left, pts_resample_left_count, mid_left_barrier, (int) round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER_ACROSS_BARRIER * ROADWIDTH / 2);
|
||||
mid_left_barrier_count = pts_resample_left_count;
|
||||
GetMidLine_Right(pts_resample_right, pts_resample_right_count, mid_right_barrier, (int) round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER_ACROSS_BARRIER * ROADWIDTH / 2);
|
||||
mid_right_barrier_count = pts_resample_right_count;
|
||||
|
||||
|
||||
}
|
||||
@@ -139,13 +139,16 @@ void ElementJudge()
|
||||
cross_type = CROSS_NONE;
|
||||
circle_type = CIRCLE_NONE;
|
||||
barrier_type = BARRIER_NONE;
|
||||
|
||||
}
|
||||
if (cross_type != CROSS_NONE) {
|
||||
circle_type = CIRCLE_NONE;
|
||||
barrier_type = BARRIER_NONE;
|
||||
|
||||
}
|
||||
if (barrier_type != BARRIER_NONE) {
|
||||
circle_type = CIRCLE_NONE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +186,15 @@ void MidLineTrack()
|
||||
GetMidLine_Right(pts_far_resample_right + far_Lpt1_rpts1s_id, pts_far_resample_right_count - far_Lpt1_rpts1s_id, mid_right, (int)round(ANGLEDIST / RESAMPLEDIST), PIXPERMETER * ROADWIDTH / 2);
|
||||
mid_track_count = pts_far_resample_right_count - far_Lpt1_rpts1s_id;
|
||||
}
|
||||
} else if (barrier_type == BARRIER_LEFT_RUNNING || barrier_type == BARRIER_RIGHT_RUNNING)
|
||||
{
|
||||
if (track_type == TRACK_LEFT) {
|
||||
mid_track = mid_left_barrier;
|
||||
mid_track_count = mid_left_barrier_count;
|
||||
} else {
|
||||
mid_track = mid_right_barrier;
|
||||
mid_track_count = mid_right_barrier_count;
|
||||
}
|
||||
}else {
|
||||
if (track_type == TRACK_LEFT) {
|
||||
mid_track = mid_left;
|
||||
@@ -287,17 +299,10 @@ void MidLineTrack()
|
||||
switch (barrier_type) {
|
||||
case BARRIER_LEFT_BEGIN:
|
||||
// dx_near = mid_track[aim_idx_near][1] - cx + barrier_offset;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f - 20;
|
||||
break;
|
||||
case BARRIER_LEFT_RUNNING:
|
||||
pure_angle = 15.f;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
break;
|
||||
case BARRIER_RIGHT_BEGIN:
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f + 20;
|
||||
break;
|
||||
case BARRIER_RIGHT_RUNNING:
|
||||
// dx_near = mid_track[aim_idx_near][1] - cx - barrier_offset;
|
||||
pure_angle = -15.f;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
default:
|
||||
// pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * 0.5f * dx / dn) / PI32 * 180.0f;
|
||||
if (dy > 0) {
|
||||
@@ -309,12 +314,10 @@ void MidLineTrack()
|
||||
// pure_angle_half = last_pure_angle_half;
|
||||
}
|
||||
}
|
||||
if (garage_type == GARAGE_FOUND)
|
||||
{
|
||||
if (garage_type == GARAGE_FOUND) {
|
||||
pure_angle = 0.f;
|
||||
}
|
||||
|
||||
|
||||
// if (barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
// // dx_near = mid_track[aim_idx_near][1] - cx + barrier_offset;
|
||||
// pure_angle = -25.f;
|
||||
@@ -349,7 +352,7 @@ void MidLineTrack()
|
||||
timer_clear(TIM_3);
|
||||
timer_start(TIM_3);
|
||||
}
|
||||
if (circle_type == CIRCLE_LEFT_RUNNING || circle_type == CIRCLE_RIGHT_RUNNING || circle_type == CIRCLE_RIGHT_OUT || circle_type == CIRCLE_LEFT_OUT || circle_type == CIRCLE_LEFT_END || circle_type == CIRCLE_RIGHT_END) {
|
||||
if (circle_type == CIRCLE_LEFT_RUNNING || circle_type == CIRCLE_RIGHT_RUNNING || circle_type == CIRCLE_RIGHT_OUT || circle_type == CIRCLE_LEFT_OUT) {
|
||||
if (circle_flag == 1) {
|
||||
state_type = CIRCLE_STATE;
|
||||
}
|
||||
@@ -370,6 +373,12 @@ void MidLineTrack()
|
||||
circle_flag = 1;
|
||||
}
|
||||
|
||||
if (circle_type == CIRCLE_LEFT_END || circle_type == CIRCLE_RIGHT_END)
|
||||
{
|
||||
state_type = STRAIGHT_STATE;
|
||||
}
|
||||
|
||||
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN || barrier_type == BARRIER_LEFT_RUNNING || barrier_type == BARRIER_RIGHT_BEGIN || barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
state_type = BARRIER_STATE;
|
||||
}
|
||||
@@ -399,4 +408,13 @@ void MidLineTrack()
|
||||
// timer_clear(TIM_3);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (state_type != BARRIER_STATE || garage_type != GARAGE_FOUND) {
|
||||
if ((pts_left_count <= 2) && (pts_right_count <= 2) && (GET_PIX_1C(mt9v03x_image_copy[0], BEGINH_L, IMAGE_W / 2 - BEGINW_R) <= FIX_BINTHRESHOLD) && (GET_PIX_1C(mt9v03x_image_copy[0], BEGINH_L, IMAGE_W / 2 + BEGINW_L) <= FIX_BINTHRESHOLD)) {
|
||||
garage_type = OUT_STOP;
|
||||
}
|
||||
}
|
||||
else{
|
||||
garage_type = GARAGE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ static void Loop()
|
||||
ips200_show_int(90, 18 + 38, track_type, 1);
|
||||
ips200_show_int(90, 18 + 56, garage_type, 1);
|
||||
ips200_show_int(90, 18 + 74, cross_type, 1);
|
||||
ips200_show_int(90, 18 + 92, circle_type, 1);
|
||||
ips200_show_int(90, 18 + 92, circle_type, 2);
|
||||
ips200_show_int(90, 18 + 110, s_type, 1);
|
||||
ips200_show_float(90, 18 + 128, curvature, 4, 5);
|
||||
ips200_show_int(90, 18 + 146, Lpt0_found_barrier_in, 1);
|
||||
|
||||
@@ -63,6 +63,7 @@ static void Loop()
|
||||
ips200_show_uint(160, 224, Lpt1_found_barrier_in, 3);
|
||||
ips200_show_uint(200, 165, barrier_type, 3);
|
||||
ips200_show_uint(200, 185, state_type, 5);
|
||||
//ips200_show_uint(200, 205, ceshi, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user