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
@@ -44,6 +44,7 @@
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
@@ -67,21 +68,29 @@ from launch_ros.parameter_descriptions import ParameterValue
|
||||
# ---------------------------------------------------------------------------
|
||||
PKG_SHARE = Path(__file__).resolve().parents[1] # src/sentry_sim
|
||||
WS = Path(__file__).resolve().parents[3] # 仓库根
|
||||
BIN_DIR = WS / 'build' / 'linux' / 'x86_64' / 'release' # xmake 产物
|
||||
SCRIPTS = PKG_SHARE / 'scripts'
|
||||
|
||||
# 场地迁移包:优先用仓库自带的 field/,没有才退回本机旧路径
|
||||
_FIELD_IN_REPO = WS / 'field' / 'RMUL2027_map_transfer_20261016_STEP_R1'
|
||||
_FIELD_FALLBACK = (Path.home() / 'Gazebo_projects' /
|
||||
'RMUL2027_map_transfer_20261016_STEP_R1')
|
||||
DEFAULT_FIELD_ROOT = os.environ.get(
|
||||
'SENTRY_FIELD_ROOT',
|
||||
str(_FIELD_IN_REPO if _FIELD_IN_REPO.is_dir() else _FIELD_FALLBACK))
|
||||
# 可移植探测:xmake 产物目录 / 场地包 / 地图 / gz 版本,一个都不写死。
|
||||
# 规则与 `scripts/env_common.sh` 完全一致(同样支持 SENTRY_BIN_DIR、
|
||||
# SENTRY_FIELD_ROOT、SENTRY_MAP_YAML、GZ_BIN、GZ_FORCE_VERSION 覆盖)。
|
||||
# `tools/` 不是 Python 包(本工程不用 ament),所以直接把目录塞进 sys.path。
|
||||
if str(WS / 'tools') not in sys.path:
|
||||
sys.path.insert(0, str(WS / 'tools'))
|
||||
import project_env # noqa: E402 (必须在 sys.path 调整之后导入)
|
||||
|
||||
DEFAULT_MAP_YAML = os.environ.get(
|
||||
'SENTRY_MAP_YAML',
|
||||
str(Path(DEFAULT_FIELD_ROOT) / 'src' / 'guodong_sentry_sim' / 'maps' /
|
||||
'rmul_2027' / 'rmul_2027.yaml'))
|
||||
BIN_DIR = project_env.find_bin_dir(WS)
|
||||
GZ_VERSION_ARGS = project_env.gz_version_args()
|
||||
|
||||
_FIELD_ROOT = project_env.find_field_root(WS)
|
||||
if _FIELD_ROOT is None:
|
||||
raise RuntimeError(
|
||||
'找不到场地迁移包。设 SENTRY_FIELD_ROOT=<含 src/guodong_sentry_sim 的目录>。')
|
||||
DEFAULT_FIELD_ROOT = str(_FIELD_ROOT)
|
||||
|
||||
_MAP_YAML = project_env.find_map_yaml(_FIELD_ROOT)
|
||||
if _MAP_YAML is None:
|
||||
raise RuntimeError(f'{_FIELD_ROOT} 下找不到任何栅格图 yaml。设 SENTRY_MAP_YAML=<路径>。')
|
||||
DEFAULT_MAP_YAML = str(_MAP_YAML)
|
||||
|
||||
|
||||
def _robot_description():
|
||||
@@ -165,7 +174,7 @@ def generate_launch_description():
|
||||
# (报 "The following arguments were not expected: xxx.sdf /")。
|
||||
ExecuteProcess(
|
||||
cmd=[str(SCRIPTS / 'run_gz.sh'), 'sim', '-r',
|
||||
'--force-version', '10',
|
||||
*GZ_VERSION_ARGS,
|
||||
PathJoinSubstitution([str(PKG_SHARE / 'worlds'), world])],
|
||||
name='gazebo',
|
||||
output='screen',
|
||||
@@ -177,7 +186,7 @@ def generate_launch_description():
|
||||
# 表面上一切正常,实际整条数据链是死的。
|
||||
ExecuteProcess(
|
||||
cmd=[str(SCRIPTS / 'run_gz.sh'), 'sim', '-s', '-r',
|
||||
'--force-version', '10',
|
||||
*GZ_VERSION_ARGS,
|
||||
PathJoinSubstitution([str(PKG_SHARE / 'worlds'), world])],
|
||||
name='gazebo',
|
||||
output='screen',
|
||||
|
||||
Reference in new issue
Block a user