File size: 968 Bytes
0651b21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Base sensor abstract class.

The ``gymnasium`` dependency is lazy-imported so the camera server can
run without it.
"""

from abc import abstractmethod
from typing import Any


class Sensor:
    """Base class for camera / sensor implementations.

    Concrete drivers (OAK, RealSense, ZED, USB, …) inherit from this and
    implement at least :meth:`read` and :meth:`serialize`.
    """

    def read(self, **kwargs) -> Any:
        """Read the current sensor value (e.g. a dict of images)."""

    def observation_space(self):
        """Return a ``gymnasium.Space`` describing the observation.

        Only used during init to report camera capabilities to the
        composed-camera orchestrator; not required for data collection.
        """

    @abstractmethod
    def serialize(self, data: dict[str, Any]) -> dict[str, Any]:
        """Serialize the sensor reading for ZMQ transmission."""

    def close(self):
        """Release hardware resources."""