Skip to content

Commit edd4fb2

Browse files
refactor(cameras): width, fps and height is mandatory to have a value in robot config
1 parent 51180d7 commit edd4fb2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lerobot/common/robots/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ class RobotConfig(draccus.ChoiceRegistry, abc.ABC):
1212
# Directory to store calibration file
1313
calibration_dir: Path | None = None
1414

15+
def __post_init__(self):
16+
if hasattr(self, "cameras"):
17+
cameras = self.cameras
18+
if cameras:
19+
for cam_name, cam_config in cameras.items():
20+
for attr in ["width", "height", "fps"]:
21+
if getattr(cam_config, attr) is None:
22+
raise ValueError(
23+
f"Camera config for '{cam_name}' has None value for required attribute '{attr}'"
24+
)
25+
1526
@property
1627
def type(self) -> str:
1728
return self.get_choice_name(self.__class__)

tests/cameras/test_opencv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from lerobot.common.cameras.opencv import OpenCVCamera, OpenCVCameraConfig
2929
from lerobot.common.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError
3030

31+
# NOTE(Steven): Consider improving the assert coverage
32+
3133

3234
def test_base_class_implementation():
3335
config = OpenCVCameraConfig(index_or_path=0)

0 commit comments

Comments
 (0)