日常更新
This commit is contained in:
@@ -44,6 +44,7 @@ void sport_motion(void)
|
||||
{
|
||||
|
||||
cnt1++;
|
||||
imu660ra_get_gyro();
|
||||
in_gyro = imu660ra_gyro_z; // 陀螺仪输入
|
||||
// in_angle = 0; // 图像远端输入
|
||||
// in_pos = 0; // 图像近端输入
|
||||
@@ -53,15 +54,14 @@ 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
|
||||
// printf("rate:%d\r\n", (int16)in_speed);
|
||||
in_speed = -encoder_get_count(TIM5_ENCOEDER); // 速度输入,m/s
|
||||
// printf("rate:%d\r\n", (int16)in_speed);
|
||||
encoder_clear_count(TIM5_ENCOEDER);
|
||||
PID_Compute(&near_pos_pid);
|
||||
cnt1 = 0;
|
||||
}
|
||||
|
||||
PID_Compute(&near_pos_pid);
|
||||
|
||||
if (bt_run_flag == 1) {
|
||||
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),
|
||||
@@ -72,7 +72,6 @@ void sport_motion(void)
|
||||
if (bt_fly_flag == 0) {
|
||||
bt_fly = 0;
|
||||
}
|
||||
|
||||
by_pwm_update_duty(bt_fly + 500, bt_fly + 500);
|
||||
}
|
||||
/**
|
||||
@@ -82,7 +81,7 @@ void sport_motion(void)
|
||||
void sport_pid_init()
|
||||
{
|
||||
|
||||
PID(&far_angle_pid, &in_angle, &out_angle, &set_angle, an_Kp, an_Ki, an_Kd, 0, 0);
|
||||
PID(&far_angle_pid, &in_angle, &out_angle, &set_angle, an_Kp, an_Ki, an_Kd, 0, 1);
|
||||
PID(&far_gyro_pid, &in_gyro, &out_gyro, &out_angle, gy_Kp, gy_Ki, gy_Kd, 1, 1);
|
||||
PID_Init(&far_angle_pid);
|
||||
PID_Init(&far_gyro_pid);
|
||||
@@ -94,7 +93,7 @@ void sport_pid_init()
|
||||
PID_SetMode(&far_angle_pid, 1);
|
||||
|
||||
PID(&near_pos_pid, &in_pos, &out_pos, &set_pos, po_Kp, po_Ki, po_Kd, 0, 0);
|
||||
PID(&speed_pid, &in_speed, &out_speed, &out_speed, sp_Kp, sp_Ki, sp_Kd, 1, 1);
|
||||
PID(&speed_pid, &in_speed, &out_speed, &set_speed, sp_Kp, sp_Ki, sp_Kd, 1, 0);
|
||||
PID_Init(&near_pos_pid);
|
||||
PID_Init(&speed_pid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user