forked from tangger/lerobot
add mock=False
This commit is contained in:
@@ -3,33 +3,33 @@ import enum
|
||||
import numpy as np
|
||||
|
||||
|
||||
class MockStream(enum.Enum):
|
||||
class RSStream(enum.Enum):
|
||||
color = 0
|
||||
depth = 1
|
||||
|
||||
|
||||
class MockFormat(enum.Enum):
|
||||
class RSFormat(enum.Enum):
|
||||
rgb8 = 0
|
||||
z16 = 1
|
||||
|
||||
|
||||
class MockConfig:
|
||||
class RSConfig:
|
||||
def enable_device(self, device_id: str):
|
||||
self.device_enabled = device_id
|
||||
|
||||
def enable_stream(
|
||||
self, stream_type: MockStream, width=None, height=None, color_format: MockFormat = None, fps=None
|
||||
self, stream_type: RSStream, width=None, height=None, color_format: RSFormat = None, fps=None
|
||||
):
|
||||
self.stream_type = stream_type
|
||||
# Overwrite default values when possible
|
||||
self.width = 848 if width is None else width
|
||||
self.height = 480 if height is None else height
|
||||
self.color_format = MockFormat.rgb8 if color_format is None else color_format
|
||||
self.color_format = RSFormat.rgb8 if color_format is None else color_format
|
||||
self.fps = 30 if fps is None else fps
|
||||
|
||||
|
||||
class MockColorProfile:
|
||||
def __init__(self, config: MockConfig):
|
||||
class RSColorProfile:
|
||||
def __init__(self, config: RSConfig):
|
||||
self.config = config
|
||||
|
||||
def fps(self):
|
||||
@@ -42,32 +42,32 @@ class MockColorProfile:
|
||||
return self.config.height
|
||||
|
||||
|
||||
class MockColorStream:
|
||||
def __init__(self, config: MockConfig):
|
||||
class RSColorStream:
|
||||
def __init__(self, config: RSConfig):
|
||||
self.config = config
|
||||
|
||||
def as_video_stream_profile(self):
|
||||
return MockColorProfile(self.config)
|
||||
return RSColorProfile(self.config)
|
||||
|
||||
|
||||
class MockProfile:
|
||||
def __init__(self, config: MockConfig):
|
||||
class RSProfile:
|
||||
def __init__(self, config: RSConfig):
|
||||
self.config = config
|
||||
|
||||
def get_stream(self, color_format: MockFormat):
|
||||
def get_stream(self, color_format: RSFormat):
|
||||
del color_format # unused
|
||||
return MockColorStream(self.config)
|
||||
return RSColorStream(self.config)
|
||||
|
||||
|
||||
class MockPipeline:
|
||||
class RSPipeline:
|
||||
def __init__(self):
|
||||
self.started = False
|
||||
self.config = None
|
||||
|
||||
def start(self, config: MockConfig):
|
||||
def start(self, config: RSConfig):
|
||||
self.started = True
|
||||
self.config = config
|
||||
return MockProfile(self.config)
|
||||
return RSProfile(self.config)
|
||||
|
||||
def stop(self):
|
||||
if not self.started:
|
||||
@@ -77,22 +77,22 @@ class MockPipeline:
|
||||
|
||||
def wait_for_frames(self, timeout_ms=50000):
|
||||
del timeout_ms # unused
|
||||
return MockFrames(self.config)
|
||||
return RSFrames(self.config)
|
||||
|
||||
|
||||
class MockFrames:
|
||||
def __init__(self, config: MockConfig):
|
||||
class RSFrames:
|
||||
def __init__(self, config: RSConfig):
|
||||
self.config = config
|
||||
|
||||
def get_color_frame(self):
|
||||
return MockColorFrame(self.config)
|
||||
return RSColorFrame(self.config)
|
||||
|
||||
def get_depth_frame(self):
|
||||
return MockDepthFrame(self.config)
|
||||
return RSDepthFrame(self.config)
|
||||
|
||||
|
||||
class MockColorFrame:
|
||||
def __init__(self, config: MockConfig):
|
||||
class RSColorFrame:
|
||||
def __init__(self, config: RSConfig):
|
||||
self.config = config
|
||||
|
||||
def get_data(self):
|
||||
@@ -102,15 +102,15 @@ class MockColorFrame:
|
||||
return data
|
||||
|
||||
|
||||
class MockDepthFrame:
|
||||
def __init__(self, config: MockConfig):
|
||||
class RSDepthFrame:
|
||||
def __init__(self, config: RSConfig):
|
||||
self.config = config
|
||||
|
||||
def get_data(self):
|
||||
return np.ones((self.config.height, self.config.width), dtype=np.uint16)
|
||||
|
||||
|
||||
class MockDevice:
|
||||
class RSDevice:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@@ -120,9 +120,15 @@ class MockDevice:
|
||||
return "123456789"
|
||||
|
||||
|
||||
class MockContext:
|
||||
class RSContext:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def query_devices(self):
|
||||
return [MockDevice()]
|
||||
return [RSDevice()]
|
||||
|
||||
|
||||
class RSCameraInfo:
|
||||
def __init__(self, serial_number):
|
||||
del serial_number
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user