refactor(cameras): width, fps and height is mandatory to have a value in robot config
This commit is contained in:
@@ -12,6 +12,17 @@ class RobotConfig(draccus.ChoiceRegistry, abc.ABC):
|
|||||||
# Directory to store calibration file
|
# Directory to store calibration file
|
||||||
calibration_dir: Path | None = None
|
calibration_dir: Path | None = None
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
if hasattr(self, "cameras"):
|
||||||
|
cameras = self.cameras
|
||||||
|
if cameras:
|
||||||
|
for cam_name, cam_config in cameras.items():
|
||||||
|
for attr in ["width", "height", "fps"]:
|
||||||
|
if getattr(cam_config, attr) is None:
|
||||||
|
raise ValueError(
|
||||||
|
f"Camera config for '{cam_name}' has None value for required attribute '{attr}'"
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self) -> str:
|
def type(self) -> str:
|
||||||
return self.get_choice_name(self.__class__)
|
return self.get_choice_name(self.__class__)
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ from lerobot.common.cameras.configs import Cv2Rotation
|
|||||||
from lerobot.common.cameras.opencv import OpenCVCamera, OpenCVCameraConfig
|
from lerobot.common.cameras.opencv import OpenCVCamera, OpenCVCameraConfig
|
||||||
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
|
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
|
||||||
|
|
||||||
|
# NOTE(Steven): Consider improving the assert coverage
|
||||||
|
|
||||||
|
|
||||||
def test_base_class_implementation():
|
def test_base_class_implementation():
|
||||||
config = OpenCVCameraConfig(index_or_path=0)
|
config = OpenCVCameraConfig(index_or_path=0)
|
||||||
|
|||||||
Reference in New Issue
Block a user