增加调试功能,以及yaw补偿

This commit is contained in:
lyf committed 2026-11-18 16:05:46 +08:00
1 parent 267a659242
commit 957c535bda
257 files changed
+239436 -692

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
"""修复 module_test 的 uvprojx:通过 ASCII junction(chassis_algo)引用 Simba 底盘
下的同一份 pid.c / dji_motor.c / robot_param.h。
说明:µVision 对含中文的 include 路径支持不稳定,因此在 Simba 根目录建立
junction: Simba-OmniInfantry/chassis_algo -> Simba-OmniInfantry/底盘
本脚本只写 ASCII 路径。运行前需先创建 junction(见 tools/link_chassis_algo.ps1)。
"""
import re
P = r'E:\ELCT\Simba-OmniInfinity\module_test\MDK-ARM\Simba-ELCT-FrameWork.uvprojx'
P = r'E:\ELCT\Simba-OmniInfantry\module_test\MDK-ARM\Simba-ELCT-FrameWork.uvprojx'
LINK = r'..\..\chassis_algo'
CH = '\u5e95\u76d8' # 底盘
s = open(P, encoding='utf-8', errors='replace').read()
# 1) 源文件路径
def fix_file(m):
body = m.group(0)
fp = re.search(r'<FilePath>(.*?)</FilePath>', body, re.S)
if not fp:
return body
path = fp.group(1)
low = path.lower()
if low.endswith(r'\pid.c') and 'algorithm' in low:
path = LINK + r'\modules\algorithm\pid.c'
elif low.endswith(r'\dji_motor.c'):
path = LINK + r'\modules\motor\dji_motor.c'
else:
return body
return body[:fp.start(1)] + path + body[fp.end(1):]
s = re.sub(r'<File>.*?</File>', fix_file, s, flags=re.S)
# 2) IncludePath:清洗 + 去重 + 追加 ASCII junction 路径
def fix_inc(m):
toks = [t for t in m.group(1).split(';') if t]
clean = []
for t in toks:
if '\ufffd' in t or CH in t:
continue
n = t.replace('/', '\\').lower()
if n in (r'..\modules\algorithm', r'..\modules\motor'):
continue
if t not in clean:
clean.append(t)
out = []
added = False
for t in clean:
out.append(t)
if t.replace('/', '\\').lower() == r'..\application\task\inc' and not added:
out.append(LINK + r'\Application')
out.append(LINK + r'\modules\algorithm')
out.append(LINK + r'\modules\motor')
added = True
return '<IncludePath>' + ';'.join(out) + '</IncludePath>'
s = re.sub(r'<IncludePath>(.*?)</IncludePath>', fix_inc, s, flags=re.S)
open(P, 'w', encoding='utf-8', newline='').write(s)
# 验证
s2 = open(P, encoding='utf-8').read()
print('replacement chars:', s2.count('\ufffd'))
print('chassis_algo count:', s2.count('chassis_algo'))
for i, m in enumerate(re.finditer(r'<IncludePath>(.*?)</IncludePath>', s2, re.S)):
toks = [t for t in m.group(1).split(';') if 'chassis_algo' in t]
if toks:
print('INC', i, ':', toks)
for m in re.findall(r'<FilePath>(.*?)</FilePath>', s2):
if 'chassis_algo' in m:
print('FILE:', m)