Update teleop features & naming
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
from .config import TeleoperatorConfig
|
from .config import TeleoperatorConfig
|
||||||
from .teleoperator import Teleoperator
|
from .teleoperator import Teleoperator
|
||||||
|
from .utils import make_teleoperator_from_config
|
||||||
__all__ = ["TeleoperatorConfig", "Teleoperator"]
|
|
||||||
|
|||||||
@@ -61,12 +61,15 @@ class KeyboardTeleop(Teleoperator):
|
|||||||
self.logs = {}
|
self.logs = {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_feature(self) -> dict:
|
def action_features(self) -> dict:
|
||||||
# TODO(Steven): Change this when we agree what should this return
|
return {
|
||||||
...
|
"dtype": "float32",
|
||||||
|
"shape": (len(self.arm),),
|
||||||
|
"names": {"motors": list(self.arm.motors)},
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def feedback_feature(self) -> dict:
|
def feedback_features(self) -> dict:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -58,15 +58,11 @@ class KochLeader(Teleoperator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_feature(self) -> dict:
|
def action_features(self) -> dict[str, type]:
|
||||||
return {
|
return {f"{motor}.pos": float for motor in self.arm.motors}
|
||||||
"dtype": "float32",
|
|
||||||
"shape": (len(self.arm),),
|
|
||||||
"names": {"motors": list(self.arm.motors)},
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def feedback_feature(self) -> dict:
|
def feedback_features(self) -> dict[str, type]:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -158,6 +154,7 @@ class KochLeader(Teleoperator):
|
|||||||
|
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
action = self.arm.sync_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
|
dt_ms = (time.perf_counter() - start) * 1e3
|
||||||
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
||||||
return action
|
return action
|
||||||
@@ -55,15 +55,11 @@ class SO100Leader(Teleoperator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_feature(self) -> dict:
|
def action_features(self) -> dict[str, type]:
|
||||||
return {
|
return {f"{motor}.pos": float for motor in self.arm.motors}
|
||||||
"dtype": "float32",
|
|
||||||
"shape": (len(self.arm),),
|
|
||||||
"names": {"motors": list(self.arm.motors)},
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def feedback_feature(self) -> dict:
|
def feedback_features(self) -> dict[str, type]:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -133,6 +129,7 @@ class SO100Leader(Teleoperator):
|
|||||||
def get_action(self) -> dict[str, float]:
|
def get_action(self) -> dict[str, float]:
|
||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
action = self.arm.sync_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
|
dt_ms = (time.perf_counter() - start) * 1e3
|
||||||
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
||||||
return action
|
return action
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
from .configuration_stretch3 import Stretch3GamePadConfig
|
|
||||||
from .teleop_stretch3 import Stretch3GamePad
|
|
||||||
|
|
||||||
__all__ = ["Stretch3GamePadConfig", "Stretch3GamePad"]
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
from .configuration_stretch3 import Stretch3GamePadConfig
|
||||||
|
from .stretch3_gamepad import Stretch3GamePad
|
||||||
@@ -73,7 +73,7 @@ class Stretch3GamePad(Teleoperator):
|
|||||||
RobotParams.set_logging_formatter("brief_console_formatter")
|
RobotParams.set_logging_formatter("brief_console_formatter")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_feature(self) -> dict:
|
def action_features(self) -> dict:
|
||||||
return {
|
return {
|
||||||
"dtype": "float32",
|
"dtype": "float32",
|
||||||
"shape": (len(GAMEPAD_BUTTONS),),
|
"shape": (len(GAMEPAD_BUTTONS),),
|
||||||
@@ -81,7 +81,7 @@ class Stretch3GamePad(Teleoperator):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def feedback_feature(self) -> dict:
|
def feedback_features(self) -> dict:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def connect(self) -> None:
|
def connect(self) -> None:
|
||||||
@@ -34,11 +34,11 @@ class Teleoperator(abc.ABC):
|
|||||||
return f"{self.id} {self.__class__.__name__}"
|
return f"{self.id} {self.__class__.__name__}"
|
||||||
|
|
||||||
@abc.abstractproperty
|
@abc.abstractproperty
|
||||||
def action_feature(self) -> dict:
|
def action_features(self) -> dict:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractproperty
|
@abc.abstractproperty
|
||||||
def feedback_feature(self) -> dict:
|
def feedback_features(self) -> dict:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractproperty
|
@abc.abstractproperty
|
||||||
|
|||||||
@@ -58,15 +58,11 @@ class WidowX(Teleoperator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_feature(self) -> dict:
|
def action_features(self) -> dict[str, type]:
|
||||||
return {
|
return {f"{motor}.pos": float for motor in self.arm.motors}
|
||||||
"dtype": "float32",
|
|
||||||
"shape": (len(self.arm),),
|
|
||||||
"names": {"motors": list(self.arm.motors)},
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def feedback_feature(self) -> dict:
|
def feedback_features(self) -> dict[str, type]:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -84,6 +80,10 @@ class WidowX(Teleoperator):
|
|||||||
self.configure()
|
self.configure()
|
||||||
logger.info(f"{self} connected.")
|
logger.info(f"{self} connected.")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_calibrated(self) -> bool:
|
||||||
|
return self.arm.is_calibrated
|
||||||
|
|
||||||
def calibrate(self) -> None:
|
def calibrate(self) -> None:
|
||||||
raise NotImplementedError # TODO(aliberts): adapt code below (copied from koch)
|
raise NotImplementedError # TODO(aliberts): adapt code below (copied from koch)
|
||||||
logger.info(f"\nRunning calibration of {self}")
|
logger.info(f"\nRunning calibration of {self}")
|
||||||
@@ -137,7 +137,8 @@ class WidowX(Teleoperator):
|
|||||||
raise DeviceNotConnectedError(f"{self} is not connected.")
|
raise DeviceNotConnectedError(f"{self} is not connected.")
|
||||||
|
|
||||||
start = time.perf_counter()
|
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
|
dt_ms = (time.perf_counter() - start) * 1e3
|
||||||
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
||||||
return action
|
return action
|
||||||
|
|||||||
Reference in New Issue
Block a user