Repository navigation
初始状态中机器人的世界坐标被错误设置,导致模型在空间中位置异常,解决该异常 - #4466
Merged
Merged
Conversation
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
donghaiwang
approved these changes
Dec 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改概述:
修改的详细描述
核心问题定位:
之前的_set_initial_pose函数中,躯干关节 ID 获取错误,导致机器人初始位置被设置到了仿真空间的 “远处”(或被缩放到极小),视觉上呈现 “一闪而过” 后消失。
修改方案:
强制将机器人初始位置固定在世界坐标系原点(x=0, y=0, z=0.8),并锁定模型缩放
经过了什么样的测试?
运行效果
动图、视频、截图等

同学电脑上显示的问题效果图