-
Notifications
You must be signed in to change notification settings - Fork 599
Expand file tree
/
Copy pathdoor.py
More file actions
88 lines (65 loc) · 3.04 KB
/
door.py
File metadata and controls
88 lines (65 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved.
#
# Downloading, reproducing, distributing or otherwise using the SDK Software
# is subject to the terms and conditions of the Boston Dynamics Software
# Development Kit License (20191101-BDSDK-SL).
"""For clients to the door service."""
from bosdyn.api.spot import door_service_pb2_grpc
from bosdyn.client.common import (BaseClient, handle_common_header_errors,
handle_lease_use_result_errors)
from .lease import add_lease_wallet_processors
class DoorClient(BaseClient):
"""Client for the door service."""
default_service_name = 'door'
service_type = 'bosdyn.api.spot.DoorService'
def __init__(self):
super(DoorClient, self).__init__(door_service_pb2_grpc.DoorServiceStub)
def open_door(self, request, **kwargs):
"""Issue an open door command to the robot.
Args:
request (door_pb2.OpenDoorCommandRequest): The door command.
Returns:
The full OpenDoorCommandResponse message, which includes a command id for feedback.
Raises:
RpcError: Problem communicating with the robot.
LeaseUseError: The lease for the request failed.
"""
return self.call(self._stub.OpenDoor, request, None, _open_door_error_handler, **kwargs)
def open_door_async(self, request, **kwargs):
"""Async version of open_door()."""
return self.call_async(self._stub.OpenDoor, request, None, _open_door_error_handler,
**kwargs)
def open_door_feedback(self, request, **kwargs):
"""Get feedback from the robot on a specific door command.
Args:
request (door_pb2.OpenDoorFeedbackRequest): The request for feedback of
the door command.
Returns:
The full OpenDoorFeedbackResponse message.
Raises:
RpcError: Problem communicating with the robot.
"""
return self.call(self._stub.OpenDoorFeedback, request, None,
_open_door_feedback_error_handler, **kwargs)
def open_door_feedback_async(self, request, **kwargs):
"""Async version of open_door_feedback()."""
return self.call_async(self._stub.OpenDoorFeedback, request, None,
_open_door_feedback_error_handler, **kwargs)
def update_from(self, other):
"""Update instance from another object.
Args:
other: The object where to copy from.
"""
# The door service requires a lease.
super(DoorClient, self).update_from(other)
if self.lease_wallet:
add_lease_wallet_processors(self, self.lease_wallet)
@handle_common_header_errors
@handle_lease_use_result_errors
def _open_door_error_handler(response):
"""Return a custom exception based on response, None if no error."""
return None
@handle_common_header_errors
def _open_door_feedback_error_handler(response):
"""Return a custom exception based on response, None if no error."""
return None