Skip to content

Interface

HardwareInterface

Bases: ABC

Abstract base class for hardware interfaces.

This class provides a template for creating hardware interfaces that can control robots or other hardware devices.

Source code in mbodied/hardware/interface.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class HardwareInterface(ABC):
    """Abstract base class for hardware interfaces.

    This class provides a template for creating hardware interfaces that can
    control robots or other hardware devices.
    """

    @abstractmethod
    def __init__(self, **kwargs):
        """Initializes the hardware interface.

        Args:
            kwargs: Additional arguments to pass to the hardware interface.
        """
        raise NotImplementedError

    @abstractmethod
    def do(self, *args, **kwargs) -> None:  # noqa
        """Executes motion.

        Args:
            args: Arguments to pass to the hardware interface.
            kwargs: Additional arguments to pass to the hardware interface.
        """
        raise NotImplementedError

    async def async_do(self, *args, **kwargs) -> None:
        """Asynchronously executes motion.

        Args:
            args: Arguments to pass to the hardware interface.
            kwargs: Additional arguments to pass to the hardware interface.
        """
        return await asyncio.to_thread(self.do, *args, **kwargs)

    def fetch(self, *args, **kwargs) -> None:
        """Fetches data from the hardware.

        Args:
            args: Arguments to pass to the hardware interface.
            kwargs: Additional arguments to pass to the hardware interface.
        """
        raise NotImplementedError

    def capture(self, *args, **kwargs) -> None:
        """Captures continuous data from the hardware.

        Args:
            args: Arguments to pass to the hardware interface.
            kwargs: Additional arguments to pass to the hardware interface.
        """
        raise NotImplementedError

__init__(**kwargs) abstractmethod

Initializes the hardware interface.

Parameters:

Name Type Description Default
kwargs

Additional arguments to pass to the hardware interface.

{}
Source code in mbodied/hardware/interface.py
26
27
28
29
30
31
32
33
@abstractmethod
def __init__(self, **kwargs):
    """Initializes the hardware interface.

    Args:
        kwargs: Additional arguments to pass to the hardware interface.
    """
    raise NotImplementedError

async_do(*args, **kwargs) async

Asynchronously executes motion.

Parameters:

Name Type Description Default
args

Arguments to pass to the hardware interface.

()
kwargs

Additional arguments to pass to the hardware interface.

{}
Source code in mbodied/hardware/interface.py
45
46
47
48
49
50
51
52
async def async_do(self, *args, **kwargs) -> None:
    """Asynchronously executes motion.

    Args:
        args: Arguments to pass to the hardware interface.
        kwargs: Additional arguments to pass to the hardware interface.
    """
    return await asyncio.to_thread(self.do, *args, **kwargs)

capture(*args, **kwargs)

Captures continuous data from the hardware.

Parameters:

Name Type Description Default
args

Arguments to pass to the hardware interface.

()
kwargs

Additional arguments to pass to the hardware interface.

{}
Source code in mbodied/hardware/interface.py
63
64
65
66
67
68
69
70
def capture(self, *args, **kwargs) -> None:
    """Captures continuous data from the hardware.

    Args:
        args: Arguments to pass to the hardware interface.
        kwargs: Additional arguments to pass to the hardware interface.
    """
    raise NotImplementedError

do(*args, **kwargs) abstractmethod

Executes motion.

Parameters:

Name Type Description Default
args

Arguments to pass to the hardware interface.

()
kwargs

Additional arguments to pass to the hardware interface.

{}
Source code in mbodied/hardware/interface.py
35
36
37
38
39
40
41
42
43
@abstractmethod
def do(self, *args, **kwargs) -> None:  # noqa
    """Executes motion.

    Args:
        args: Arguments to pass to the hardware interface.
        kwargs: Additional arguments to pass to the hardware interface.
    """
    raise NotImplementedError

fetch(*args, **kwargs)

Fetches data from the hardware.

Parameters:

Name Type Description Default
args

Arguments to pass to the hardware interface.

()
kwargs

Additional arguments to pass to the hardware interface.

{}
Source code in mbodied/hardware/interface.py
54
55
56
57
58
59
60
61
def fetch(self, *args, **kwargs) -> None:
    """Fetches data from the hardware.

    Args:
        args: Arguments to pass to the hardware interface.
        kwargs: Additional arguments to pass to the hardware interface.
    """
    raise NotImplementedError