fix: 避障bug修复
This commit is contained in:
@@ -20,7 +20,7 @@ void RunBarrier()
|
||||
if (Lpt0_found) {
|
||||
Lpt0_found_count++;
|
||||
}
|
||||
if (Lpt0_found_count >= 1 && time_barrier >= 5000) {
|
||||
if (Lpt0_found_count >= 1) {
|
||||
Lpt0_found_count = 0;
|
||||
barrier_type = BARRIER_LEFT_RUNNING;
|
||||
track_type = TRACK_RIGHT;
|
||||
@@ -30,7 +30,7 @@ void RunBarrier()
|
||||
} else if (barrier_type == BARRIER_LEFT_RUNNING) {
|
||||
track_type = TRACK_RIGHT;
|
||||
time_barrier = timer_get(TIM_3);
|
||||
if (time_barrier >= 5000) {
|
||||
if (time_barrier >= 1000) {
|
||||
barrier_type = BARRIER_NONE;
|
||||
track_type = TRACK_RIGHT;
|
||||
timer_start(TIM_3);
|
||||
@@ -53,7 +53,7 @@ void RunBarrier()
|
||||
} else if (barrier_type == BARRIER_RIGHT_RUNNING) {
|
||||
track_type = TRACK_LEFT;
|
||||
time_barrier = timer_get(TIM_3);
|
||||
if (time_barrier >= 5000) {
|
||||
if (time_barrier >= 1000) {
|
||||
timer_start(TIM_3);
|
||||
timer_clear(TIM_3);
|
||||
barrier_type = BARRIER_NONE;
|
||||
|
||||
@@ -88,7 +88,7 @@ void CheckGarage()
|
||||
}
|
||||
}
|
||||
//如果色块的个数在6~9之间则认为这一行的斑马线满足要求,在去扫下一行
|
||||
if (banmaxian_geshu >= 2 ){banmaxian_hangshu++;}
|
||||
if (banmaxian_geshu >= 6 ){banmaxian_hangshu++;}
|
||||
}
|
||||
//如果有大于等于4行的有效斑马线
|
||||
if(banmaxian_hangshu>=2)
|
||||
|
||||
@@ -5,6 +5,7 @@ enum state_type_e {
|
||||
COMMON_STATE,
|
||||
TURN_STATE,
|
||||
STRAIGHT_STATE,
|
||||
|
||||
};
|
||||
|
||||
extern enum state_type_e state_type;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "gl_headfile.h"
|
||||
|
||||
#include "jj_blueteeth.h"
|
||||
float (*mid_track)[2];
|
||||
int32_t mid_track_count;
|
||||
float pure_angle;
|
||||
@@ -125,7 +125,6 @@ void MidLineTrack()
|
||||
rptsn_num = sizeof(rptsn) / sizeof(rptsn[0]);
|
||||
GetLinesResample(mid_track + begin_id, mid_track_count - begin_id, rptsn, &rptsn_num, RESAMPLEDIST * PIXPERMETER);
|
||||
|
||||
|
||||
// 远预锚点位置-
|
||||
int aim_idx = clip(round(aim_distance / RESAMPLEDIST), 0, rptsn_num - 1);
|
||||
|
||||
@@ -143,30 +142,26 @@ void MidLineTrack()
|
||||
float s1 = dy1 / dn1;
|
||||
float c2 = dx2 / dn2;
|
||||
float s2 = dy2 / dn2;
|
||||
float angle_1= atan2f(c1 * s2 - c2 * s1, c2 * c1 + s2 * s1);
|
||||
float angle_1 = atan2f(c1 * s2 - c2 * s1, c2 * c1 + s2 * s1);
|
||||
ips114_show_float(120, 80, angle_1, 3, 4);
|
||||
if (-0.3 <= angle_1 <= 0.3 )
|
||||
{
|
||||
if (angle_1 >= 0.3f || angle_1 <= -0.3f) {
|
||||
state_type = TURN_STATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
state_type = STRAIGHT_STATE;
|
||||
}
|
||||
if (circle_type == CIRCLE_LEFT_IN || circle_type == CIRCLE_LEFT_OUT || circle_type == CIRCLE_RIGHT_IN || circle_type == CIRCLE_RIGHT_OUT)
|
||||
{
|
||||
state_type = TURN_STATE;
|
||||
}
|
||||
|
||||
// if (circle_type == CIRCLE_LEFT_IN || circle_type == CIRCLE_LEFT_OUT || circle_type == CIRCLE_RIGHT_IN || circle_type == CIRCLE_RIGHT_OUT || circle_type == CIRCLE_LEFT_RUNNING || circle_type == CIRCLE_RIGHT_RUNNING)
|
||||
//{
|
||||
// state_type = TURN_STATE;
|
||||
//}
|
||||
|
||||
// 计算远锚点偏差值
|
||||
float dx = rptsn[aim_idx][1] - cx;
|
||||
float dy = cy - rptsn[aim_idx][0] + 0.2f * PIXPERMETER;
|
||||
float dn = (float)Q_sqrt(dx * dx + dy * dy);
|
||||
// float error = -atan2f(dx, dy) * 180 / PI32;
|
||||
|
||||
bt_printf("%d", barrier_type);
|
||||
if (barrier_type == BARRIER_LEFT_BEGIN) {
|
||||
dx_near = rptsn[aim_idx_near][1] - cx +barrier_offset;
|
||||
dx_near = rptsn[aim_idx_near][1] - cx + barrier_offset;
|
||||
pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * dx / dn / dn) / PI32 * 180.0f;
|
||||
} else if (barrier_type == BARRIER_RIGHT_BEGIN) {
|
||||
dx_near = rptsn[aim_idx_near][1] - cx - barrier_offset;
|
||||
@@ -187,4 +182,7 @@ void MidLineTrack()
|
||||
// // //考虑远点
|
||||
// pure_angle = -atanf(PIXPERMETER * 2.0f * 0.2f * dx / dn / dn) / PI32 * 180.0f;
|
||||
}
|
||||
if (circle_type == CIRCLE_LEFT_IN || circle_type == CIRCLE_LEFT_OUT || circle_type == CIRCLE_RIGHT_IN || circle_type == CIRCLE_RIGHT_OUT || circle_type == CIRCLE_LEFT_RUNNING || circle_type == CIRCLE_RIGHT_RUNNING) {
|
||||
state_type = TURN_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void jj_bt_run()
|
||||
{
|
||||
}
|
||||
|
||||
void jj_bt_printf(const char *format, ...)
|
||||
void bt_printf(const char *format, ...)
|
||||
{
|
||||
char sbuf[40];
|
||||
va_list args;
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
|
||||
void jj_bt_init();
|
||||
void jj_bt_run();
|
||||
void jj_bt_printf(const char *format, ...);
|
||||
void bt_printf(const char *format, ...);
|
||||
#endif
|
||||
@@ -59,7 +59,7 @@ int main(void)
|
||||
tiny_frame_param[0].f32 = pure_angle;
|
||||
tiny_frame_param[1].f32 = dx_near;
|
||||
tiny_frame_param[2].u8[0] = (uint8_t)state_type; // 0: 无状态 1: 弯道 2: 直行
|
||||
tiny_frame_param[3].u8[1] = (uint8_t)garage_type; // 0: 无车库 1: 有车库
|
||||
tiny_frame_param[2].u8[1] = (uint8_t)garage_type; // 0: 无车库 1: 有车库
|
||||
if (mt9v03x_finish_flag) {
|
||||
// 该操作消耗大概 1970 个 tick,折合约 110us
|
||||
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
|
||||
Reference in New Issue
Block a user