import abc
from typing import Any, Dict, Final, Optional
from viam.components.component_base import ComponentBase
from viam.resource.types import RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, Subtype
[docs]class Gripper(ComponentBase):
"""
Gripper represents a physical robotic gripper.
This acts as an abstract base class for any drivers representing specific
gripper implementations. This cannot be used on its own. If the ``__init__()`` function is
overridden, it must call the ``super().__init__()`` function.
"""
SUBTYPE: Final = Subtype(RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT, "gripper")
[docs] @abc.abstractmethod
async def open(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
):
"""
Open the gripper.
"""
...
[docs] @abc.abstractmethod
async def grab(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
) -> bool:
"""
Instruct the gripper to grab.
Returns:
bool: Indicates if the gripper grabbed something.
"""
...
[docs] @abc.abstractmethod
async def stop(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
):
"""
Stop the gripper. It is assumed the gripper stops immediately.
"""
...
[docs] @abc.abstractmethod
async def is_moving(self) -> bool:
"""
Get if the gripper is currently moving.
Returns:
bool: Whether the gripper is moving.
"""
...