实现固定目标点的导航功能#3182
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 14, 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.
修改概述:
修改的详细描述
目标点配置:固定目标点设置为(8.0, 0.0),可通过修改TARGET_POS变量调整位置
导航逻辑:
实时计算机器人到目标点的距离和朝向误差
控制机器人始终朝向目标点移动
遇到障碍时避障,避障完成后回归导航路径
距离目标点小于 0.5 米时判定为到达,停止移动
可视化:模型中添加了红色球体作为目标点标记,直观可见
状态输出:实时打印剩余距离、朝向误差、障碍距离、动态障碍位置等信息
1.
2.
经过了什么样的测试?
运行效果
动图、视频、截图等
