镜像自地址
https://github.com/MINT-SJTU/Evo-RL.git
已同步 2026-11-20 18:17:06 +00:00
fix(piper): align follower flags and SDK dependency
这个提交包含在:
@ -34,8 +34,8 @@ class PiperFollowerConfigBase:
|
||||
log_level: str = "WARNING"
|
||||
startup_sleep_s: float = 0.1
|
||||
|
||||
# Optional role command on startup (0xFC = motion output arm)
|
||||
set_slave_mode_on_connect: bool = False
|
||||
# Optional role command on startup (0xFC = motion output/follower arm)
|
||||
set_follower_mode_on_connect: bool = False
|
||||
|
||||
# Motion mode for follower arm
|
||||
speed_ratio: int = 100
|
||||
|
||||
@ -85,7 +85,7 @@ class PiperFollower(Robot):
|
||||
|
||||
self._is_connected = True
|
||||
try:
|
||||
if self.config.set_slave_mode_on_connect:
|
||||
if self.config.set_follower_mode_on_connect:
|
||||
self.arm.MasterSlaveConfig(0xFC, 0x00, 0x00, 0x00)
|
||||
time.sleep(0.05)
|
||||
|
||||
|
||||
@ -16,10 +16,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
PIPER_JOINT_NAMES = (
|
||||
@ -41,72 +38,16 @@ def unit_to_milli(value: float | int) -> int:
|
||||
return int(round(float(value) * 1e3))
|
||||
|
||||
|
||||
def _iter_candidate_paths() -> list[Path]:
|
||||
repo_root = Path(__file__).resolve().parents[3]
|
||||
env_path = os.environ.get("PIPER_SDK_PATH")
|
||||
candidates: list[Path] = []
|
||||
if env_path:
|
||||
candidates.append(Path(env_path).expanduser())
|
||||
|
||||
candidates.extend(
|
||||
[
|
||||
Path.cwd(),
|
||||
repo_root,
|
||||
repo_root.parent,
|
||||
repo_root / "piper_sdk",
|
||||
repo_root.parent / "piper_sdk",
|
||||
]
|
||||
)
|
||||
return candidates
|
||||
|
||||
|
||||
def _add_path_if_matches(candidate: Path) -> bool:
|
||||
candidate = candidate.resolve()
|
||||
|
||||
package_dir = candidate / "piper_sdk"
|
||||
if package_dir.is_dir() and (package_dir / "__init__.py").is_file():
|
||||
parent = str(candidate)
|
||||
if parent not in sys.path:
|
||||
sys.path.insert(0, parent)
|
||||
return True
|
||||
|
||||
if candidate.name == "piper_sdk" and (candidate / "__init__.py").is_file():
|
||||
parent = str(candidate.parent)
|
||||
if parent not in sys.path:
|
||||
sys.path.insert(0, parent)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def get_piper_sdk() -> tuple[type[Any], Any]:
|
||||
try:
|
||||
from piper_sdk import C_PiperInterface_V2, LogLevel
|
||||
|
||||
return C_PiperInterface_V2, LogLevel
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
||||
searched_paths: list[str] = []
|
||||
for candidate in _iter_candidate_paths():
|
||||
searched_paths.append(str(candidate))
|
||||
if not candidate.exists():
|
||||
continue
|
||||
_add_path_if_matches(candidate)
|
||||
try:
|
||||
from piper_sdk import C_PiperInterface_V2, LogLevel
|
||||
|
||||
return C_PiperInterface_V2, LogLevel
|
||||
except ModuleNotFoundError:
|
||||
continue
|
||||
|
||||
searched = "\n- ".join(searched_paths)
|
||||
raise ModuleNotFoundError(
|
||||
"Could not import `piper_sdk`. Install it (for example: `pip install -e /path/to/piper_sdk`) "
|
||||
"or set PIPER_SDK_PATH. Searched paths:\n- "
|
||||
f"{searched}"
|
||||
)
|
||||
except ModuleNotFoundError as exc:
|
||||
raise ModuleNotFoundError(
|
||||
"Could not import `piper_sdk`. Install Evo-RL dependencies first (for example: `pip install -e .`)."
|
||||
) from exc
|
||||
|
||||
|
||||
def parse_piper_log_level(level_name: str) -> Any:
|
||||
|
||||
在新工单中引用
屏蔽一个用户