feat: refactor project structure and update dependencies

- Rename app_ui.py to main.py for better naming convention
- Update balance.py import to use dm_imu_pkg.dm_imu_py for modularity
- Constrain Gradio version to <5.0 in pyproject.toml and <6.0 in PKG-INFO for compatibility
- Add compiled .so file for dm_imu_pkg and update cached .pyc files after builds
- Include motors_enabled flag in main.py UI for better state management

These changes improve code organization, resolve potential import issues, and ensure dependency compatibility in the balance controller project.
This commit is contained in:
2025-12-09 22:55:35 +08:00
parent 8c76cf23a7
commit f8d12a8348
11 changed files with 10 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -1,5 +1,5 @@
import time
import imu_py
from dm_imu_pkg import imu_py
from Legs_controller import LegsController
class BalanceController:

View File

@@ -13,7 +13,7 @@ License-File: LICENSE
Requires-Dist: pybind11>=2.10
Requires-Dist: numpy<2.0
Requires-Dist: pyserial>=3.5
Requires-Dist: gradio
Requires-Dist: gradio<5.0
Dynamic: author
Dynamic: license-file
Dynamic: requires-python

View File

@@ -1,4 +1,4 @@
pybind11>=2.10
numpy<2.0
pyserial>=3.5
gradio
gradio<5.0

Binary file not shown.

View File

@@ -27,6 +27,7 @@ def log(msg: str) -> None:
# 全局状态
# -------------------------------------------------
controller: BalanceController | None = None # 单例
motors_enabled = False # 电机使能状态
# -------------------------------------------------
# 安全创建 BalanceController带重试
@@ -202,9 +203,9 @@ with gr.Blocks() as demo:
start_btn = gr.Button("▶️ 启动平衡控制")
status_box = gr.Textbox(label="状态", value=init_status, interactive=False)
enable_btn.click(fn=enable_all, inputs=None, outputs=[status_box, log_box])
disable_btn.click(fn=disable_all, inputs=None, outputs=[status_box, log_box])
start_btn.click(fn=start_balance, inputs=None, outputs=[status_box, log_box])
enable_btn.click(fn=enable_all, inputs=None, outputs=[status_box, log_box])
disable_btn.click(fn=disable_all, inputs=None, outputs=[status_box, log_box])
start_btn.click(fn=start_balance, inputs=None, outputs=[status_box, log_box])
# 中间:位置控制
with gr.Column():

View File

@@ -14,7 +14,7 @@ dependencies = [
"pybind11>=2.10",
"numpy<2.0",
"pyserial>=3.5",
"gradio",
"gradio<6.0",
]
classifiers = [
"Programming Language :: Python :: 3",

2
ui.log Normal file
View File

@@ -0,0 +1,2 @@
2025-12-09 22:02:40,904 - INFO - 尝试创建 BalanceController第 1 次)
2025-12-09 22:03:37,277 - INFO - 尝试创建 BalanceController第 1 次)