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