Skip to content

Commit

Permalink
__init__ clas desc
Browse files Browse the repository at this point in the history
  • Loading branch information
glannuzel committed Oct 10, 2024
1 parent 27b08f6 commit 3d5e3e9
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/reachy2_sdk/parts/goto_based_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion src/reachy2_sdk/parts/hand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 12 additions & 1 deletion src/reachy2_sdk/parts/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 12 additions & 1 deletion src/reachy2_sdk/parts/joints_based_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion src/reachy2_sdk/parts/mobile_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
14 changes: 13 additions & 1 deletion src/reachy2_sdk/parts/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d5e3e9

Please sign in to comment.