Update 2026-04-22 11:53:06
This commit is contained in:
parent
5b8e94f42e
commit
9ac3e19ed1
@ -64,6 +64,28 @@ def slam_worker(
|
||||
loc_cfg: LocalizationConfig,
|
||||
run_cfg: RuntimeConfig,
|
||||
):
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
# Redirect this subprocess's stderr to logs/lidar_sdk.log. The Livox
|
||||
# C++ SDK prints directly to stderr (not Python logging) and spams
|
||||
# thousands of lines/second when the LiDAR is offline or flaky. Keeping
|
||||
# it in a file lets us still debug Livox issues without the errors
|
||||
# drowning the interactive terminal. stdout stays attached so our own
|
||||
# Python `print`s (pose updates, status lines) still reach the terminal.
|
||||
# ─────────────────────────────────────────────────────────────────────
|
||||
import os as _os, sys as _sys
|
||||
try:
|
||||
_log_dir = _os.path.join(
|
||||
_os.path.dirname(_os.path.dirname(_os.path.abspath(__file__))),
|
||||
"logs",
|
||||
)
|
||||
_os.makedirs(_log_dir, exist_ok=True)
|
||||
_err_path = _os.path.join(_log_dir, "lidar_sdk.log")
|
||||
_fd = _os.open(_err_path, _os.O_WRONLY | _os.O_CREAT | _os.O_APPEND, 0o644)
|
||||
_os.dup2(_fd, 2) # replace stderr FD so even C++ libs are captured
|
||||
_sys.stderr = _os.fdopen(2, "w", buffering=1)
|
||||
except Exception:
|
||||
pass # never crash just because the log redirect failed
|
||||
|
||||
# suppress noisy warning from ctypes->numpy conversion
|
||||
import warnings
|
||||
warnings.filterwarnings(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user