Add calibrate

This commit is contained in:
Simon Alibert
2025-05-08 18:27:19 +02:00
parent dd3e305164
commit 64303781c2
14 changed files with 91 additions and 20 deletions

View File

@@ -85,7 +85,7 @@ class KochFollower(Robot):
# TODO(aliberts): add cam.is_connected for cam in self.cameras
return self.arm.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
"""
We assume that at connection time, arm is in a rest position,
and torque can be safely disabled to run calibration.
@@ -94,7 +94,7 @@ class KochFollower(Robot):
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
for cam in self.cameras.values():

View File

@@ -104,12 +104,12 @@ class LeKiwi(Robot):
# TODO(aliberts): add cam.is_connected for cam in self.cameras
return self.bus.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
if self.is_connected:
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.bus.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
for cam in self.cameras.values():

View File

@@ -82,7 +82,7 @@ class MossRobot(Robot):
# TODO(aliberts): add cam.is_connected for cam in self.cameras
return self.arm.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
"""
We assume that at connection time, arm is in a rest position,
and torque can be safely disabled to run calibration.
@@ -91,7 +91,7 @@ class MossRobot(Robot):
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
# Connect the cameras

View File

@@ -48,7 +48,7 @@ class Robot(abc.ABC):
pass
@abc.abstractmethod
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
"""Connects to the robot."""
pass

View File

@@ -82,7 +82,7 @@ class SO100Follower(Robot):
# TODO(aliberts): add cam.is_connected for cam in self.cameras
return self.arm.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
"""
We assume that at connection time, arm is in a rest position,
and torque can be safely disabled to run calibration.
@@ -91,7 +91,7 @@ class SO100Follower(Robot):
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
# Connect the cameras

View File

@@ -78,7 +78,7 @@ class ViperX(Robot):
# TODO(aliberts): add cam.is_connected for cam in self.cameras
return self.arm.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
"""
We assume that at connection time, arm is in a rest position,
and torque can be safely disabled to run calibration.
@@ -87,7 +87,7 @@ class ViperX(Robot):
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
for cam in self.cameras.values():

View File

@@ -69,12 +69,12 @@ class KochLeader(Teleoperator):
def is_connected(self) -> bool:
return self.arm.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
if self.is_connected:
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
self.configure()

View File

@@ -66,12 +66,12 @@ class SO100Leader(Teleoperator):
def is_connected(self) -> bool:
return self.arm.is_connected
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
if self.is_connected:
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
self.configure()

View File

@@ -46,7 +46,7 @@ class Teleoperator(abc.ABC):
pass
@abc.abstractmethod
def connect(self) -> None:
def connect(self, calibrate: bool = True) -> None:
"""Connects to the teleoperator."""
pass

View File

@@ -69,12 +69,12 @@ class WidowX(Teleoperator):
def is_connected(self) -> bool:
return self.arm.is_connected
def connect(self):
def connect(self, calibrate: bool = True):
if self.is_connected:
raise DeviceAlreadyConnectedError(f"{self} already connected")
self.arm.connect()
if not self.is_calibrated:
if not self.is_calibrated and calibrate:
self.calibrate()
self.configure()