From 3d5e3e9907551fa98fb5e7999561479325b920ec Mon Sep 17 00:00:00 2001 From: glannuzel Date: Thu, 10 Oct 2024 11:59:46 +0200 Subject: [PATCH] __init__ clas desc --- src/reachy2_sdk/parts/goto_based_part.py | 11 ++++++++++- src/reachy2_sdk/parts/hand.py | 11 ++++++++++- src/reachy2_sdk/parts/head.py | 13 ++++++++++++- src/reachy2_sdk/parts/joints_based_part.py | 13 ++++++++++++- src/reachy2_sdk/parts/mobile_base.py | 13 ++++++++++++- src/reachy2_sdk/parts/part.py | 14 +++++++++++++- 6 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/reachy2_sdk/parts/goto_based_part.py b/src/reachy2_sdk/parts/goto_based_part.py index 7fde8024..7577c51f 100644 --- a/src/reachy2_sdk/parts/goto_based_part.py +++ b/src/reachy2_sdk/parts/goto_based_part.py @@ -26,7 +26,16 @@ def __init__( part: Part, goto_stub: GoToServiceStub, ) -> None: - """Initialize the common attributes.""" + """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. + + Args: + 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. + """ self.part = part self._goto_stub = goto_stub diff --git a/src/reachy2_sdk/parts/hand.py b/src/reachy2_sdk/parts/hand.py index d1e2803d..fe5e0e24 100644 --- a/src/reachy2_sdk/parts/hand.py +++ b/src/reachy2_sdk/parts/hand.py @@ -44,7 +44,16 @@ def __init__( initial_state: HandState, grpc_channel: grpc.Channel, ) -> None: - """Set up the hand.""" + """Initialize the Hand component. + + Sets up the necessary attributes and configuration for the hand, including the gRPC + stub and initial state. + + Args: + hand_msg: The Hand_proto object containing the configuration details for the hand. + initial_state: The initial state of the hand, represented as a HandState object. + grpc_channel: The gRPC channel used to communicate with the hand's gRPC service. + """ super().__init__(hand_msg, grpc_channel, HandServiceStub(grpc_channel)) self._hand_stub = HandServiceStub(grpc_channel) diff --git a/src/reachy2_sdk/parts/head.py b/src/reachy2_sdk/parts/head.py index c116987f..22ac575c 100644 --- a/src/reachy2_sdk/parts/head.py +++ b/src/reachy2_sdk/parts/head.py @@ -57,7 +57,18 @@ def __init__( grpc_channel: grpc.Channel, goto_stub: GoToServiceStub, ) -> None: - """Initialize the head with its actuators.""" + """Initialize the Head component with its actuators. + + Sets up the necessary attributes and configuration for the head, including the gRPC + stubs and initial state. + + Args: + head_msg: The Head_proto object containing the configuration details for the head. + initial_state: The initial state of the head, represented as a HeadState object. + grpc_channel: The gRPC channel used to communicate with the head's gRPC service. + goto_stub: The GoToServiceStub used to handle goto-based movements for the head. + """ + JointsBasedPart.__init__(self, head_msg, grpc_channel, HeadServiceStub(grpc_channel)) IGoToBasedPart.__init__(self, self, goto_stub) diff --git a/src/reachy2_sdk/parts/joints_based_part.py b/src/reachy2_sdk/parts/joints_based_part.py index 8379e4a3..4392acfd 100644 --- a/src/reachy2_sdk/parts/joints_based_part.py +++ b/src/reachy2_sdk/parts/joints_based_part.py @@ -29,7 +29,18 @@ def __init__( grpc_channel: grpc.Channel, stub: ArmServiceStub | HeadServiceStub | MobileBaseUtilityServiceStub, ) -> None: - """Initialize the common attributes.""" + """Initialize the JointsBasedPart with its common attributes. + + Sets up the gRPC communication channel and service stub for controlling the joint-based + part of the robot, such as an arm or head. + + Args: + proto_msg: A protocol message representing the part's configuration. It can be an + Arm_proto, Head_proto, or MobileBase_proto object. + grpc_channel: The gRPC channel used to communicate with the corresponding service. + stub: The service stub for the gRPC communication, which can be an ArmServiceStub, + HeadServiceStub, or MobileBaseUtilityServiceStub, depending on the part type. + """ super().__init__(proto_msg, grpc_channel, stub) @property diff --git a/src/reachy2_sdk/parts/mobile_base.py b/src/reachy2_sdk/parts/mobile_base.py index 4a611f0d..15dc1d30 100644 --- a/src/reachy2_sdk/parts/mobile_base.py +++ b/src/reachy2_sdk/parts/mobile_base.py @@ -58,7 +58,18 @@ def __init__( initial_state: MobileBaseState, grpc_channel: grpc.Channel, ) -> None: - """Set up the connection with the mobile base.""" + """Initialize the MobileBase with its gRPC communication and configuration. + + This sets up the gRPC communication channel and service stubs for controlling the + mobile base, initializes the drive and control modes. + It also sets up the LIDAR safety monitoring. + + Args: + mb_msg: A MobileBase_proto message containing the configuration details for the mobile base. + initial_state: The initial state of the mobile base, as a MobileBaseState object. + grpc_channel: The gRPC channel used to communicate with the mobile base service. + """ + self._logger = logging.getLogger(__name__) super().__init__(mb_msg, grpc_channel, MobileBaseUtilityServiceStub(grpc_channel)) diff --git a/src/reachy2_sdk/parts/part.py b/src/reachy2_sdk/parts/part.py index 0f8347f0..dbd32f39 100644 --- a/src/reachy2_sdk/parts/part.py +++ b/src/reachy2_sdk/parts/part.py @@ -33,7 +33,19 @@ def __init__( grpc_channel: grpc.Channel, stub: ArmServiceStub | HeadServiceStub | HandServiceStub | MobileBaseUtilityServiceStub, ) -> None: - """Initialize the common attributes.""" + """Initialize the Part with common attributes for gRPC communication. + + This sets up the communication channel and service stubs for the specified part, + configures the part's unique identifier. It provides the foundation for specific parts of the robot + (Arm, Head, Hand, MobileBase) to be derived from this class. + + Args: + proto_msg: The protobuf message containing configuration details for the part + (Arm, Head, Hand, or MobileBase). + grpc_channel: The gRPC channel used to communicate with the service. + stub: The service stub for the gRPC communication, which could be for Arm, Head, + Hand, or MobileBase. + """ self._grpc_channel = grpc_channel self._stub = stub self._part_id = PartId(id=proto_msg.part_id.id, name=proto_msg.part_id.name)