chore: 导入 Simba-OmniInfantry 基线(云台/底盘双工程)

- 云台(ROBOT_TYPE_GIMBAL)与底盘(ROBOT_TYPE_CHASSIS)完整固件源码
- 新增根级 .gitignore,排除 Keil MDK-ARM 构建产物(.o/.d/.crf/.axf/.lnp/.map/.htm/.sct/.dep/.iex/.lst 等)
  与 *.uvguix.* / DebugConfig/(与机器绑定的 UI 布局)
- core.autocrlf=false,避免固件源码在检出时被改动换行符
This commit is contained in:
2026-09-12 10:28:21 +08:00
commit a4da5ad17c
517 changed files with 503795 additions and 0 deletions
+101
View File
@@ -0,0 +1,101 @@
/* =============================================================================
* shoot.c - 发射机构:摩擦轮 2xM3508(0x200 CAN1 槽1/2)+ 拨弹 M2006
* 逻辑(与 legacy 一致):
* 摩擦轮开关受发射机构上电状态门控(可由 DEBUG_SHOOT_WITHOUT_REFEREE 绕过),
* 开启时联动激光(PC8=TIM3_CH3 PWM,占空比 0/满 对应关/开)
* 拨弹仅在摩擦轮开启后允许;fire=GIMBAL_RAMMER_SPEED(-5400),eject 反向
* 拨弹电流经 shoot_share_rammer_current() 交给云台共帧发送(0x1FF CAN1)
* ========================================================================== */
#include "shoot.h"
#include "gimbal.h"
#include "pid.h"
#include "tim.h"
#include "robot_param.h"
extern TIM_HandleTypeDef htim3;
uint8_t shoot_friction_flag = 0;
static PID_PositionTypeDef friction_l_pid, friction_r_pid, rammer_pid;
/* 激光:PC8 = TIM3_CH3(10kHz PWM,ARR=8399),占空比 0/满 对应关/开 */
#define LASER_ON() __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, 8399)
#define LASER_OFF() __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, 0)
static void laser_init(void)
{
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, 0);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
}
void shoot_init(void)
{
PID_PositionStructureInit(&friction_l_pid, 0);
PID_PositionSetParameter(&friction_l_pid, GIMBAL_FRICTION_WHEEL_KP, GIMBAL_FRICTION_WHEEL_KI, GIMBAL_FRICTION_WHEEL_KD);
PID_PositionSetEkRange(&friction_l_pid, -5, 5);
PID_PositionSetOUTRange(&friction_l_pid, -15000, 15000);
PID_PositionStructureInit(&friction_r_pid, 0);
PID_PositionSetParameter(&friction_r_pid, GIMBAL_FRICTION_WHEEL_KP, GIMBAL_FRICTION_WHEEL_KI, GIMBAL_FRICTION_WHEEL_KD);
PID_PositionSetEkRange(&friction_r_pid, -5, 5);
PID_PositionSetOUTRange(&friction_r_pid, -15000, 15000);
PID_PositionStructureInit(&rammer_pid, GIMBAL_RAMMER_SPEED);
PID_PositionSetParameter(&rammer_pid, GIMBAL_RAMMER_KP, GIMBAL_RAMMER_KI, GIMBAL_RAMMER_KD);
PID_PositionSetEkRange(&rammer_pid, -20, 20);
PID_PositionSetOUTRange(&rammer_pid, -30000, 30000);
laser_init();
}
void shoot_control(uint8_t friction_on, uint8_t fire, uint8_t eject, uint8_t shooter_power_on)
{
/* 摩擦轮(与 legacy 逻辑一致:发射机构上电才允许开启;
* 台架调试时可经 DEBUG_SHOOT_WITHOUT_REFEREE 绕过裁判系统检查) */
if (friction_on && (shooter_power_on || DEBUG_SHOOT_WITHOUT_REFEREE))
{
friction_l_pid.Need_Value = -GIMBAL_FRICTION_WHEEL_SPEED;
friction_r_pid.Need_Value = GIMBAL_FRICTION_WHEEL_SPEED;
LASER_ON();
shoot_friction_flag = 1;
}
else
{
friction_l_pid.Need_Value = 0;
friction_r_pid.Need_Value = 0;
LASER_OFF();
shoot_friction_flag = 0;
}
/* 拨弹:仅在摩擦轮开启时允许 */
if (shoot_friction_flag)
{
if (fire)
rammer_pid.Need_Value = GIMBAL_RAMMER_SPEED;
else if (eject)
rammer_pid.Need_Value = -GIMBAL_RAMMER_SPEED;
else
rammer_pid.Need_Value = 0;
}
else
rammer_pid.Need_Value = 0;
PID_PositionCalc(&friction_l_pid, motor_friction_l.fdb.rotor_speed);
PID_PositionCalc(&friction_r_pid, motor_friction_r.fdb.rotor_speed);
PID_PositionCalc(&rammer_pid, motor_rammer.fdb.rotor_speed);
/* 拨弹电流交给云台控制帧统一发送(0x1FF CAN1 共帧) */
shoot_share_rammer_current((int16_t)rammer_pid.OUT);
}
void shoot_send_cmd(void)
{
dji_motor_send_current_low(&hcan1, (int16_t)friction_l_pid.OUT, (int16_t)friction_r_pid.OUT, 0, 0);
}
void shoot_output_zero(void)
{
dji_motor_send_current_low(&hcan1, 0, 0, 0, 0);
LASER_OFF();
shoot_friction_flag = 0;
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef SHOOT_H
#define SHOOT_H
#include <stdint.h>
/* 发射机构:摩擦轮 2×M3508(0x200 CAN1 槽1/2)+ 拨弹 M2006(电流由云台共帧发送)
* 摩擦轮开启时联动激光(PC8,经 TIM3 CH3 PWM) */
/* 初始化摩擦轮/拨弹 PID(can_start 之后调用) */
extern void shoot_init(void);
/* 发射控制(2ms 调用)
* friction_on:摩擦轮开关;fire:发射;eject:退弹
* shooter_power_on:发射机构上电状态(来自底盘 0x019) */
extern void shoot_control(uint8_t friction_on, uint8_t fire, uint8_t eject, uint8_t shooter_power_on);
/* 发送摩擦轮电流帧(0x200 CAN1) */
extern void shoot_send_cmd(void);
/* 摩擦轮输出清零 */
extern void shoot_output_zero(void);
/* 摩擦轮当前开关状态(供激光联动与调试) */
extern uint8_t shoot_friction_flag;
/* 拨弹电流写入共享变量(由 shoot 模块调用,云台共帧发送) */
extern void shoot_share_rammer_current(int16_t current);
#endif