feat: 开启速度闭环

fix: 暂时修复通信卡死问题
This commit is contained in:
2024-03-05 21:28:08 +08:00
parent 6c0cfe1248
commit bab1667efb
7 changed files with 112 additions and 23 deletions

View File

@@ -70,25 +70,26 @@ void sport_motion(void)
if (cnt1 >= 10) {
PID_Compute(&far_angle_pid);
PID_Compute(&speed_pid);
// in_speed = -encoder_get_count(TIM5_ENCOEDER); // 速度输入m/s
in_speed = sport_get_speed();
printf("rate:%d\r\n", (int16_t)in_speed);
in_speed = -sport_get_speed();
// printf("rate:%d\r\n", (int16_t)in_speed);
PID_Compute(&near_pos_pid);
cnt1 = 0;
}
if (bt_run_flag == 1) {
by_pwm_power_duty((int32_t)(500 + out_pos + out_gyro),
(int32_t)(500 - out_pos - out_gyro),
(int32_t)(500 + out_speed + out_gyro),
(int32_t)(500 + out_speed - out_gyro));
// by_pwm_power_duty((int32_t)(500 + out_pos + out_gyro),
// (int32_t)(500 - out_pos - out_gyro),
// (int32_t)(500 + out_speed + out_gyro),
// (int32_t)(500 + out_speed - out_gyro));
by_pwm_power_duty(500, 500, 500 + out_speed, 500 + out_speed);
} else {
by_pwm_power_duty(500, 500, 500, 500);
}
if (bt_fly_flag == 0) {
bt_fly = 0;
by_pwm_update_duty(0 + 500, 0 + 500);
} else {
by_pwm_update_duty(bt_fly + 500, bt_fly + 500);
}
by_pwm_update_duty(bt_fly + 500, bt_fly + 500);
}
/**