日常更新
This commit is contained in:
@@ -16,7 +16,7 @@ void by_frame_init(void)
|
||||
{
|
||||
lwrb_init(&lwrb_ctx, frame_buffer_recv, sizeof(frame_buffer_recv)); // lwrb 最大元素数量为 buff 大小减一
|
||||
uart_init(BY_FRAME_UART_INDEX, BY_FRAME_UART_BAUDRATE, BY_FRAME_UART_TX_PIN, BY_FRAME_UART_RX_PIN);
|
||||
uart_rx_interrupt(BY_FRAME_UART_INDEX, ENABLE);
|
||||
// uart_rx_interrupt(BY_FRAME_UART_INDEX, ENABLE);
|
||||
}
|
||||
|
||||
void by_frame_send(uint32_t *data_array)
|
||||
|
||||
@@ -14,7 +14,7 @@ void get_corners()
|
||||
int im1 = clip(i - (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_resample_left_count - 1);
|
||||
int ip1 = clip(i + (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_resample_left_count - 1);
|
||||
float conf = fabs(angle_left[i]) - (fabs(angle_left[im1]) + fabs(angle_left[ip1])) / 2;
|
||||
|
||||
ips114_show_float(120, 80, conf, 3, 4);
|
||||
// L 角点阈值
|
||||
if (Lpt0_found == false && (66. / 180. * PI32) < conf && conf < (140. / 180. * PI32) && i < 0.5 / RESAMPLEDIST) {
|
||||
Lpt0_rpts0s_id = i;
|
||||
@@ -22,20 +22,20 @@ void get_corners()
|
||||
// transform(pts_resample_left[Lpt0_rpts0s_id][1],pts_resample_left[Lpt0_rpts0s_id][0],&Lpt0[1],&Lpt0[0]); //待优化,是否用到,无用则删
|
||||
}
|
||||
// 长直道阈值
|
||||
if (conf > (7. / 180. * PI32) && i < 0.8 / RESAMPLEDIST) {
|
||||
if (conf > (6. / 180. * PI32) && i < 1.2 / RESAMPLEDIST) {
|
||||
is_straight0 = false;
|
||||
}
|
||||
if (Lpt0_found == true && is_straight0 == false) break;
|
||||
}
|
||||
|
||||
if (is_straight0 == false && Lpt0_found == false)
|
||||
if (Lpt0_found == false)
|
||||
{
|
||||
is_turn0 = is_curve(angle_left ,clip(angle_left_num - 10, 0,angle_left_num),0.05);
|
||||
}
|
||||
if (is_turn0)
|
||||
{
|
||||
state_type = TURN_LEFT_STATE;
|
||||
}
|
||||
//if (is_turn0)
|
||||
//{
|
||||
//state_type = TURN_LEFT_STATE;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ void get_corners()
|
||||
int im1 = clip(i - (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_resample_right_count - 1);
|
||||
int ip1 = clip(i + (int)round(ANGLEDIST / RESAMPLEDIST), 0, pts_resample_right_count - 1);
|
||||
float conf = fabs(angle_right[i]) - (fabs(angle_right[im1]) + fabs(angle_right[ip1])) / 2;
|
||||
ips114_show_float(100, 100, conf, 3, 4);
|
||||
|
||||
if (Lpt1_found == false && (66. / 180. * PI32) < conf && conf < 140. / 180. * PI32 && i < 0.5 / RESAMPLEDIST) {
|
||||
Lpt1_rpts1s_id = i;
|
||||
@@ -74,7 +75,7 @@ void get_corners()
|
||||
// transform(pts_resample_right[Lpt1_rpts1s_id][1],pts_resample_right[Lpt1_rpts1s_id][0],&Lpt1[1],&Lpt1[0]);
|
||||
}
|
||||
|
||||
if (conf > (7. / 180. * PI32) && i < 0.8 / RESAMPLEDIST) is_straight1 = false;
|
||||
if (conf > (6. / 180. * PI32) && i < 1.2 / RESAMPLEDIST) is_straight1 = false;
|
||||
if (Lpt1_found == true && is_straight1 == false) break;
|
||||
}
|
||||
|
||||
@@ -82,7 +83,7 @@ void get_corners()
|
||||
state_type = STRAIGHT_STATE;
|
||||
}
|
||||
|
||||
if (is_straight1 == false && Lpt1_found == false)
|
||||
if (Lpt1_found == false)
|
||||
{
|
||||
is_turn1 = is_curve(angle_right ,clip(angle_right_num - 10, 0,angle_right_num),0.05);
|
||||
}
|
||||
@@ -107,8 +108,8 @@ void get_corners()
|
||||
}
|
||||
}
|
||||
|
||||
if (is_turn1)
|
||||
if (is_turn1 && is_turn0)
|
||||
{
|
||||
state_type = TURN_RIGHT_STATE;
|
||||
state_type = TURN_LEFT_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ void GetMidLine_Right(float pts_right[][2], int32_t pts_right_count, float mid_r
|
||||
|
||||
int is_curve(float angle[], int n, float threshold) {
|
||||
for (int i = 1; i < n - 1; i++) {
|
||||
float da = fabs(angle[i] - angle[i-1]);
|
||||
float db = fabs(angle[i+1] - angle[i]);
|
||||
float da = fabs(angle[i] - angle[i-3]);
|
||||
float db = fabs(angle[i+3] - angle[i]);
|
||||
if (da > threshold && db > threshold) {
|
||||
return 1; // 是弯道
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user