写入了发弹检测模块,并为电流环控制
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/* =============================================================================
|
||||
* shoot.c - 发射机构:摩擦轮 2xM3508(0x200 CAN1 槽1/2)+ 拨弹 M2006
|
||||
* 逻辑(与 legacy 一致):
|
||||
* shoot.c - 发射机构:摩擦轮 2xM3508(0x200 CAN1 槽1/2)+ 拨弹 M2006(0x200 CAN2 槽1)
|
||||
* 逻辑:
|
||||
* 摩擦轮开关受发射机构上电状态门控(可由 DEBUG_SHOOT_WITHOUT_REFEREE 绕过),
|
||||
* 开启时联动激光(PC8=TIM3_CH3 PWM,占空比 0/满 对应关/开)
|
||||
* 拨弹仅在摩擦轮开启后允许;fire=GIMBAL_RAMMER_SPEED(-5400),eject 反向
|
||||
* 拨弹电流经 shoot_share_rammer_current() 交给云台共帧发送(0x1FF CAN1)
|
||||
* 摩擦轮通过 0x200(CAN1)发送, 拨弹通过 0x200(CAN2)发送
|
||||
* ========================================================================== */
|
||||
#include "shoot.h"
|
||||
#include "gimbal.h"
|
||||
@@ -43,7 +43,7 @@ void shoot_init(void)
|
||||
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);
|
||||
PID_PositionSetOUTRange(&rammer_pid, -10000, 10000); // M2006 电流限幅(±10000 对应 ±10A)
|
||||
|
||||
laser_init();
|
||||
}
|
||||
@@ -84,18 +84,31 @@ void shoot_control(uint8_t friction_on, uint8_t fire, uint8_t eject, uint8_t sho
|
||||
PID_PositionCalc(&friction_r_pid, motor_friction_r.fdb.rotor_speed);
|
||||
PID_PositionCalc(&rammer_pid, motor_rammer.fdb.rotor_speed);
|
||||
|
||||
/* 拨弹电流交给云台控制帧统一发送(0x1FF CAN1 共帧) */
|
||||
/* 拨弹电流由 shoot_send_cmd 统一在 0x200 帧(槽 3)发送, 保留共享函数以兼容 */
|
||||
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);
|
||||
/* CAN1 0x200: 槽1=左摩擦轮, 槽2=右摩擦轮 */
|
||||
dji_motor_send_current_low(&hcan1,
|
||||
(int16_t)friction_l_pid.OUT,
|
||||
(int16_t)friction_r_pid.OUT,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* CAN2 0x200: 槽1=拨弹盘 M2006 (ID 1) */
|
||||
dji_motor_send_current_low(&hcan2,
|
||||
(int16_t)rammer_pid.OUT,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
void shoot_output_zero(void)
|
||||
{
|
||||
dji_motor_send_current_low(&hcan1, 0, 0, 0, 0);
|
||||
dji_motor_send_current_low(&hcan2, 0, 0, 0, 0);
|
||||
LASER_OFF();
|
||||
shoot_friction_flag = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user