英雄版本

This commit is contained in:
Robofish 2025-01-15 14:14:41 +08:00
parent ee7ed0b056
commit 9f67e5e851
7 changed files with 8919 additions and 8907 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -356,6 +356,7 @@ int8_t CMD_ParseHost(const CMD_Host_t *host, CMD_t *cmd, float dt_sec) {
cmd->gimbal.delta_eulr.pit = host->gimbal_delta.pit;
cmd->shoot.mode = SHOOT_MODE_LOADED;
cmd->shoot.fire = false;
/* host射击命令设置不同的射击频率和弹丸初速度 */
if (host->fire && cmd->shoot.ai_fire) {
cmd->shoot.fire = true;

View File

@ -202,7 +202,11 @@ static const Config_RobotParam_t param_default = {
}, /* can */
}; /* param_default */
#ifdef DEBUG
Config_RobotParam_t param_hero = {
#else
static const Config_RobotParam_t param_hero = {
#endif
.model = ROBOT_MODEL_HERO,
.chassis = { /* 底盘模块参数 */
@ -236,7 +240,7 @@ static const Config_RobotParam_t param_hero = {
},
.reverse = {
.yaw = true,
.yaw = false,
},
}, /* chassis */
@ -293,8 +297,8 @@ static const Config_RobotParam_t param_hero = {
},
.reverse = {
.yaw = true,
.pit = true,
.yaw = false,
.pit = false,
},
.pit_ctrl_reverse = false,
@ -331,8 +335,8 @@ static const Config_RobotParam_t param_hero = {
.trig = -1.0f,
},
},
.num_trig_tooth = 6.0f,
.trig_gear_ratio = 3591.0f / 187.0f,
.num_trig_tooth = 5.0f,
.trig_gear_ratio = 19.0f,
.fric_radius = 0.03f,
.cover_open_duty = 0.125f,
.cover_close_duty = 0.075f,

View File

@ -134,33 +134,33 @@ int8_t Gimbal_Control(Gimbal_t *g, CMD_GimbalCmd_t *g_cmd, uint32_t now) {
if (g->param->pit_ctrl_reverse){
g_cmd->delta_eulr.yaw = -g_cmd->delta_eulr.yaw;
}else{
g_cmd->delta_eulr.yaw = g_cmd->delta_eulr.yaw;
g_cmd->delta_eulr.yaw = -g_cmd->delta_eulr.yaw;
}
/* 处理yaw控制命令 */
CircleAdd(&(g->setpoint.eulr.yaw), g_cmd->delta_eulr.yaw, M_2PI);
/* 处理pitch控制命令软件限位 */
// const float delta_max =
// CircleError(g->limit.max,
// (g->feedback.eulr.encoder.pit + g->setpoint.eulr.pit -
// g->feedback.eulr.imu.pit),
// M_2PI);
// const float delta_min =
// CircleError(g->limit.min,
// (g->feedback.eulr.encoder.pit + g->setpoint.eulr.pit -
// g->feedback.eulr.imu.pit),
// M_2PI);
const float delta_max =
CircleError(g->limit.max,
(g->feedback.eulr.encoder.pit + g->setpoint.eulr.pit -
g->feedback.eulr.encoder.pit),
g->feedback.eulr.imu.pit),
M_2PI);
const float delta_min =
CircleError(g->limit.min,
(g->feedback.eulr.encoder.pit + g->setpoint.eulr.pit -
g->feedback.eulr.encoder.pit),
g->feedback.eulr.imu.pit),
M_2PI);
// const float delta_max =
// CircleError(g->limit.max,
// (g->feedback.eulr.encoder.pit + g->setpoint.eulr.pit -
// g->feedback.eulr.encoder.pit),
// M_2PI);
// const float delta_min =
// CircleError(g->limit.min,
// (g->feedback.eulr.encoder.pit + g->setpoint.eulr.pit -
// g->feedback.eulr.encoder.pit),
// M_2PI);
Clip(&(g_cmd->delta_eulr.pit), delta_min, delta_max);
g->setpoint.eulr.pit += g_cmd->delta_eulr.pit;
@ -182,16 +182,20 @@ int8_t Gimbal_Control(Gimbal_t *g, CMD_GimbalCmd_t *g_cmd, uint32_t now) {
PID_Calc(&(g->pid[GIMBAL_PID_YAW_OMEGA_IDX]), yaw_omega_set_point,
g->feedback.gyro.z, 0.f, g->dt);
// pit_omega_set_point =
// PID_Calc(&(g->pid[GIMBAL_PID_PIT_ANGLE_IDX]), g->setpoint.eulr.pit,
// g->feedback.eulr.imu.pit, 0.0f, g->dt);
pit_omega_set_point =
PID_Calc(&(g->pid[GIMBAL_PID_PIT_ANGLE_IDX]), g->setpoint.eulr.pit,
g->feedback.eulr.encoder.pit, 0.0f, g->dt);
g->feedback.eulr.imu.pit, 0.0f, g->dt);
// pit_omega_set_point =
// PID_Calc(&(g->pid[GIMBAL_PID_PIT_ANGLE_IDX]), g->setpoint.eulr.pit,
// g->feedback.eulr.encoder.pit, 0.0f, g->dt);
g->out[GIMBAL_ACTR_PIT_IDX] =
PID_Calc(&(g->pid[GIMBAL_PID_PIT_OMEGA_IDX]), pit_omega_set_point,
0.0, 0.f, g->dt);
g->feedback.gyro.x, 0.f, g->dt);
// g->out[GIMBAL_ACTR_PIT_IDX] =
// PID_Calc(&(g->pid[GIMBAL_PID_PIT_OMEGA_IDX]), pit_omega_set_point,
// 0.0, 0.f, g->dt);
break;
case GIMBAL_MODE_RELATIVE:

View File

@ -252,9 +252,9 @@ int8_t Shoot_Control(Shoot_t *s, CMD_ShootCmd_t *s_cmd,
float fric_rpm = CalculateRpm(s->fire_ctrl.bullet_speed, s->param->fric_radius,
(s->param->model == SHOOT_MODEL_17MM));
s->setpoint.fric_rpm[0] = fric_rpm;
s->setpoint.fric_rpm[1] = -fric_rpm;
s->setpoint.fric_rpm[2] = fric_rpm;
s->setpoint.fric_rpm[0] = -fric_rpm;
s->setpoint.fric_rpm[1] = fric_rpm;
s->setpoint.fric_rpm[2] = -fric_rpm;
/* 计算拨弹电机位置的目标值 */
if (((now - s->fire_ctrl.last_shoot) >= s->fire_ctrl.period_ms) &&

View File

@ -32,10 +32,10 @@ typedef struct {
static const char *const CLI_WELCOME_MESSAGE =
"\r\n"
// " ______ __ _______ __ \r\n"
// " | __ \\.-----.| |--.-----.| | |.---.-.-----.| |_.-----.----.\r\n"
// " | <| _ || _ | _ || || _ |__ --|| _| -__| _|\r\n"
// " |___|__||_____||_____|_____||__|_|__||___._|_____||____|_____|__| \r\n"
" ______ __ _______ __ \r\n"
" | __ \\.-----.| |--.-----.| | |.---.-.-----.| |_.-----.----.\r\n"
" | <| _ || _ | _ || || _ |__ --|| _| -__| _|\r\n"
" |___|__||_____||_____|_____||__|_|__||___._|_____||____|_____|__| \r\n"
" -------------------------------------------------------------------\r\n"
" FreeRTOS CLI. Type 'help' to view a list of registered commands. \r\n"
"\r\n";