修改程序未解决俯仰角度大,pid失控问题

This commit is contained in:
2026-04-06 19:58:40 +08:00
parent 016450f9c2
commit 4cd0f4dfa7
147 changed files with 45988 additions and 45856 deletions

View File

@@ -740,10 +740,13 @@ void mt11Request(void *signal_id)
packUniversalCommandFrame(CMD_ID_REQUEST_DATA_STREAM, (uint8_t*)&gimbal_stream_request_output, 2, 0, 1);
publishMessage(&gimbal_stream_request_output, 1);
printf("Magnetic Angle - Yaw: %d, Pitch: %d, Roll: %d\n",
printf("Magnetic Angle - Yaw: %d, Pitch: %d, Roll: %d, motor: %.4f\n",
magnetic_angle_data.angle.yaw_angle,
magnetic_angle_data.angle.pitch_angle,
magnetic_angle_data.angle.roll_angle);
magnetic_angle_data.angle.roll_angle,
mt11_data.pitch_motor_pos);
printf("current_state: %d\n",
mt11_data.current_state);
@@ -758,6 +761,8 @@ void mt11Request(void *signal_id)
mt11_data.pan_speed_parem = getParam("turn_sp");
mt11_data.pitch_speed_parem = getParam("pit_sp");
mt11_data.pitch_yun_max_pos = getParam("yun_pos");
setPidParameters(&pitch_pid,
getParam("pit_kp"),
@@ -918,8 +923,8 @@ static void podControlStateMachineProcess()
mt11_data.desired_pitch_position = mt11_data.min_pitch_postion;
}
// printf("Manual PID - Pitch Out: %.4f, Yaw Out: %.4f, Pitch In: %d, Yaw In: %d, Pitch Cur: %.4f, Yaw Cur: %.4f\n",
// pitch_pid_output, mt11_data.pan_motor_speed, pitch_input, yaw_input, mt11_data.pitch, mt11_data.yaw);
printf("Manual PID - Pitch Out: %.4f, Yaw Out: %.4f, Pitch In: %d, Yaw In: %d, Pitch Cur: %.4f, Yaw Cur: %.4f\n",
pitch_pid_output, mt11_data.pan_motor_speed, pitch_input, yaw_input, mt11_data.pitch, mt11_data.yaw);
}
else
@@ -1391,6 +1396,14 @@ void mt11Init(void *signal_id)
}
}
}
else if(signal_id == &un_motor_pitch_input)//
{
mt11_data.pitch_motor_pos = convertPhysical(SWAP_ENDIAN_16(un_motor_pitch_input.rx_can_data.bit_data.current_angle),-RS04_ANGLE_MAX_PITCH,RS04_ANGLE_MAX_PITCH,0.0f);//弧度
}
else
{
}
}
void mt11_enable_Request(void *signal_id)
@@ -1423,7 +1436,9 @@ void mt11AppInit(void)
timerInit(&mt11_timer);
// 订阅定时器信号
subscribe(&mt11_timer, mt11Request);
subscribe(&mt11_received_data, mt11Init);
subscribe(&mt11_received_data, mt11Init);
subscribe(&un_motor_pitch_input, mt11Init);
printf("mt11APP: initial OK %d\n",getCurrentTime());
timerStart(&mt11_timer, 1000,1);

View File

@@ -342,6 +342,8 @@ typedef struct {
float pan_speed_parem; // 速度信息
float pitch_speed_parem; // 俯仰速度信息
float pitch_yun_max_pos; // 俯仰速度信息
float desired_yaw; // 期望方位角
float desired_pitch; // 期望俯仰角
@@ -351,6 +353,8 @@ typedef struct {
uint8_t angle_data_valid; // 角度数据有效标志0-无效1-有效
PodControlState current_state;
float pitch_motor_pos;//俯仰电机位置
Timer turnable_timer; //定时器

View File

@@ -73,6 +73,7 @@ extern "C"
X(pit_kd) \
X(pit_il) \
X(pit_ol) \
X(yun_pos) \
X(test)
// 定义一个包含所有参数名称的结构体