reachy2_sdk.components.goto_based_component
Reachy IGoToBasedComponent interface.
Handles common interface for components performing movement using goto mechanism.
1"""Reachy IGoToBasedComponent interface. 2 3Handles common interface for components performing movement using goto mechanism. 4""" 5 6from typing import List 7 8from reachy2_sdk_api.component_pb2 import ComponentId 9from reachy2_sdk_api.goto_pb2 import GoToAck, GoToId 10from reachy2_sdk_api.goto_pb2_grpc import GoToServiceStub 11 12from ..utils.goto_based_element import IGoToBasedElement 13 14 15class IGoToBasedComponent(IGoToBasedElement): 16 """Interface for components of Reachy that use goto functions. 17 18 The `IGoToBasedComponent` class defines a common interface for handling goto-based movements. It is 19 designed to be implemented by components of the robot that perform movements via the goto mechanism. 20 It is used by the Antenna class to handle goto-based movements, and is based on the IGoToBasedElement. 21 """ 22 23 def __init__( 24 self, 25 component_id: ComponentId, 26 goto_stub: GoToServiceStub, 27 ) -> None: 28 """Initialize the IGoToBasedComponent interface. 29 30 Sets up the common attributes needed for handling goto-based movements. This includes 31 associating the component with the interface and setting up the gRPC stub for performing 32 goto commands. 33 34 Args: 35 component_id: The robot component that uses this interface. 36 goto_stub: The gRPC stub used to send goto commands to the robot component. 37 """ 38 super().__init__(component_id, goto_stub) 39 40 def get_goto_playing(self) -> GoToId: 41 """Return the GoToId of the currently playing goto movement on a specific component.""" 42 response = self._goto_stub.GetComponentGoToPlaying(self._element_id) 43 return response 44 45 def get_goto_queue(self) -> List[GoToId]: 46 """Return a list of all GoToIds waiting to be played on a specific component.""" 47 response = self._goto_stub.GetComponentGoToQueue(self._element_id) 48 return [goal_id for goal_id in response.goto_ids] 49 50 def cancel_all_goto(self) -> GoToAck: 51 """Request the cancellation of all playing and waiting goto commands for a specific component. 52 53 Returns: 54 A GoToAck acknowledging the cancellation of all goto commands. 55 """ 56 response = self._goto_stub.CancelComponentAllGoTo(self._element_id) 57 return response
16class IGoToBasedComponent(IGoToBasedElement): 17 """Interface for components of Reachy that use goto functions. 18 19 The `IGoToBasedComponent` class defines a common interface for handling goto-based movements. It is 20 designed to be implemented by components of the robot that perform movements via the goto mechanism. 21 It is used by the Antenna class to handle goto-based movements, and is based on the IGoToBasedElement. 22 """ 23 24 def __init__( 25 self, 26 component_id: ComponentId, 27 goto_stub: GoToServiceStub, 28 ) -> None: 29 """Initialize the IGoToBasedComponent interface. 30 31 Sets up the common attributes needed for handling goto-based movements. This includes 32 associating the component with the interface and setting up the gRPC stub for performing 33 goto commands. 34 35 Args: 36 component_id: The robot component that uses this interface. 37 goto_stub: The gRPC stub used to send goto commands to the robot component. 38 """ 39 super().__init__(component_id, goto_stub) 40 41 def get_goto_playing(self) -> GoToId: 42 """Return the GoToId of the currently playing goto movement on a specific component.""" 43 response = self._goto_stub.GetComponentGoToPlaying(self._element_id) 44 return response 45 46 def get_goto_queue(self) -> List[GoToId]: 47 """Return a list of all GoToIds waiting to be played on a specific component.""" 48 response = self._goto_stub.GetComponentGoToQueue(self._element_id) 49 return [goal_id for goal_id in response.goto_ids] 50 51 def cancel_all_goto(self) -> GoToAck: 52 """Request the cancellation of all playing and waiting goto commands for a specific component. 53 54 Returns: 55 A GoToAck acknowledging the cancellation of all goto commands. 56 """ 57 response = self._goto_stub.CancelComponentAllGoTo(self._element_id) 58 return response
Interface for components of Reachy that use goto functions.
The IGoToBasedComponent
class defines a common interface for handling goto-based movements. It is
designed to be implemented by components of the robot that perform movements via the goto mechanism.
It is used by the Antenna class to handle goto-based movements, and is based on the IGoToBasedElement.
24 def __init__( 25 self, 26 component_id: ComponentId, 27 goto_stub: GoToServiceStub, 28 ) -> None: 29 """Initialize the IGoToBasedComponent interface. 30 31 Sets up the common attributes needed for handling goto-based movements. This includes 32 associating the component with the interface and setting up the gRPC stub for performing 33 goto commands. 34 35 Args: 36 component_id: The robot component that uses this interface. 37 goto_stub: The gRPC stub used to send goto commands to the robot component. 38 """ 39 super().__init__(component_id, goto_stub)
Initialize the IGoToBasedComponent interface.
Sets up the common attributes needed for handling goto-based movements. This includes associating the component with the interface and setting up the gRPC stub for performing goto commands.
Arguments:
- component_id: The robot component that uses this interface.
- goto_stub: The gRPC stub used to send goto commands to the robot component.
41 def get_goto_playing(self) -> GoToId: 42 """Return the GoToId of the currently playing goto movement on a specific component.""" 43 response = self._goto_stub.GetComponentGoToPlaying(self._element_id) 44 return response
Return the GoToId of the currently playing goto movement on a specific component.
46 def get_goto_queue(self) -> List[GoToId]: 47 """Return a list of all GoToIds waiting to be played on a specific component.""" 48 response = self._goto_stub.GetComponentGoToQueue(self._element_id) 49 return [goal_id for goal_id in response.goto_ids]
Return a list of all GoToIds waiting to be played on a specific component.
51 def cancel_all_goto(self) -> GoToAck: 52 """Request the cancellation of all playing and waiting goto commands for a specific component. 53 54 Returns: 55 A GoToAck acknowledging the cancellation of all goto commands. 56 """ 57 response = self._goto_stub.CancelComponentAllGoTo(self._element_id) 58 return response
Request the cancellation of all playing and waiting goto commands for a specific component.
Returns:
A GoToAck acknowledging the cancellation of all goto commands.