refactor: 哨兵分支整理目录结构,按功能归类(只搬家,程序不变)
基于战队 main 9de485e。两块板统一改为三层目录,Keil 工程分组与文件夹一一对应:
- App/ 本板业务,按功能分文件夹(system/ cmd/ comm/ referee/,
云台另有 gimbal/ shoot/ vision/,底盘另有 chassis/,含 hlj_pc、supercap)
- Lib/ 与业务无关的通用模块(algorithm/ motor/ imu/ sensor/ dev/),两板逐字节相同
- Bsp/ bsp_can、bsp_usart,不再分 Inc/Src
具体改动:
- 107 个文件全部 git mv(纯重命名,内容不变),文件名不变,#include 不用改
- .uvprojx:Application/Task、Modules、BSP 三个分组换成新分组,登记文件集合不变;
头文件路径换成新目录,CubeMX/第三方目录不动
- .uvoptx 分组同步,文件序号重新连续编号
- 根 README 和两块板 README 的路径、代码地图、模块清单同步更新(补 hlj_pc、supercap)
- 新增 doc/目录整理说明.md(新旧路径对照、验证方法、以后如何跟进步兵更新)
验证(整理前后同一编译器):
- 两块板 Program Size 完全相同
底盘 Code=111184 RO=1956 RW=432 ZI=62720
云台 Code=109876 RO=1960 RW=420 ZI=62764
- .map 符号表(名字/类型/大小/所在 .o)底盘 1155 个、云台 1156 个,逐条一致
未改动:Core/、Drivers/、Middlewares/、USB_DEVICE/、CubeMX 分组名与任务名、module_test/
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9de485e4ef
commit
4b75e4ec6e
115 files changed
+1200
-818
No files matched your search
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
*文件名称:debug_task.c
|
||||
*功能描述:USB虚拟串口(CDC)姿态与控制量遥测输出任务(底盘板)
|
||||
*备注:每DEBUG_OUT_PERIOD_MS输出一行欧拉角、姿态健康诊断与底盘控制模式
|
||||
*/
|
||||
#include "debug_task.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "usbd_cdc_if.h"
|
||||
#include "attitude.h"
|
||||
#include "ins.h"
|
||||
#include "bmi088.h"
|
||||
#include "robot_typedef.h"
|
||||
#include "c_comm.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define DEBUG_ATT_HEALTH 1 //1=输出健康位(cvg/rdy/imu/an/gn),0=仅欧拉角
|
||||
#define DEBUG_ATT_DIAG 1 //1=附加原始陀螺/零偏/采样计数,0=关闭
|
||||
#define DEBUG_CMD_OUT 1 //1=追加底盘控制量/模式,0=不追加
|
||||
#define DEBUG_OUT_PERIOD_MS 100//遥测输出周期(ms)
|
||||
|
||||
#if DEBUG_CMD_OUT
|
||||
/*
|
||||
*函数简介:将底盘控制模式枚举转换为可读字符串
|
||||
*参数说明:m:底盘控制模式枚举
|
||||
*返回类型:const char *:模式名称字符串
|
||||
*备注:仅用于遥测日志格式化
|
||||
*/
|
||||
static const char * cmd_mode_name(chassis_mode_e m)
|
||||
{
|
||||
switch (m)
|
||||
{
|
||||
case CHASSIS_MODE_OFF: return "OFF";
|
||||
case CHASSIS_MODE_MANUAL: return "MANUAL";
|
||||
case CHASSIS_MODE_FOLLOW: return "FOLLOW";
|
||||
case CHASSIS_MODE_SPIN_SLOW: return "SPIN_SLOW";
|
||||
case CHASSIS_MODE_SPIN_FAST: return "SPIN_FAST";
|
||||
default: return "?";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*函数简介:USB虚拟串口遥测输出任务
|
||||
*参数说明:argument:FreeRTOS任务参数(未使用)
|
||||
*返回类型:无
|
||||
*备注:无
|
||||
*/
|
||||
void debug_task(void const * argument)
|
||||
{
|
||||
(void)argument;
|
||||
|
||||
char line[448];
|
||||
char tail[112];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const float an = sqrtf(bmi088_accel[0] * bmi088_accel[0] +
|
||||
bmi088_accel[1] * bmi088_accel[1] +
|
||||
bmi088_accel[2] * bmi088_accel[2]);
|
||||
const float gn = sqrtf(bmi088_gyro[0] * bmi088_gyro[0] +
|
||||
bmi088_gyro[1] * bmi088_gyro[1] +
|
||||
bmi088_gyro[2] * bmi088_gyro[2]);
|
||||
|
||||
tail[0] = '\0';
|
||||
#if DEBUG_ATT_HEALTH && DEBUG_ATT_DIAG
|
||||
snprintf(tail, sizeof(tail),
|
||||
" gx=%.4f gy=%.4f gz=%.4f zo=%.4f ck=%u ca=%lu cg=%lu se=%lu st=%u",
|
||||
bmi088_gyro[0], bmi088_gyro[1], bmi088_gyro[2],
|
||||
ins_gyro_z_offset, (unsigned)ins_z_cal_ok,
|
||||
(unsigned long)bmi088_accel_cnt, (unsigned long)bmi088_gyro_cnt,
|
||||
(unsigned long)bmi088_spi_errors, (unsigned)bmi088_spi_state());
|
||||
#endif
|
||||
|
||||
#if DEBUG_CMD_OUT
|
||||
char ctl[192];
|
||||
snprintf(ctl, sizeof(ctl),
|
||||
" mode=%s online=%u vx=%.3f vy=%.3f wz=%.3f spin=%u s2=%u reset=%u",
|
||||
cmd_mode_name(cmd_robot.chassis_mode),
|
||||
(unsigned)cmd_robot.online,
|
||||
cmd_robot.vx, cmd_robot.vy, cmd_robot.wz_manual,
|
||||
(unsigned)ctoc_remote.spin_flag,
|
||||
(unsigned)ctoc_remote.s2,
|
||||
(unsigned)cmd_robot.gimbal_reset);
|
||||
#else
|
||||
const char * ctl = "";
|
||||
#endif
|
||||
|
||||
#if DEBUG_ATT_HEALTH
|
||||
int len = snprintf(line, sizeof(line),
|
||||
"yaw=%.2f pitch=%.2f roll=%.2f cvg=%u rdy=%u imu=%u an=%.2f gn=%.3f%s%s\r\n",
|
||||
att_deg_yaw, att_deg_pitch, att_deg_roll,
|
||||
(unsigned)INS.ConvergeFlag, (unsigned)att_ready,
|
||||
(unsigned)bmi088_online, an, gn, tail, ctl);
|
||||
#else
|
||||
int len = snprintf(line, sizeof(line), "yaw=%.2f pitch=%.2f roll=%.2f%s\r\n",
|
||||
att_deg_yaw, att_deg_pitch, att_deg_roll, ctl);
|
||||
#endif
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
uint16_t tx_len = (len < (int)sizeof(line)) ? (uint16_t)len : (uint16_t)(sizeof(line) - 1U);
|
||||
CDC_Transmit_FS((uint8_t *)line, tx_len);
|
||||
}
|
||||
|
||||
osDelay(DEBUG_OUT_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user