解决云台响应慢的问题
This commit is contained in:
@@ -918,7 +918,9 @@ static void podControlStateMachineProcess()
|
||||
mt11_data.desired_pitch_position = mt11_data.min_pitch_postion;
|
||||
}
|
||||
|
||||
printf("Manual PID - Pitch Output: %.4f, Yaw Output: %.4f\n", pitch_pid_output, mt11_data.pan_motor_speed);
|
||||
// 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
|
||||
{
|
||||
@@ -1251,12 +1253,12 @@ void mt11Init(void *signal_id)
|
||||
// 调用解包函数处理数据
|
||||
uint8_t cmd_id = unpackProtocolFrame(mt11_received_data.data, mt11_received_data.length);
|
||||
|
||||
if (cmd_id != 0xFF)
|
||||
if (cmd_id != 0xFF)
|
||||
{
|
||||
switch(cmd_id)
|
||||
{
|
||||
case CMD_ID_PAN_TILT_CONTROL:
|
||||
printf("Processing PAN/TILT control command\n");
|
||||
// printf("Processing PAN/TILT control command\n");
|
||||
break;
|
||||
|
||||
case CMD_ID_CENTER_CONTROL:
|
||||
@@ -1312,8 +1314,7 @@ void mt11Init(void *signal_id)
|
||||
} else {
|
||||
// 通道6不在范围内,设置为手动模式
|
||||
mt11_data.mode_switch = 0; // 手动模式
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1321,7 +1322,10 @@ void mt11Init(void *signal_id)
|
||||
{
|
||||
// 从数据段拷贝磁编码角度数据到全局结构体
|
||||
memcpy(&magnetic_angle_data, &mt11_received_data.data[8], sizeof(unipod_magnetic_angle_data_t));
|
||||
|
||||
// printf("data[8] = 0x%02X, data[9] = 0x%02X\n",
|
||||
// mt11_received_data.data[8],
|
||||
// mt11_received_data.data[9]);
|
||||
|
||||
// 标记角度数据有效
|
||||
mt11_data.angle_data_valid = 1;
|
||||
}
|
||||
@@ -1332,6 +1336,8 @@ void mt11Init(void *signal_id)
|
||||
// 从数据段拷贝AI追踪目标坐标数据到全局结构体
|
||||
memcpy(&ai_track_target_data, &mt11_received_data.data[8], sizeof(ai_track_data_t));
|
||||
|
||||
|
||||
|
||||
// printf("AI Track Target - X: %d, Y: %d, Width: %d, Height: %d, Target_ID: %d, Track_Sta: %d\n",
|
||||
// ai_track_target_data.info.pos_x,
|
||||
// ai_track_target_data.info.pos_y,
|
||||
@@ -1375,19 +1381,16 @@ void mt11Init(void *signal_id)
|
||||
|
||||
// 清除数据长度,表示已处理
|
||||
mt11_received_data.length = 0;
|
||||
|
||||
if(cmd_id == CMD_ID_REMOTE_CONTROL_16CH ||
|
||||
cmd_id == CMD_ID_REQUEST_MAGNETIC_ANGLE ||
|
||||
cmd_id == CMD_ID_AI_MODE_STATUS ||
|
||||
cmd_id == CMD_ID_REQUEST_CURRENT_POD_MODE)
|
||||
{
|
||||
turnableProcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{}
|
||||
|
||||
// if ( (power_data.current_state == POWER_STANDBY) || (power_data.current_state == POWER_SLEEP) )//这几种状态可以转转台
|
||||
// {
|
||||
// mt11_data.motor_state = 0;//清空状态。保证每次上电都初始化
|
||||
// mt11_data.current_state = POD_STATE_INIT;//清空状态。保证每次上电都初始化
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
turnableProcess();
|
||||
// }
|
||||
}
|
||||
|
||||
void mt11_enable_Request(void *signal_id)
|
||||
@@ -1424,6 +1427,26 @@ void mt11AppInit(void)
|
||||
printf("mt11APP: initial OK %d\n",getCurrentTime());
|
||||
timerStart(&mt11_timer, 1000,1);
|
||||
|
||||
// 初始化加速 PID 控制器
|
||||
initializePid(&yaw_pid, PID_MODE_DERIVATIVE_CALC, 0.0001f);
|
||||
// 设置 PID 控制器的参数
|
||||
setPidParameters(&yaw_pid,
|
||||
getParam("yaw_kp"),
|
||||
getParam("yaw_ki"),
|
||||
getParam("yaw_kd"),
|
||||
getParam("yaw_il"),
|
||||
getParam("yaw_ol")
|
||||
);
|
||||
|
||||
initializePid(&pitch_pid, PID_MODE_DERIVATIVE_CALC, 0.0001f);
|
||||
setPidParameters(&pitch_pid,
|
||||
getParam("pit_kp"),
|
||||
getParam("pit_ki"),
|
||||
getParam("pit_kd"),
|
||||
getParam("pit_il"),
|
||||
getParam("pit_ol")
|
||||
);
|
||||
|
||||
//使能检测
|
||||
timerInit(&motor_enable_timer);
|
||||
subscribe(&motor_enable_timer, mt11_enable_Request);
|
||||
|
||||
Reference in New Issue
Block a user