功率控制加超电,参数可以更激进一点

This commit is contained in:
zcj 2024-05-16 22:15:26 +08:00
parent 7825e6e55f
commit 89609e884a
2 changed files with 23 additions and 16 deletions

View File

@ -60,7 +60,7 @@ float chassis_power = 0;
static float chassis_vx, chassis_vy; // 将云台系的速度投影到底盘
static float vt_lf, vt_rf, vt_lb, vt_rb; // 底盘速度解算后的临时输出,待进行限幅
float P_cmdall = 0;
static uint8_t input=0;
static float input=0;
void ChassisInit()
{
@ -121,10 +121,10 @@ void ChassisInit()
.rx_id = 0x211,
},
.buffer_pid_config = {
.Kp = 0.5f,
.Kp = 0.7f,
.Ki = 0,
.Kd = 0,
.MaxOut = 500,
.MaxOut = 300,
}
};
cap = SuperCapInit(&cap_conf); // 超级电容初始化
@ -183,6 +183,7 @@ static void MecanumCalculate()
*/
static void LimitChassisOutput()
{
static float P_max=0;
float initial_total_power[4]={motor_rf->motor_controller.motor_power_predict ,
motor_rb->motor_controller.motor_power_predict ,
motor_lb->motor_controller.motor_power_predict ,
@ -195,11 +196,14 @@ static void LimitChassisOutput()
P_cmdall += initial_total_power[i];
}
float P_max = (float)(chassis_cmd_recv.chassis_power_limit + 5 + chassis_cmd_recv.P_SuperCap) ;
if(chassis_cmd_recv.chassis_power_buffer<10)//当缓冲功率过小时,限制功率给小;
P_max = chassis_cmd_recv.chassis_power_limit;
if (cap->cap_msg.cap_vol>1800)
{
P_max = input + chassis_cmd_recv.P_SuperCap ;
}
else
{
P_max = input;
}
float K = P_max/P_cmdall;
@ -225,9 +229,10 @@ static void LimitChassisOutput()
static void SuperCapSetUpdate()
{
// PIDCalculate(&cap->buffer_pid, chassis_cmd_recv.chassis_power_buffer,30);
// input = chassis_cmd_recv.chassis_power_limit - cap->buffer_pid.Output;
// SuperCapSetPower(cap,input);
PIDCalculate(&cap->buffer_pid, chassis_cmd_recv.chassis_power_buffer,30);
input = chassis_cmd_recv.chassis_power_limit - cap->buffer_pid.Output;
LIMIT_MIN_MAX(input, 30, 130);
SuperCapSetPower(cap,input);
// if(last_chassis_power_limit != chassis_cmd_recv.chassis_power_limit)
@ -325,13 +330,15 @@ void ChassisTask()
MecanumCalculate();
//读取底盘功率,方便功率控制
// chassis_power = PowerMeterGet(power_meter);
//更新超电设定值
SuperCapSetUpdate();
// 根据裁判系统的反馈数据和电容数据对输出限幅并设定闭环参考值
LimitChassisOutput();
// 根据电机的反馈速度和IMU(如果有)计算真实速度
EstimateSpeed();
//更新超电设定值
SuperCapSetUpdate();
// // 获取裁判系统数据 建议将裁判系统与底盘分离,所以此处数据应使用消息中心发送
// // 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red

View File

@ -156,7 +156,7 @@ static void update_ui_data()
}
static void pitch_limit()
{
gimbal_cmd_send.pitch = LIMIT_MIN_MAX(gimbal_cmd_send.pitch, PITCH_MIN_ANGLE, PITCH_MAX_ANGLE);
LIMIT_MIN_MAX(gimbal_cmd_send.pitch, PITCH_MIN_ANGLE, PITCH_MAX_ANGLE);
// if(!Pitch_Limit_Flag)
// {
@ -433,10 +433,10 @@ static void MouseKeySet()
switch (rc_data[TEMP].key[KEY_PRESS].shift) //shift开关超电//
{
case 0:
chassis_cmd_send.P_SuperCap=0;
chassis_cmd_send.P_SuperCap=5;
break;
case 1:
chassis_cmd_send.P_SuperCap=195;
chassis_cmd_send.P_SuperCap=200;
break;
}
pitch_limit();