增加调试功能,以及yaw补偿
This commit is contained in:
1 parent
267a659242
commit
957c535bda
257 files changed
+239436
-692
No files matched your search
@@ -0,0 +1,57 @@
|
||||
/* =============================================================================
|
||||
* debug_task.c - USB 虚拟串口(CDC)FireWater 输出(精简版)
|
||||
*
|
||||
* 200Hz 输出 4 通道 CSV(逗号分隔 + 换行,VOFA+ 选 FireWater 协议):
|
||||
* 1) mt_power_est 功率模型估计输入功率 (W,带符号;回馈时为负)
|
||||
* 2) mt_target_out 目标值(正弦/速度模式=线速度 m/s;电流模式=目标电流 A;
|
||||
* 拨弹/摩擦轮模式=目标转速 RPM)
|
||||
* 3) 实测速度 默认线速度 m/s(MT_SPEED_OUT_MPS=0 时为转子转速 RPM;
|
||||
* 摩擦轮模式固定为转子转速 RPM)
|
||||
* 4) 电机反馈转矩电流编码值(counts,±16384 ↔ 满量程;反馈值,未滤波)
|
||||
*
|
||||
* 其余诊断量不占通道,用调试器 Watch:
|
||||
* mt_current_a / mt_power_mech / mt_power_loss
|
||||
* mt_pid_out / mt_ff_cmd / mt_cmd_limited / mt_ref_alpha
|
||||
* mt_state(0=IDLE 1=RUN 2=PROTECT) / mt_fault(0无 1电流硬限 2堵转 3过温 4遥控离线)
|
||||
*
|
||||
* MT_POWER_OUT=0 时退回旧的 4 通道(实测电流/实测转速/下发指令/温度)。
|
||||
* 已移除:姿态/IMU/控制量汇总等整车遥测。
|
||||
* ========================================================================== */
|
||||
#include "app_tasks.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "usbd_cdc_if.h"
|
||||
#include "module_test.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void debug_task(void const * argument)
|
||||
{
|
||||
char line[96];
|
||||
|
||||
(void)argument;
|
||||
|
||||
while (!app_ready)
|
||||
osDelay(10);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
#if MT_POWER_OUT
|
||||
/* 通道3 实测速度:默认 m/s(与 MT_TARGET_MPS_OUT 同口径),可切换为转子 RPM;
|
||||
* 摩擦轮模式固定 RPM(摩擦轮不是麦轮,m/s 换算无意义,与通道2 同口径) */
|
||||
#if (MT_MODE == MT_MODE_FRICTION)
|
||||
const float speed_out = mt_speed_rpm;
|
||||
#else
|
||||
const float speed_out = MT_SPEED_OUT_MPS ? mt_speed_mps : mt_speed_rpm;
|
||||
#endif
|
||||
int len = snprintf(line, sizeof(line), "%.2f,%.3f,%.2f,%d\n",
|
||||
mt_power_est, mt_target_out, speed_out, (int)mt_current_cnt);
|
||||
#else
|
||||
int len = snprintf(line, sizeof(line), "%.3f,%.1f,%.1f,%.1f\n",
|
||||
mt_current_a, mt_speed_rpm, mt_out_cmd, mt_temperature);
|
||||
#endif
|
||||
if (len > 0)
|
||||
CDC_Transmit_FS((uint8_t *)line, (uint16_t)len);
|
||||
|
||||
monitor_heartbeat(HB_DEBUG);
|
||||
osDelay(MT_DEBUG_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user