Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make simulation delay in detector configurable #133

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions rosys/vision/detector_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@ class DetectorSimulation(Detector):
Individual camera IDs can be added to a set of `blocked_cameras` to simulate occlusions during pytests.
A list of `simulated_objects` can be filled to define what can be detected.
An optional `noise` parameter controls the spatial accuracy in pixels.
An optional `detection_delay` parameter simulates the time it takes to process an image.
"""

def __init__(self, camera_provider: CalibratableCameraProvider, *, noise: float = 1.0, name: Optional[str] = None) -> None:
def __init__(self,
camera_provider: CalibratableCameraProvider, *,
noise: float = 1.0,
detection_delay: float = 0.4,
name: Optional[str] = None,
) -> None:
super().__init__(name=name)

self.camera_provider = camera_provider
self.noise = noise

self.blocked_cameras: set[str] = set()
self.simulated_objects: list[SimulatedObject] = []
self.detection_delay = detection_delay

rosys.on_repeat(self.step, 0.1)

Expand All @@ -54,7 +61,7 @@ async def detect(self,
tags: list[str] = [],
) -> Detections | None:
is_blocked = image.camera_id in self.blocked_cameras
await rosys.sleep(0.4)
await rosys.sleep(self.detection_delay)
image.set_detections(self.name, Detections())
if not is_blocked:
self.update_simulated_objects(image)
Expand Down
Loading