电流环控制,并实现简单的补偿控制,还差参数具体化。
This commit is contained in:
@@ -36,24 +36,66 @@
|
||||
#include "ins.h"
|
||||
#include "bmi088.h"
|
||||
#include "gimbal.h"
|
||||
#include "dr16.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ===== 2026-10-15 台架调参临时遥测(已停用,保留备查) =====
|
||||
* 启用时把 #if 0 改 #if 1:本任务改为输出 5 列 CSV
|
||||
* setpoint_deg, actual_deg, out_current, ecd_deg, gyro_x_dps
|
||||
* (逗号分隔+换行,可被 Lissio FireWater 自动识别为 5 通道),采样率提到 200Hz,
|
||||
* 用于定量观测阶跃响应与判断"轴是否真的在转动"。 */
|
||||
#if 0
|
||||
#include "robot_param.h"
|
||||
#define DEBUG_PITCH_TUNE 1
|
||||
#if DEBUG_PITCH_TUNE
|
||||
#define DEBUG_OUT_PERIOD_MS 5 /* 200Hz:2ms 控制环的阶跃响应需 ≥100Hz 采样才量得准 */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* 1-输出健康位(cvg/rdy/imu/an/gn); 0-只输出三个欧拉角 */
|
||||
#define DEBUG_ATT_HEALTH 1
|
||||
#define DEBUG_ATT_HEALTH 0
|
||||
/* 1-再附加原始陀螺/零偏/采样计数(排障用); 0-只留上面的通用健康位 */
|
||||
#define DEBUG_ATT_DIAG 1
|
||||
#define DEBUG_ATT_DIAG 0
|
||||
/* 1-仅输出 Pitch 调参行(便于用 VOFA+/串口示波器绘图); 0-同时输出姿态行与 Pitch 调参行 */
|
||||
#define DEBUG_PITCH_ONLY 0
|
||||
|
||||
/* 输出周期(ms)。姿态观测建议 100ms(10Hz) */
|
||||
#define DEBUG_OUT_PERIOD_MS 100
|
||||
|
||||
void debug_task(void const * argument)
|
||||
{
|
||||
char line[192];
|
||||
char line[384];
|
||||
char tail[112];
|
||||
char pitch_line[128];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
#if 0
|
||||
/* ===== 2026-10-15 台架 Pitch 调参遥测(已停用,保留备查) =====
|
||||
* 5 列 CSV → Lissio FireWater 直接成 5 通道:
|
||||
* setpoint(位置环设定值含台架偏置), actual(-att_deg_roll),
|
||||
* out(最终电流), ecd_deg(编码器机械角), gyro_x_dps(陀螺 x 轴角速度) */
|
||||
const float tune_ecd_deg = ((float)motor_pitch_gimbal.fdb.raw_angle -
|
||||
(float)PITCH_GM6020_ENCODER_ZERO) * (360.0f / 8192.0f);
|
||||
const float tune_gyro_dps = bmi088_gyro[0] * 57.29578f;
|
||||
int len = snprintf(line, sizeof(line), "%.3f,%.3f,%.1f,%.3f,%.2f\n",
|
||||
gimbal_pitch_setpoint_deg(),
|
||||
-att_deg_roll,
|
||||
pitch_current,
|
||||
tune_ecd_deg,
|
||||
tune_gyro_dps);
|
||||
#endif
|
||||
#if DEBUG_PITCH_ONLY
|
||||
/* 仅输出 Pitch 调参数据(编码值、roll、PID最后输出值、遥控pitch杆量) */
|
||||
int len = snprintf(line, sizeof(line),
|
||||
"p_ecd=%u roll=%.2f p_out=%.1f rc_pitch=%u\r\n",
|
||||
(unsigned)motor_pitch_gimbal.fdb.raw_angle,
|
||||
att_deg_roll,
|
||||
pitch_current,
|
||||
(unsigned)dr16.rc_l_UD);
|
||||
#else
|
||||
const float an = sqrtf(bmi088_accel[0] * bmi088_accel[0] +
|
||||
bmi088_accel[1] * bmi088_accel[1] +
|
||||
bmi088_accel[2] * bmi088_accel[2]);
|
||||
@@ -79,9 +121,11 @@ void debug_task(void const * argument)
|
||||
(unsigned)INS.ConvergeFlag, (unsigned)att_ready,
|
||||
(unsigned)bmi088_online, an, gn, tail);
|
||||
#else
|
||||
int len = snprintf(line, sizeof(line), "ecd=%u yaw=%.2f pitch=%.2f roll=%.2f\r\n",
|
||||
(unsigned)motor_yaw_gimbal.fdb.raw_angle,
|
||||
att_deg_yaw, att_deg_pitch, att_deg_roll);
|
||||
int len = snprintf(line, sizeof(line), "%u,%.1f,%u\r\n",
|
||||
(unsigned)motor_pitch_gimbal.fdb.raw_angle,
|
||||
pitch_current,(unsigned)motor_yaw_gimbal.fdb.raw_angle);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (len > 0)
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
* YAW_RUN 正常串级控制(符号用参数回退值,直至手势自检完成)
|
||||
* YAW_DETECT 装配符号自检——**仅由操作手手势显式触发,绝不自动执行**:
|
||||
* 遥控在线时"左摇杆推到最左 + 右摇杆推到最右"保持 0.5s。
|
||||
* 检测期间云台会轻转几度(约 20% 电压脉冲 60ms),操作手应
|
||||
* 检测期间云台会轻转几度(约 20% 电流脉冲 60ms),操作手应
|
||||
* 确认云台周围无人后再做手势。失败重试 3 次后回退参数符号。
|
||||
* 任意门控失效(遥控离线/电机掉线/姿态不可用/底盘故障)立即清零输出
|
||||
* 拨弹电流由 shoot_task 写入共享变量,本任务与 Pitch 共帧发送(0x1FF CAN1)
|
||||
* Yaw/Pitch GM6020 采用 0x1FE 电流帧控制;拨弹 M2006 由 shoot_task 独立发 0x200
|
||||
* ========================================================================== */
|
||||
#include "app_tasks.h"
|
||||
#include "cmsis_os.h"
|
||||
@@ -64,6 +64,34 @@ void gimbal_task(void const * argument)
|
||||
if (gesture)
|
||||
gesture_cnt = 0;
|
||||
|
||||
#if 0
|
||||
/* ===== 2026-10-15 台架 Pitch 阶跃发生器(已停用,保留备查) =====
|
||||
* **有界**测试,不是持续抖动:只跑 GIMBAL_BENCH_PITCH_HALF_COUNT 个半周期,
|
||||
* 跑完自动归零并锁存,之后云台恢复静止(重新上电/改开关才会再跑一次)。
|
||||
* 配合 gimbal.c 的台架偏置使用;2ms 任务,半周期 tick 数 = HALF_MS / 2 */
|
||||
{
|
||||
static uint32_t bench_phase = 0;
|
||||
static uint8_t bench_done = 0;
|
||||
const uint32_t half_ticks = (uint32_t)GIMBAL_BENCH_PITCH_HALF_MS / 2u;
|
||||
if (!bench_done && half_ticks > 0u)
|
||||
{
|
||||
const uint32_t total_ticks = half_ticks * (uint32_t)GIMBAL_BENCH_PITCH_HALF_COUNT;
|
||||
if (bench_phase >= total_ticks)
|
||||
{
|
||||
bench_done = 1;
|
||||
gimbal_bench_pitch_offset = 0.0f; /* 跑完立即停,不再抖动 */
|
||||
}
|
||||
else
|
||||
{
|
||||
gimbal_bench_pitch_offset = ((bench_phase / half_ticks) % 2u)
|
||||
? GIMBAL_BENCH_PITCH_STEP_DEG
|
||||
: 0.0f;
|
||||
bench_phase++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case YAW_WAIT:
|
||||
|
||||
@@ -85,8 +85,8 @@ static int8_t linkcheck_first_offline(void)
|
||||
{
|
||||
uint32_t now = HAL_GetTick();
|
||||
#if defined(ROBOT_TYPE_GIMBAL)
|
||||
/* 设备序号:0 摩擦轮L(0x201) 1 摩擦轮R(0x202) 2 Pitch(0x206)
|
||||
* 3 Yaw(0x205) 4 拨弹(0x207,安装时) 5 底盘回传(0x019) */
|
||||
/* 设备序号:0 摩擦轮L(CAN1 0x201) 1 摩擦轮R(CAN1 0x202) 2 Pitch(CAN1 0x206)
|
||||
* 3 Yaw(CAN2 0x205) 4 拨弹(CAN2 0x201,安装时) 5 底盘回传(0x019) */
|
||||
if (LINK_OFFLINE(motor_friction_l.fdb.last_online_tick))
|
||||
return 0;
|
||||
if (LINK_OFFLINE(motor_friction_r.fdb.last_online_tick))
|
||||
|
||||
@@ -97,8 +97,8 @@ void robot_cmd_task(void const * argument)
|
||||
|
||||
if (!keyboard_online)
|
||||
{
|
||||
/* 遥控器:左摇杆,输出与摇杆偏量成比例(legacy 为过死区即全速,
|
||||
* 体感过灵敏),限位门控与方向保持 legacy */
|
||||
/* 遥控器:左摇杆向上(>1050)为抬头(pitch_delta减小,pos向2260减小),门控须 pos > UPPER_LIMIT(2260);
|
||||
* 左摇杆向下(<1000)为低头(pitch_delta增大,pos向3950增大),门控须 pos < LOWER_LIMIT(3950) */
|
||||
if (dr16.rc_l_UD > 1050 && pos > PITCH_GM6020_POSITION_UPPER_LIMIT)
|
||||
pitch_delta -= GIMBAL_PITCH_LEVER_RATE / 8192.0f * 360.0f *
|
||||
((float)dr16.rc_l_UD - 1024.0f) / 660.0f;
|
||||
@@ -113,13 +113,13 @@ void robot_cmd_task(void const * argument)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 键鼠:同改为比例输出 */
|
||||
if (keyboard_data.mouse_du < -8 && pos > PITCH_GM6020_POSITION_UPPER_LIMIT)
|
||||
/* 键鼠:鼠标前推(>8)为抬头(pitch_delta减小),门控须 pos > UPPER_LIMIT;鼠标后拉(<-8)为低头(pitch_delta增大),门控须 pos < LOWER_LIMIT */
|
||||
if (keyboard_data.mouse_du > 8 && pos > PITCH_GM6020_POSITION_UPPER_LIMIT)
|
||||
pitch_delta -= GIMBAL_PITCH_LEVER_RATE / 8192.0f * 360.0f *
|
||||
(-(float)keyboard_data.mouse_du * PC_MOUSE_DU_SENSITIVITY) / 660.0f;
|
||||
else if (keyboard_data.mouse_du > 8 && pos < PITCH_GM6020_POSITION_LOWER_LIMIT)
|
||||
pitch_delta += GIMBAL_PITCH_LEVER_RATE / 8192.0f * 360.0f *
|
||||
((float)keyboard_data.mouse_du * PC_MOUSE_DU_SENSITIVITY) / 660.0f;
|
||||
else if (keyboard_data.mouse_du < -8 && pos < PITCH_GM6020_POSITION_LOWER_LIMIT)
|
||||
pitch_delta += GIMBAL_PITCH_LEVER_RATE / 8192.0f * 360.0f *
|
||||
(-(float)keyboard_data.mouse_du * PC_MOUSE_DU_SENSITIVITY) / 660.0f;
|
||||
|
||||
if (keyboard_data.mouse_rl != 0)
|
||||
yaw_delta -= GIMBAL_LEVER_SPEED_MAP_RATE * GIMBAL_YAW_PITCH_SPEED_RATE *
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* =============================================================================
|
||||
* shoot_task.c - 发射机构任务(2ms)
|
||||
* shoot_control() 计算摩擦轮/拨弹电流 -> shoot_send_cmd() 发 0x200;
|
||||
* 拨弹电流由云台任务与 Pitch 共帧发送;发射机构上电状态来自底盘 0x019
|
||||
* shoot_control() 计算摩擦轮/拨弹电流 -> shoot_send_cmd() 发 0x200(CAN1 摩擦轮 / CAN2 拨弹);
|
||||
* 发射机构上电状态来自底盘 0x019
|
||||
* ========================================================================== */
|
||||
#include "app_tasks.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
Reference in New Issue
Block a user