Update teleop features & naming

This commit is contained in:
Simon Alibert
2025-05-08 12:51:09 +02:00
parent 87a8cb6d89
commit 293870d0f6
14 changed files with 31 additions and 36 deletions

View File

@@ -1,4 +1,3 @@
from .config import TeleoperatorConfig
from .teleoperator import Teleoperator
__all__ = ["TeleoperatorConfig", "Teleoperator"]
from .utils import make_teleoperator_from_config

View File

@@ -61,12 +61,15 @@ class KeyboardTeleop(Teleoperator):
self.logs = {}
@property
def action_feature(self) -> dict:
# TODO(Steven): Change this when we agree what should this return
...
def action_features(self) -> dict:
return {
"dtype": "float32",
"shape": (len(self.arm),),
"names": {"motors": list(self.arm.motors)},
}
@property
def feedback_feature(self) -> dict:
def feedback_features(self) -> dict:
return {}
@property

View File

@@ -58,15 +58,11 @@ class KochLeader(Teleoperator):
)
@property
def action_feature(self) -> dict:
return {
"dtype": "float32",
"shape": (len(self.arm),),
"names": {"motors": list(self.arm.motors)},
}
def action_features(self) -> dict[str, type]:
return {f"{motor}.pos": float for motor in self.arm.motors}
@property
def feedback_feature(self) -> dict:
def feedback_features(self) -> dict[str, type]:
return {}
@property
@@ -158,6 +154,7 @@ class KochLeader(Teleoperator):
start = time.perf_counter()
action = self.arm.sync_read("Present_Position")
action = {f"{motor}.pos": val for motor, val in action.items()}
dt_ms = (time.perf_counter() - start) * 1e3
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
return action

View File

@@ -55,15 +55,11 @@ class SO100Leader(Teleoperator):
)
@property
def action_feature(self) -> dict:
return {
"dtype": "float32",
"shape": (len(self.arm),),
"names": {"motors": list(self.arm.motors)},
}
def action_features(self) -> dict[str, type]:
return {f"{motor}.pos": float for motor in self.arm.motors}
@property
def feedback_feature(self) -> dict:
def feedback_features(self) -> dict[str, type]:
return {}
@property
@@ -133,6 +129,7 @@ class SO100Leader(Teleoperator):
def get_action(self) -> dict[str, float]:
start = time.perf_counter()
action = self.arm.sync_read("Present_Position")
action = {f"{motor}.pos": val for motor, val in action.items()}
dt_ms = (time.perf_counter() - start) * 1e3
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
return action

View File

@@ -1,4 +0,0 @@
from .configuration_stretch3 import Stretch3GamePadConfig
from .teleop_stretch3 import Stretch3GamePad
__all__ = ["Stretch3GamePadConfig", "Stretch3GamePad"]

View File

@@ -0,0 +1,2 @@
from .configuration_stretch3 import Stretch3GamePadConfig
from .stretch3_gamepad import Stretch3GamePad

View File

@@ -73,7 +73,7 @@ class Stretch3GamePad(Teleoperator):
RobotParams.set_logging_formatter("brief_console_formatter")
@property
def action_feature(self) -> dict:
def action_features(self) -> dict:
return {
"dtype": "float32",
"shape": (len(GAMEPAD_BUTTONS),),
@@ -81,7 +81,7 @@ class Stretch3GamePad(Teleoperator):
}
@property
def feedback_feature(self) -> dict:
def feedback_features(self) -> dict:
return {}
def connect(self) -> None:

View File

@@ -34,11 +34,11 @@ class Teleoperator(abc.ABC):
return f"{self.id} {self.__class__.__name__}"
@abc.abstractproperty
def action_feature(self) -> dict:
def action_features(self) -> dict:
pass
@abc.abstractproperty
def feedback_feature(self) -> dict:
def feedback_features(self) -> dict:
pass
@abc.abstractproperty

View File

@@ -58,15 +58,11 @@ class WidowX(Teleoperator):
)
@property
def action_feature(self) -> dict:
return {
"dtype": "float32",
"shape": (len(self.arm),),
"names": {"motors": list(self.arm.motors)},
}
def action_features(self) -> dict[str, type]:
return {f"{motor}.pos": float for motor in self.arm.motors}
@property
def feedback_feature(self) -> dict:
def feedback_features(self) -> dict[str, type]:
return {}
@property
@@ -84,6 +80,10 @@ class WidowX(Teleoperator):
self.configure()
logger.info(f"{self} connected.")
@property
def is_calibrated(self) -> bool:
return self.arm.is_calibrated
def calibrate(self) -> None:
raise NotImplementedError # TODO(aliberts): adapt code below (copied from koch)
logger.info(f"\nRunning calibration of {self}")
@@ -137,7 +137,8 @@ class WidowX(Teleoperator):
raise DeviceNotConnectedError(f"{self} is not connected.")
start = time.perf_counter()
action = self.arm.read("Present_Position")
action = self.arm.sync_read("Present_Position")
action = {f"{motor}.pos": val for motor, val in action.items()}
dt_ms = (time.perf_counter() - start) * 1e3
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
return action