docs: 对齐 build/bin 布局、日志自动落盘、env_common 探测库与 tools 精简
This commit is contained in:
1 parent
0843c6ade0
commit
3c58a08dad
47 files changed
+1063
-2009
No files matched your search
+63
-3
@@ -11,6 +11,7 @@
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@@ -30,12 +31,19 @@ from tf2_ros import Buffer, TransformListener
|
||||
|
||||
|
||||
# 期望处于 ACTIVE 的节点(缺了哪个,导航就会缺一块能力)
|
||||
#
|
||||
# ⚠️ amcl 必须在这个列表里:它不发 /map,但 **map_server 的激活与否看不出定位好坏**。
|
||||
# 曾经漏掉它,结果 map_server 卡在 inactive、amcl 压根没配起来,而这个脚本
|
||||
# 只报了 7 个节点的状态 —— 一眼看不出问题其实出在定位那一组。
|
||||
EXPECTED_ACTIVE = [
|
||||
'map_server',
|
||||
'amcl',
|
||||
'controller_server',
|
||||
'planner_server',
|
||||
'smoother_server',
|
||||
'bt_navigator',
|
||||
'behavior_server',
|
||||
'waypoint_follower',
|
||||
'velocity_smoother',
|
||||
'collision_monitor',
|
||||
]
|
||||
@@ -60,7 +68,7 @@ def parse_gz_pose(out):
|
||||
Model: [52]
|
||||
- Name: sentry
|
||||
- Pose [ XYZ (m) ] [ RPY (rad) ]:
|
||||
[0.900000 4.000000 0.000000]
|
||||
[-5.000000 3.000000 0.000000]
|
||||
[0.000000 -0.000000 0.000000]
|
||||
|
||||
注意标签本身就带两个方括号(`[ XYZ (m) ]` `[ RPY (rad) ]`),
|
||||
@@ -89,6 +97,26 @@ def parse_gz_pose(out):
|
||||
return None
|
||||
|
||||
|
||||
def _gz_bin():
|
||||
"""返回 gz 可执行文件路径(系统安装的那个),找不到返回 None。
|
||||
|
||||
不写死 `/usr/bin/gz`:换台机器 gz 可能装在别处。
|
||||
优先用 tools/project_env.py 的统一探测逻辑(同样支持 GZ_BIN 覆盖)。
|
||||
"""
|
||||
try:
|
||||
import project_env # noqa: PLC0415 (同目录模块,按需导入)
|
||||
gz = project_env.find_gz_bin()
|
||||
if gz is not None:
|
||||
return gz
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
for cand in ('/usr/bin/gz', '/usr/local/bin/gz'):
|
||||
if os.access(cand, os.X_OK):
|
||||
return cand
|
||||
return shutil.which('gz')
|
||||
|
||||
|
||||
def gz_model_pose(model_name):
|
||||
"""从 Gazebo 读模型的世界位姿,返回 (x, y, z, roll, pitch, yaw) 或 None。
|
||||
|
||||
@@ -104,9 +132,12 @@ def gz_model_pose(model_name):
|
||||
env = dict(os.environ)
|
||||
env['GZ_PARTITION'] = partition
|
||||
# 必须用系统版 gz 并清掉 LD_LIBRARY_PATH,否则会加载 ROS vendor 的库,
|
||||
# 和服务端(系统版 10.6)不是同一套
|
||||
# 和服务端不是同一套。
|
||||
env.pop('LD_LIBRARY_PATH', None)
|
||||
cmd = ['/usr/bin/gz', 'model', '-m', model_name, '-p']
|
||||
gz_bin = _gz_bin()
|
||||
if gz_bin is None:
|
||||
return None
|
||||
cmd = [str(gz_bin), 'model', '-m', model_name, '-p']
|
||||
try:
|
||||
out = subprocess.run(cmd, env=env, capture_output=True, text=True,
|
||||
timeout=10).stdout
|
||||
@@ -146,6 +177,35 @@ def main():
|
||||
print(' %-20s ⚠️ %s' % (name, st.label))
|
||||
problems.append(f'{name} 是 {st.label},不是 ACTIVE')
|
||||
|
||||
# ---------- 1.5 节点总览:定位"卡在谁身上" ----------
|
||||
# 光看生命周期状态不够 —— 如果某个节点**压根没起来**,
|
||||
# 上面只会说"服务不存在",看不出是谁没被编排。这里把家底列出来。
|
||||
print('\n=== 1.5 节点总览(生命周期管理器在不在)===')
|
||||
try:
|
||||
names = sorted(set(node.get_node_names()))
|
||||
except Exception: # noqa: BLE001
|
||||
names = []
|
||||
if names:
|
||||
lms = [n for n in names if 'lifecycle_manager' in n]
|
||||
print(f' 节点总数: {len(names)}')
|
||||
if lms:
|
||||
print(f' 生命周期管理器: {", ".join(lms)}')
|
||||
else:
|
||||
print(' 生命周期管理器: ❌ 一个都没有(Nav2 不会自己配置)')
|
||||
problems.append('没有 lifecycle_manager 在跑')
|
||||
missing = [n for n in EXPECTED_ACTIVE if n not in names]
|
||||
if missing:
|
||||
print(f' ⚠️ 期望存在但没起: {", ".join(missing)}')
|
||||
for n in missing:
|
||||
problems.append(f'{n} 没在跑')
|
||||
extra = [n for n in names
|
||||
if any(k in n for k in ('amcl', 'server', 'navigator', 'manager'))
|
||||
and n not in EXPECTED_ACTIVE and 'lifecycle_manager' not in n]
|
||||
if extra:
|
||||
print(f' 其他相关节点: {", ".join(extra)}')
|
||||
else:
|
||||
print(' ⚠️ 一个节点都没发现 —— DDS 发现可能有问题')
|
||||
|
||||
# ---------- 2. 话题有没有数据 ----------
|
||||
print('\n=== 2. 话题数据(各收 1 条,最多 8 秒)===')
|
||||
seen = {}
|
||||
|
||||
Reference in new issue
Block a user