修复热量
This commit is contained in:
parent
08036a7b1f
commit
dd6c48c75c
@ -71,7 +71,7 @@ static void CMD_RC_BuildGimbalCmd(CMD_t *ctx) {
|
|||||||
#if CMD_ENABLE_SRC_RC && CMD_ENABLE_MODULE_SHOOT
|
#if CMD_ENABLE_SRC_RC && CMD_ENABLE_MODULE_SHOOT
|
||||||
static void CMD_RC_BuildShootCmd(CMD_t *ctx) {
|
static void CMD_RC_BuildShootCmd(CMD_t *ctx) {
|
||||||
if (ctx->input.online[CMD_SRC_RC]) {
|
if (ctx->input.online[CMD_SRC_RC]) {
|
||||||
ctx->output.shoot.cmd.mode = SHOOT_MODE_SINGLE;
|
ctx->output.shoot.cmd.mode = SHOOT_MODE_CONTINUE;
|
||||||
} else {
|
} else {
|
||||||
ctx->output.shoot.cmd.mode = SHOOT_MODE_SAFE;
|
ctx->output.shoot.cmd.mode = SHOOT_MODE_SAFE;
|
||||||
}
|
}
|
||||||
@ -406,6 +406,13 @@ static void CMD_PC_BuildBalanceChassisCmd(CMD_t *ctx) {
|
|||||||
ctx->output.balance_chassis.cmd.move_vec.vy = 0.0f;
|
ctx->output.balance_chassis.cmd.move_vec.vy = 0.0f;
|
||||||
ctx->output.balance_chassis.cmd.move_vec.wz = 0.0f;
|
ctx->output.balance_chassis.cmd.move_vec.wz = 0.0f;
|
||||||
|
|
||||||
|
ctx->output.balance_chassis.cmd.height += (float)ctx->input.pc.mouse.z * sens->mouse_sens * 0.001f * ctx->timer.dt;
|
||||||
|
if (ctx->output.balance_chassis.cmd.height > 1.0f) {
|
||||||
|
ctx->output.balance_chassis.cmd.height = 1.0f;
|
||||||
|
} else if (ctx->output.balance_chassis.cmd.height < 0.2f) {
|
||||||
|
ctx->output.balance_chassis.cmd.height = 0.2f;
|
||||||
|
}
|
||||||
|
ctx->output.balance_chassis.cmd.jump_trigger = false;
|
||||||
ctx->output.balance_chassis.cmd.mode = CHASSIS_MODE_WHELL_LEG_BALANCE;
|
ctx->output.balance_chassis.cmd.mode = CHASSIS_MODE_WHELL_LEG_BALANCE;
|
||||||
CMD_Behavior_ProcessAll(ctx, &ctx->input, &ctx->last_input, CMD_MODULE_BALANCE_CHASSIS);
|
CMD_Behavior_ProcessAll(ctx, &ctx->input, &ctx->last_input, CMD_MODULE_BALANCE_CHASSIS);
|
||||||
|
|
||||||
|
|||||||
@ -146,16 +146,16 @@ Config_RobotParam_t robot_config = {
|
|||||||
},
|
},
|
||||||
.jamDetection={
|
.jamDetection={
|
||||||
.enable=true,
|
.enable=true,
|
||||||
.threshold=200.0f,
|
.threshold=90.0f,
|
||||||
.suspectedTime=0.5f,
|
.suspectedTime=0.5f,
|
||||||
},
|
},
|
||||||
.heatControl={
|
.heatControl={
|
||||||
.enable=true,
|
.enable=true,
|
||||||
.safe_shots=0.05f, // 安全出弹余量比例
|
.safe_shots=0.10f, // 安全出弹余量比例
|
||||||
.nmax=18.0f, // 最大射频 Hz
|
.nmax=15.0f, // 最大射频 Hz
|
||||||
.Hwarn=0.70f, // 预警阈值比例(70%)
|
.Hwarn=0.50f, // 预警阈值比例(70%)
|
||||||
.Hsatu=0.40f, // 饱和阈值比例(40%)
|
.Hsatu=0.25f, // 饱和阈值比例(40%)
|
||||||
.Hthres=0.08f, // 停射阈值比例(8%)
|
.Hthres=0.05f, // 停射阈值比例(8%)
|
||||||
},
|
},
|
||||||
.motor={
|
.motor={
|
||||||
.fric = {
|
.fric = {
|
||||||
@ -480,7 +480,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
|
|
||||||
.climb = {
|
.climb = {
|
||||||
.forward_speed = 1.5f, /* 上台阶前进速度 (m/s) */
|
.forward_speed = 1.5f, /* 上台阶前进速度 (m/s) */
|
||||||
.theta_retract_threshold = 0.9f, /* 腿后摆收腿阈值 (rad),约30° */
|
.theta_retract_threshold = 0.98f, /* 腿后摆收腿阈值 (rad),约30° */
|
||||||
.tp_scale = 0.08f, /* 摆力矩缩放:削弱到10%,让腿自由后摆 */
|
.tp_scale = 0.08f, /* 摆力矩缩放:削弱到10%,让腿自由后摆 */
|
||||||
.settle_time_ms = 500, /* 收腿后稳定时间 (ms) */
|
.settle_time_ms = 500, /* 收腿后稳定时间 (ms) */
|
||||||
},
|
},
|
||||||
|
|||||||
@ -353,8 +353,8 @@ static int8_t Shoot_FuseHeatData(Shoot_t *s)
|
|||||||
s->heatcontrol.Hnow_last = s->heatcontrol.Hnow; /* 记录本次值 */
|
s->heatcontrol.Hnow_last = s->heatcontrol.Hnow; /* 记录本次值 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 融合值就是裁判系统值(作为基准) */
|
/* 连射场景下,裁判数据存在刷新延迟;取更保守的热量用于限热 */
|
||||||
s->heatcontrol.Hnow_fused = s->heatcontrol.Hnow;
|
s->heatcontrol.Hnow_fused = fmaxf(s->heatcontrol.Hnow, s->heatcontrol.Hnow_estimated);
|
||||||
} else {
|
} else {
|
||||||
/* 裁判系统数据无效,仅使用自主估计值 */
|
/* 裁判系统数据无效,仅使用自主估计值 */
|
||||||
s->heatcontrol.Hnow_fused = s->heatcontrol.Hnow_estimated;
|
s->heatcontrol.Hnow_fused = s->heatcontrol.Hnow_estimated;
|
||||||
@ -461,26 +461,8 @@ static int8_t Shoot_HeatDetectionFSM(Shoot_t *s)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOOT_HEAT_DETECT_CONFIRMED:
|
case SHOOT_HEAT_DETECT_CONFIRMED:
|
||||||
/* 确认发射状态:增加热量并返回准备状态 */
|
/* 确认发射状态:仅记录检测计数。
|
||||||
/* 根据弹丸类型增加估计热量 */
|
* 估计热量在实际下发拨弹时已预扣,避免重复累加。 */
|
||||||
switch (s->param->basic.projectileType) {
|
|
||||||
case SHOOT_PROJECTILE_17MM:
|
|
||||||
s->heatcontrol.Hnow_estimated += 10.0f;
|
|
||||||
break;
|
|
||||||
case SHOOT_PROJECTILE_42MM:
|
|
||||||
s->heatcontrol.Hnow_estimated += 100.0f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
s->heatcontrol.Hnow_estimated += s->heatcontrol.Hgen;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 限制估计热量不超过最大值 */
|
|
||||||
if (s->heatcontrol.Hnow_estimated > s->heatcontrol.Hmax) {
|
|
||||||
s->heatcontrol.Hnow_estimated = s->heatcontrol.Hmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 增加发射计数 */
|
|
||||||
s->heatcontrol.shots_detected++;
|
s->heatcontrol.shots_detected++;
|
||||||
|
|
||||||
/* 返回准备检测状态 */
|
/* 返回准备检测状态 */
|
||||||
@ -539,6 +521,15 @@ static float Shoot_CaluFreqByHeat(Shoot_t *s)
|
|||||||
float nmax = s->param->heatControl.nmax;
|
float nmax = s->param->heatControl.nmax;
|
||||||
float ncd = s->heatcontrol.ncd;
|
float ncd = s->heatcontrol.ncd;
|
||||||
|
|
||||||
|
if (nmax <= 0.0f) {
|
||||||
|
nmax = s->param->basic.shot_freq;
|
||||||
|
}
|
||||||
|
if (ncd < 0.0f) {
|
||||||
|
ncd = 0.0f;
|
||||||
|
} else if (ncd > nmax) {
|
||||||
|
ncd = nmax;
|
||||||
|
}
|
||||||
|
|
||||||
if (Hwarn <= 0.0f) {
|
if (Hwarn <= 0.0f) {
|
||||||
Hwarn = s->heatcontrol.Hmax * 0.7f;
|
Hwarn = s->heatcontrol.Hmax * 0.7f;
|
||||||
}
|
}
|
||||||
@ -609,6 +600,14 @@ int8_t Shoot_CaluTargetAngle(Shoot_t *s, Shoot_CMD_t *cmd)
|
|||||||
CircleAdd(&s->target_variable.trig_angle, M_2PI/s->param->basic.num_trig_tooth, M_2PI);
|
CircleAdd(&s->target_variable.trig_angle, M_2PI/s->param->basic.num_trig_tooth, M_2PI);
|
||||||
s->var_trig.num_toShoot--;
|
s->var_trig.num_toShoot--;
|
||||||
s->var_trig.num_shooted++;
|
s->var_trig.num_shooted++;
|
||||||
|
|
||||||
|
/* 实际发射指令下发时,立刻预扣估计热量,抑制裁判数据延迟导致的超热。 */
|
||||||
|
if (s->param->heatControl.enable && s->heatcontrol.ref_online && s->heatcontrol.Hgen > 0.0f) {
|
||||||
|
s->heatcontrol.Hnow_estimated += s->heatcontrol.Hgen;
|
||||||
|
if (s->heatcontrol.Hnow_estimated > s->heatcontrol.Hmax) {
|
||||||
|
s->heatcontrol.Hnow_estimated = s->heatcontrol.Hmax;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SHOOT_OK;
|
return SHOOT_OK;
|
||||||
|
|||||||
@ -13,8 +13,8 @@ extern "C" {
|
|||||||
#include "component/pid.h"
|
#include "component/pid.h"
|
||||||
#include "device/motor_rm.h"
|
#include "device/motor_rm.h"
|
||||||
/* Exported constants ------------------------------------------------------- */
|
/* Exported constants ------------------------------------------------------- */
|
||||||
#define MAX_FRIC_NUM 6
|
#define MAX_FRIC_NUM 2
|
||||||
#define MAX_NUM_MULTILEVEL 2 /* 多级发射级数 */
|
#define MAX_NUM_MULTILEVEL 1 /* 多级发射级数 */
|
||||||
|
|
||||||
#define SHOOT_OK (0) /* 运行正常 */
|
#define SHOOT_OK (0) /* 运行正常 */
|
||||||
#define SHOOT_ERR_NULL (-1) /* 运行时发现NULL指针 */
|
#define SHOOT_ERR_NULL (-1) /* 运行时发现NULL指针 */
|
||||||
|
|||||||
@ -38,13 +38,23 @@ static int print_shoot(const void *data, char *buf, size_t size) {
|
|||||||
" Fric1 : %.1f rpm (target: %.1f)\r\n"
|
" Fric1 : %.1f rpm (target: %.1f)\r\n"
|
||||||
" Fric_Avg : %.1f rpm\r\n"
|
" Fric_Avg : %.1f rpm\r\n"
|
||||||
" Trig : %.1f rpm (angle: %.2f deg)\r\n"
|
" Trig : %.1f rpm (angle: %.2f deg)\r\n"
|
||||||
" Output : Fric0=%.1f Fric1=%.1f Trig=%.1f\r\n",
|
" Output : Fric0=%.1f Fric1=%.1f Trig=%.1f\r\n"
|
||||||
|
" Heat : online=%d Hnow=%.1f Hest=%.1f Hfused=%.1f Hres=%.1f Hmax=%.1f Hgen=%.1f ncd=%.2f avail=%u\r\n",
|
||||||
shoot->running_state,
|
shoot->running_state,
|
||||||
shoot->feedback.fric[0].rotor_speed, shoot->target_variable.fric_rpm,
|
shoot->feedback.fric[0].rotor_speed, shoot->target_variable.fric_rpm,
|
||||||
shoot->feedback.fric[1].rotor_speed, shoot->target_variable.fric_rpm,
|
shoot->feedback.fric[1].rotor_speed, shoot->target_variable.fric_rpm,
|
||||||
shoot->var_fric.normalized_fil_avgrpm,
|
shoot->var_fric.normalized_fil_avgrpm,
|
||||||
shoot->feedback.trig.feedback.rotor_speed, shoot->feedback.trig.feedback.rotor_abs_angle,
|
shoot->feedback.trig.feedback.rotor_speed, shoot->feedback.trig.feedback.rotor_abs_angle,
|
||||||
shoot->output.out_fric[0], shoot->output.out_fric[1], shoot->output.outagl_trig);
|
shoot->output.out_fric[0], shoot->output.out_fric[1], shoot->output.outagl_trig,
|
||||||
|
shoot->heatcontrol.ref_online ? 1 : 0,
|
||||||
|
shoot->heatcontrol.Hnow,
|
||||||
|
shoot->heatcontrol.Hnow_estimated,
|
||||||
|
shoot->heatcontrol.Hnow_fused,
|
||||||
|
shoot->heatcontrol.Hres,
|
||||||
|
shoot->heatcontrol.Hmax,
|
||||||
|
shoot->heatcontrol.Hgen,
|
||||||
|
shoot->heatcontrol.ncd,
|
||||||
|
(unsigned int)shoot->heatcontrol.shots_available);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +90,20 @@ void Task_ctrl_shoot(void *argument) {
|
|||||||
shoot.heatcontrol.ref_online = true;
|
shoot.heatcontrol.ref_online = true;
|
||||||
shoot.heatcontrol.Hmax = (float)shoot_ref.robot_status.shooter_barrel_heat_limit;
|
shoot.heatcontrol.Hmax = (float)shoot_ref.robot_status.shooter_barrel_heat_limit;
|
||||||
shoot.heatcontrol.Hcd = (float)shoot_ref.robot_status.shooter_barrel_cooling_value;
|
shoot.heatcontrol.Hcd = (float)shoot_ref.robot_status.shooter_barrel_cooling_value;
|
||||||
|
switch (shoot.param->basic.projectileType) {
|
||||||
|
case SHOOT_PROJECTILE_17MM:
|
||||||
|
shoot.heatcontrol.Hnow = (float)shoot_ref.power_heat.shooter_17mm_barrel_heat;
|
||||||
|
shoot.heatcontrol.Hgen = 10.0f;
|
||||||
|
break;
|
||||||
|
case SHOOT_PROJECTILE_42MM:
|
||||||
shoot.heatcontrol.Hnow = (float)shoot_ref.power_heat.shooter_42mm_barrel_heat;
|
shoot.heatcontrol.Hnow = (float)shoot_ref.power_heat.shooter_42mm_barrel_heat;
|
||||||
shoot.heatcontrol.Hgen = 10.0f; /* 42mm弹丸每发产生热量 */
|
shoot.heatcontrol.Hgen = 100.0f;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shoot.heatcontrol.Hnow = (float)shoot_ref.power_heat.shooter_17mm_barrel_heat;
|
||||||
|
shoot.heatcontrol.Hgen = 10.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
shoot.heatcontrol.ref_online = false;
|
shoot.heatcontrol.ref_online = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user