Skip to content

Conversation

mengdeqi12
Copy link
Contributor

No description provided.

1. 核心修改:在 main.py 头部新增自动切换工作目录逻辑
   - 通过 os.path 获取脚本绝对路径,计算并切换到项目根目录(D:\pycharm\nn2)
   - 统一相对路径基准,避免因运行目录不同导致的路径错误

2. 增强鲁棒性:
   - 新增模型路径存在性检查,提前捕获「文件不存在」错误并给出明确提示
   - 路径使用正斜杠(/)替代反斜杠(\),保证 Windows/macOS/Linux 跨平台兼容性
   - 打印日志增加 [INFO]/[SUCCESS]/[ERROR] 前缀,便于调试定位问题

3. 解决的核心问题:
   - 原版代码因相对路径基准不统一,频繁出现「No such file or directory」错误
   - 无需手动修改模型路径,支持从任意目录运行 main.py 仍能正常加载 humanoid.xml

修改文件:src/humanoid_motion_control/main.py
1. 核心修改:在 main.py 头部新增自动切换工作目录逻辑
   - 通过 os.path 获取脚本绝对路径,计算并切换到项目根目录(D:\pycharm\nn2)
   - 统一相对路径基准,避免因运行目录不同导致的路径错误

2. 增强鲁棒性:
   - 新增模型路径存在性检查,提前捕获「文件不存在」错误并给出明确提示
   - 路径使用正斜杠(/)替代反斜杠(\),保证 Windows/macOS/Linux 跨平台兼容性
   - 打印日志增加 [INFO]/[SUCCESS]/[ERROR] 前缀,便于调试定位问题

3. 解决的核心问题:
   - 原版代码因相对路径基准不统一,频繁出现「No such file or directory」错误
   - 无需手动修改模型路径,支持从任意目录运行 main.py 仍能正常加载 humanoid.xml

修改文件:src/humanoid_motion_control/main.py
1. 核心修改:在 main.py 头部新增自动切换工作目录逻辑
   - 通过 os.path 获取脚本绝对路径,计算并切换到项目根目录(D:\pycharm\nn2)
   - 统一相对路径基准,避免因运行目录不同导致的路径错误

2. 增强鲁棒性:
   - 新增模型路径存在性检查,提前捕获「文件不存在」错误并给出明确提示
   - 路径使用正斜杠(/)替代反斜杠(\),保证 Windows/macOS/Linux 跨平台兼容性
   - 打印日志增加 [INFO]/[SUCCESS]/[ERROR] 前缀,便于调试定位问题

3. 解决的核心问题:
   - 原版代码因相对路径基准不统一,频繁出现「No such file or directory」错误
   - 无需手动修改模型路径,支持从任意目录运行 main.py 仍能正常加载 humanoid.xml

修改文件:src/humanoid_motion_control/main.py
@mengdeqi12 mengdeqi12 changed the title 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题; 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题;添加一个main.py的例子代码 Sep 29, 2025
@donghaiwang

This comment was marked as resolved.

tatus Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件是git日志文件,需要删除

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@donghaiwang donghaiwang requested a review from qiqi678 September 29, 2025 03:31
@donghaiwang
Copy link
Member

同时修改了三个模块中的内容,需要其他模块开发同学同意

@mengdeqi12 mengdeqi12 changed the title 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题;添加一个main.py的例子代码 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题;添加一个main.py的例子代码;已删除git 日志文件 Sep 29, 2025
@donghaiwang
Copy link
Member

根目录下的tatus还未删除

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果没有内容,这个文件就不需要添加

@donghaiwang donghaiwang merged commit cf330a8 into OpenHUTB:main Oct 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants