Skip to content

Commit 2de5c8e

Browse files
authored
Revert "Add types to Action Server and Action Client (#1349)" (#1359)
This reverts commit d1d7d05. Signed-off-by: Tomoya Fujita <[email protected]>
1 parent db9db32 commit 2de5c8e

10 files changed

+189
-589
lines changed

rclpy/rclpy/action/client.py

+77-145
Large diffs are not rendered by default.

rclpy/rclpy/action/server.py

+73-148
Large diffs are not rendered by default.

rclpy/rclpy/client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@
2828
from rclpy.qos import QoSProfile
2929
from rclpy.service_introspection import ServiceIntrospectionState
3030
from rclpy.task import Future
31-
from rclpy.type_support import Srv, SrvRequestT, SrvResponseT
31+
from rclpy.type_support import Srv, SrvEventT, SrvRequestT, SrvResponseT
3232

3333
# Left To Support Legacy TypeVars
3434
SrvType = TypeVar('SrvType')
3535
SrvTypeRequest = TypeVar('SrvTypeRequest')
3636
SrvTypeResponse = TypeVar('SrvTypeResponse')
3737

3838

39-
class Client(Generic[SrvRequestT, SrvResponseT]):
39+
class Client(Generic[SrvRequestT, SrvResponseT, SrvEventT]):
4040
def __init__(
4141
self,
4242
context: Context,
4343
client_impl: _rclpy.Client,
44-
srv_type: Type[Srv[SrvRequestT, SrvResponseT]],
44+
srv_type: Type[Srv[SrvRequestT, SrvResponseT, SrvEventT]],
4545
srv_name: str,
4646
qos_profile: QoSProfile,
4747
callback_group: CallbackGroup
@@ -231,7 +231,7 @@ def destroy(self) -> None:
231231
"""
232232
self.__client.destroy_when_not_in_use()
233233

234-
def __enter__(self) -> 'Client[SrvRequestT, SrvResponseT]':
234+
def __enter__(self) -> 'Client[SrvRequestT, SrvResponseT, SrvEventT]':
235235
return self
236236

237237
def __exit__(

rclpy/rclpy/impl/_rclpy_pybind11.pyi

+2-192
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@ from enum import Enum, IntEnum
1818
from types import TracebackType
1919
from typing import Any, Generic, Literal, overload, Sequence, TypedDict
2020

21-
22-
from action_msgs.msg import GoalInfo
23-
from action_msgs.msg._goal_status_array import GoalStatusArray
24-
from action_msgs.srv._cancel_goal import CancelGoal
2521
from rclpy.clock import JumpHandle
2622
from rclpy.clock_type import ClockType
2723
from rclpy.duration import Duration
2824
from rclpy.parameter import Parameter
2925
from rclpy.subscription import MessageInfo
30-
from type_support import (MsgT, Action, GoalT, ResultT, FeedbackT, SendGoalServiceResponse,
31-
GetResultServiceResponse, FeedbackMessage, SendGoalServiceRequest, GetResultServiceRequest)
26+
from rclpy.type_support import MsgT
3227

3328

3429
def rclpy_remove_ros_args(pycli_args: Sequence[str]) -> list[str]:
@@ -448,191 +443,6 @@ class WaitSet(Destroyable):
448443
"""Wait until timeout is reached or event happened."""
449444

450445

451-
class ActionClient(Generic[GoalT, ResultT, FeedbackT], Destroyable):
452-
453-
def __init__(
454-
self,
455-
node: Node,
456-
pyaction_type: type[Action[GoalT, ResultT, FeedbackT]],
457-
goal_service_qos: rmw_qos_profile_t,
458-
result_service_qos: rmw_qos_profile_t,
459-
cancel_service_qos: rmw_qos_profile_t,
460-
feedback_service_qos: rmw_qos_profile_t,
461-
status_topci_qos: rmw_qos_profile_t
462-
) -> None: ...
463-
464-
@property
465-
def pointer(self) -> int:
466-
"""Get the address of the entity as an integer."""
467-
468-
def take_goal_response(self, pymsg_type: type[SendGoalServiceResponse]
469-
) -> tuple[int, SendGoalServiceResponse] | tuple[None, None]:
470-
"""Take an action goal response."""
471-
472-
def send_result_request(self, pyrequest: GetResultServiceRequest) -> int:
473-
"""Send an action result requst."""
474-
475-
def take_cancel_response(self, pymsg_type: type[CancelGoal.Response]
476-
) -> tuple[int, CancelGoal.Response] | tuple[None, None]:
477-
"""Take an action cancel response."""
478-
479-
def take_feedback(self, pymsg_type: type[FeedbackMessage[FeedbackT]]
480-
) -> FeedbackMessage[FeedbackT] | None:
481-
"""Take a feedback message from a given action client."""
482-
483-
def send_cancel_request(self: CancelGoal.Request) -> int:
484-
"""Send an action cancel request."""
485-
486-
def send_goal_request(self: SendGoalServiceRequest[GoalT]) -> int:
487-
"""Send an action goal request."""
488-
489-
def take_result_response(self, pymsg_type: type[GetResultServiceResponse[ResultT]]
490-
) -> tuple[int, GetResultServiceResponse[ResultT]] | tuple[None, None]:
491-
"""Take an action result response."""
492-
493-
def get_num_entities(self) -> tuple[int, int, int, int, int]:
494-
"""Get the number of wait set entities that make up an action entity."""
495-
496-
def is_action_server_available(self) -> bool:
497-
"""Check if an action server is available for the given action client."""
498-
499-
def add_to_waitset(self, waitset: WaitSet) -> None:
500-
"""Add an action entity to a wait set."""
501-
502-
def is_ready(self) -> bool:
503-
"""Check if an action entity has any ready wait set entities."""
504-
505-
def take_status(self, pymsg_type: type[GoalStatusArray]) -> GoalStatusArray | None:
506-
"""Take an action status response."""
507-
508-
509-
class GoalEvent(Enum):
510-
_value_: int
511-
EXECUTE = ...
512-
CANCEL_GOAL = ...
513-
SUCCEED = ...
514-
ABORT = ...
515-
CANCELED = ...
516-
517-
518-
class rmw_request_id_t:
519-
writer_guid: list[int]
520-
sequence_number: int
521-
522-
523-
class ActionServer(Generic[GoalT, ResultT, FeedbackT], Destroyable):
524-
525-
def __init__(
526-
self,
527-
node: Node,
528-
rclpy_clock: Clock,
529-
pyaction_type: type[Action[GoalT, ResultT, FeedbackT]],
530-
action_name: str,
531-
goal_service_qos: rmw_qos_profile_t,
532-
result_service_qos: rmw_qos_profile_t,
533-
cancel_service_qos: rmw_qos_profile_t,
534-
feedback_topic_qos: rmw_qos_profile_t,
535-
status_topic_qos: rmw_qos_profile_t,
536-
result_timeout: float
537-
) -> None: ...
538-
539-
@property
540-
def pointer(self) -> int:
541-
"""Get the address of the entity as an integer."""
542-
543-
def take_goal_request(
544-
self,
545-
pymsg_type: type[SendGoalServiceRequest[GoalT]]
546-
) -> tuple[rmw_request_id_t, SendGoalServiceRequest[GoalT]] | tuple[None, None]:
547-
"""Take an action goal request."""
548-
549-
def send_goal_response(
550-
self,
551-
header: rmw_request_id_t,
552-
pyresponse: SendGoalServiceResponse
553-
) -> None:
554-
"""Send an action goal response."""
555-
556-
def send_result_response(
557-
self,
558-
header: rmw_request_id_t,
559-
pyresponse: GetResultServiceResponse[ResultT]
560-
) -> None:
561-
"""Send an action result response."""
562-
563-
def take_cancel_request(
564-
self,
565-
pymsg_type: type[CancelGoal.Request]
566-
) -> tuple[rmw_request_id_t, CancelGoal.Request] | tuple[None, None]:
567-
"""Take an action cancel request."""
568-
569-
def take_result_request(
570-
self,
571-
pymsg_type: type[GetResultServiceRequest]
572-
) -> tuple[rmw_request_id_t, GetResultServiceRequest] | tuple[None, None]:
573-
"""Take an action result request."""
574-
575-
def send_cancel_response(
576-
self,
577-
header: rmw_request_id_t,
578-
pyresponse: int
579-
) -> None:
580-
"""Send an action cancel response."""
581-
582-
def publish_feedback(
583-
self,
584-
pymsg: FeedbackMessage[FeedbackT]
585-
) -> None:
586-
"""Publish a feedback message from a given action server."""
587-
588-
def publish_status(self) -> None:
589-
"""Publish a status message from a given action server."""
590-
591-
def notify_goal_done(self) -> None:
592-
"""Notify goal is done."""
593-
594-
def goal_exists(self, pygoal_info: GoalInfo) -> bool:
595-
"""Check is a goal exists in the server."""
596-
597-
def process_cancel_request(
598-
self,
599-
pycancel_request: CancelGoal.Request,
600-
pycancel_response_tpye: type[CancelGoal.Response]
601-
) -> CancelGoal.Response:
602-
"""Process a cancel request"""
603-
604-
def expire_goals(self, max_num_goals: int) -> tuple[GoalInfo, ...]:
605-
"""Expired goals."""
606-
607-
def get_num_entities(self) -> tuple[int, int, int, int, int]:
608-
"""Get the number of wait set entities that make up an action entity."""
609-
610-
def is_ready(self, wait_set: WaitSet) -> tuple[bool, bool, bool, bool]:
611-
"""Check if an action entity has any ready wait set entities."""
612-
613-
def add_to_waitset(self, wait_set: WaitSet) -> None:
614-
"""Add an action entity to a wait set."""
615-
616-
617-
class ActionGoalHandle:
618-
619-
def __init__(self, action_server: ActionServer, pygoal_info_msg: GoalInfo) -> None:
620-
...
621-
622-
@property
623-
def pointer(self) -> int:
624-
"""Get the address of the entity as an integer."""
625-
626-
def get_status(self) -> GoalEvent:
627-
"""Get the status of a goal."""
628-
629-
def update_goal_state(self, event: GoalEvent) -> None:
630-
"""Update a goal state."""
631-
632-
def is_active(self) -> bool:
633-
"""Check if a goal is active."""
634-
635-
636446
class RCLError(RuntimeError):
637447
pass
638448

@@ -644,7 +454,7 @@ class NodeNameNonExistentError(RCLError):
644454
class InvalidHandle(RuntimeError):
645455
pass
646456

647-
457+
648458
class SignalHandlerOptions(Enum):
649459
_value_: int
650460
NO = ...

rclpy/rclpy/impl/implementation_singleton.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
# limitations under the License.
1414

1515

16-
from impl import _rclpy_pybind11
16+
from rclpy.impl import _rclpy_pybind11
1717

1818
rclpy_implementation = _rclpy_pybind11

rclpy/rclpy/node.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
from rclpy.type_support import check_is_valid_srv_type
9090
from rclpy.type_support import MsgT
9191
from rclpy.type_support import Srv
92+
from rclpy.type_support import SrvEventT
9293
from rclpy.type_support import SrvRequestT
9394
from rclpy.type_support import SrvResponseT
9495
from rclpy.utilities import get_default_context
@@ -172,8 +173,8 @@ def __init__(
172173
self._parameters: Dict[str, Parameter[Any]] = {}
173174
self._publishers: List[Publisher[Any]] = []
174175
self._subscriptions: List[Subscription[Any]] = []
175-
self._clients: List[Client[Any, Any]] = []
176-
self._services: List[Service[Any, Any]] = []
176+
self._clients: List[Client[Any, Any, Any]] = []
177+
self._services: List[Service[Any, Any, Any]] = []
177178
self._timers: List[Timer] = []
178179
self._guards: List[GuardCondition] = []
179180
self.__waitables: List[Waitable[Any]] = []
@@ -269,12 +270,12 @@ def subscriptions(self) -> Iterator[Subscription[Any]]:
269270
yield from self._subscriptions
270271

271272
@property
272-
def clients(self) -> Iterator[Client[Any, Any]]:
273+
def clients(self) -> Iterator[Client[Any, Any, Any]]:
273274
"""Get clients that have been created on this node."""
274275
yield from self._clients
275276

276277
@property
277-
def services(self) -> Iterator[Service[Any, Any]]:
278+
def services(self) -> Iterator[Service[Any, Any, Any]]:
278279
"""Get services that have been created on this node."""
279280
yield from self._services
280281

@@ -1689,12 +1690,12 @@ def create_subscription(
16891690

16901691
def create_client(
16911692
self,
1692-
srv_type: Type[Srv[SrvRequestT, SrvResponseT]],
1693+
srv_type: Type[Srv[SrvRequestT, SrvResponseT, SrvEventT]],
16931694
srv_name: str,
16941695
*,
16951696
qos_profile: QoSProfile = qos_profile_services_default,
16961697
callback_group: Optional[CallbackGroup] = None
1697-
) -> Client[SrvRequestT, SrvResponseT]:
1698+
) -> Client[SrvRequestT, SrvResponseT, SrvEventT]:
16981699
"""
16991700
Create a new service client.
17001701
@@ -1731,13 +1732,13 @@ def create_client(
17311732

17321733
def create_service(
17331734
self,
1734-
srv_type: Type[Srv[SrvRequestT, SrvResponseT]],
1735+
srv_type: Type[Srv[SrvRequestT, SrvResponseT, SrvEventT]],
17351736
srv_name: str,
17361737
callback: Callable[[SrvRequestT, SrvResponseT], SrvResponseT],
17371738
*,
17381739
qos_profile: QoSProfile = qos_profile_services_default,
17391740
callback_group: Optional[CallbackGroup] = None
1740-
) -> Service[SrvRequestT, SrvResponseT]:
1741+
) -> Service[SrvRequestT, SrvResponseT, SrvEventT]:
17411742
"""
17421743
Create a new service server.
17431744
@@ -1891,7 +1892,7 @@ def destroy_subscription(self, subscription: Subscription[Any]) -> bool:
18911892
return True
18921893
return False
18931894

1894-
def destroy_client(self, client: Client[Any, Any]) -> bool:
1895+
def destroy_client(self, client: Client[Any, Any, Any]) -> bool:
18951896
"""
18961897
Destroy a service client created by the node.
18971898
@@ -1907,7 +1908,7 @@ def destroy_client(self, client: Client[Any, Any]) -> bool:
19071908
return True
19081909
return False
19091910

1910-
def destroy_service(self, service: Service[Any, Any]) -> bool:
1911+
def destroy_service(self, service: Service[Any, Any, Any]) -> bool:
19111912
"""
19121913
Destroy a service server created by the node.
19131914

rclpy/rclpy/service.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
2525
from rclpy.qos import QoSProfile
2626
from rclpy.service_introspection import ServiceIntrospectionState
27-
from rclpy.type_support import Srv, SrvRequestT, SrvResponseT
27+
from rclpy.type_support import Srv, SrvEventT, SrvRequestT, SrvResponseT
2828

2929
# Used for documentation purposes only
3030
SrvType = TypeVar('SrvType')
3131
SrvTypeRequest = TypeVar('SrvTypeRequest')
3232
SrvTypeResponse = TypeVar('SrvTypeResponse')
3333

3434

35-
class Service(Generic[SrvRequestT, SrvResponseT]):
35+
class Service(Generic[SrvRequestT, SrvResponseT, SrvEventT]):
3636
def __init__(
3737
self,
3838
service_impl: _rclpy.Service,
39-
srv_type: Type[Srv[SrvRequestT, SrvResponseT]],
39+
srv_type: Type[Srv[SrvRequestT, SrvResponseT, SrvEventT]],
4040
srv_name: str,
4141
callback: Callable[[SrvRequestT, SrvResponseT], SrvResponseT],
4242
callback_group: CallbackGroup,
@@ -121,7 +121,7 @@ def destroy(self) -> None:
121121
"""
122122
self.__service.destroy_when_not_in_use()
123123

124-
def __enter__(self) -> 'Service[SrvRequestT, SrvResponseT]':
124+
def __enter__(self) -> 'Service[SrvRequestT, SrvResponseT, SrvEventT]':
125125
return self
126126

127127
def __exit__(

0 commit comments

Comments
 (0)