wirepod-vector-sdk-audio 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. anki_vector/__init__.py +43 -0
  2. anki_vector/animation.py +272 -0
  3. anki_vector/annotate.py +590 -0
  4. anki_vector/audio.py +212 -0
  5. anki_vector/audio_stream.py +335 -0
  6. anki_vector/behavior.py +1135 -0
  7. anki_vector/camera.py +670 -0
  8. anki_vector/camera_viewer/__init__.py +121 -0
  9. anki_vector/color.py +88 -0
  10. anki_vector/configure/__main__.py +331 -0
  11. anki_vector/connection.py +838 -0
  12. anki_vector/events.py +420 -0
  13. anki_vector/exceptions.py +185 -0
  14. anki_vector/faces.py +819 -0
  15. anki_vector/lights.py +210 -0
  16. anki_vector/mdns.py +131 -0
  17. anki_vector/messaging/__init__.py +45 -0
  18. anki_vector/messaging/alexa_pb2.py +36 -0
  19. anki_vector/messaging/alexa_pb2_grpc.py +3 -0
  20. anki_vector/messaging/behavior_pb2.py +40 -0
  21. anki_vector/messaging/behavior_pb2_grpc.py +3 -0
  22. anki_vector/messaging/client.py +33 -0
  23. anki_vector/messaging/cube_pb2.py +113 -0
  24. anki_vector/messaging/cube_pb2_grpc.py +3 -0
  25. anki_vector/messaging/extensions_pb2.py +25 -0
  26. anki_vector/messaging/extensions_pb2_grpc.py +3 -0
  27. anki_vector/messaging/external_interface_pb2.py +169 -0
  28. anki_vector/messaging/external_interface_pb2_grpc.py +1267 -0
  29. anki_vector/messaging/messages_pb2.py +431 -0
  30. anki_vector/messaging/messages_pb2_grpc.py +3 -0
  31. anki_vector/messaging/nav_map_pb2.py +33 -0
  32. anki_vector/messaging/nav_map_pb2_grpc.py +3 -0
  33. anki_vector/messaging/protocol.py +33 -0
  34. anki_vector/messaging/response_status_pb2.py +27 -0
  35. anki_vector/messaging/response_status_pb2_grpc.py +3 -0
  36. anki_vector/messaging/settings_pb2.py +72 -0
  37. anki_vector/messaging/settings_pb2_grpc.py +3 -0
  38. anki_vector/messaging/shared_pb2.py +54 -0
  39. anki_vector/messaging/shared_pb2_grpc.py +3 -0
  40. anki_vector/motors.py +127 -0
  41. anki_vector/nav_map.py +409 -0
  42. anki_vector/objects.py +1782 -0
  43. anki_vector/opengl/__init__.py +103 -0
  44. anki_vector/opengl/assets/LICENSE.txt +21 -0
  45. anki_vector/opengl/assets/cube.jpg +0 -0
  46. anki_vector/opengl/assets/cube.mtl +9 -0
  47. anki_vector/opengl/assets/cube.obj +1000 -0
  48. anki_vector/opengl/assets/vector.mtl +67 -0
  49. anki_vector/opengl/assets/vector.obj +13220 -0
  50. anki_vector/opengl/opengl.py +864 -0
  51. anki_vector/opengl/opengl_vector.py +620 -0
  52. anki_vector/opengl/opengl_viewer.py +689 -0
  53. anki_vector/photos.py +145 -0
  54. anki_vector/proximity.py +176 -0
  55. anki_vector/reserve_control/__main__.py +36 -0
  56. anki_vector/robot.py +930 -0
  57. anki_vector/screen.py +201 -0
  58. anki_vector/status.py +322 -0
  59. anki_vector/touch.py +119 -0
  60. anki_vector/user_intent.py +186 -0
  61. anki_vector/util.py +1132 -0
  62. anki_vector/version.py +15 -0
  63. anki_vector/viewer.py +403 -0
  64. anki_vector/vision.py +202 -0
  65. anki_vector/world.py +899 -0
  66. wirepod_vector_sdk_audio-0.9.0.dist-info/METADATA +80 -0
  67. wirepod_vector_sdk_audio-0.9.0.dist-info/RECORD +71 -0
  68. wirepod_vector_sdk_audio-0.9.0.dist-info/WHEEL +5 -0
  69. wirepod_vector_sdk_audio-0.9.0.dist-info/licenses/LICENSE.txt +180 -0
  70. wirepod_vector_sdk_audio-0.9.0.dist-info/top_level.txt +1 -0
  71. wirepod_vector_sdk_audio-0.9.0.dist-info/zip-safe +1 -0
anki_vector/photos.py ADDED
@@ -0,0 +1,145 @@
1
+ # Copyright (c) 2018 Anki, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License in the file LICENSE.txt or at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Photo related classes, functions, events and values.
17
+ """
18
+
19
+ # __all__ should order by constants, event classes, other classes, functions.
20
+ __all__ = ["PhotographComponent"]
21
+
22
+ import concurrent
23
+ from typing import List
24
+
25
+ from . import connection, util
26
+ from .messaging import protocol
27
+
28
+
29
+ class PhotographComponent(util.Component):
30
+ """Access the photos on Vector.
31
+
32
+ .. testcode::
33
+
34
+ import anki_vector
35
+ import io
36
+ from PIL import Image
37
+
38
+ with anki_vector.Robot() as robot:
39
+ for photo_info in robot.photos.photo_info:
40
+ print(f"Opening photo {photo_info.photo_id}")
41
+ photo = robot.photos.get_photo(photo_info.photo_id)
42
+ image = Image.open(io.BytesIO(photo.image))
43
+ image.show()
44
+
45
+ :param anki_vector.Robot robot: A reference to an instance of the Robot class. Used to make rpc calls.
46
+ """
47
+
48
+ def __init__(self, robot):
49
+ super().__init__(robot)
50
+ self._photo_info: List[protocol.PhotoInfo] = []
51
+
52
+ @property
53
+ def photo_info(self) -> List[protocol.PhotoInfo]:
54
+ """The information about what photos are stored on Vector.
55
+
56
+ If the photo info hasn't been loaded yet, accessing this property will request it from the robot.
57
+
58
+ .. testcode::
59
+
60
+ import anki_vector
61
+
62
+ with anki_vector.Robot() as robot:
63
+ for photo_info in robot.photos.photo_info:
64
+ print(f"photo_info.photo_id: {photo_info.photo_id}") # the id to use to grab a photo from the robot
65
+ print(f"photo_info.timestamp_utc: {photo_info.timestamp_utc}") # utc timestamp of when the photo was taken (according to the robot)
66
+ """
67
+ if not self._photo_info:
68
+ self.logger.debug("Photo list was empty. Lazy-loading photo list now.")
69
+ result = self.load_photo_info()
70
+ if isinstance(result, concurrent.futures.Future):
71
+ result.result()
72
+ return self._photo_info
73
+
74
+ @connection.on_connection_thread()
75
+ async def load_photo_info(self) -> protocol.PhotosInfoResponse:
76
+ """Request the photo information from the robot.
77
+
78
+ .. testcode::
79
+
80
+ import anki_vector
81
+
82
+ with anki_vector.Robot() as robot:
83
+ photo_info = robot.photos.load_photo_info()
84
+ print(f"photo_info: {photo_info}")
85
+
86
+ :return: UTC timestamp of the photo and additional data.
87
+ """
88
+ req = protocol.PhotosInfoRequest()
89
+ result = await self.grpc_interface.PhotosInfo(req)
90
+ self._photo_info = result.photo_infos
91
+ return result
92
+
93
+ @connection.on_connection_thread(log_messaging=False)
94
+ async def get_photo(self, photo_id: int) -> protocol.PhotoResponse:
95
+ """Download a full-resolution photo from the robot's storage.
96
+
97
+ .. testcode::
98
+
99
+ import anki_vector
100
+ import io
101
+ from PIL import Image
102
+
103
+ with anki_vector.Robot() as robot:
104
+ for photo_info in robot.photos.photo_info:
105
+ print(f"Opening photo {photo_info.photo_id}")
106
+ photo = robot.photos.get_photo(photo_info.photo_id)
107
+ image = Image.open(io.BytesIO(photo.image))
108
+ image.show()
109
+
110
+ :param photo_id: The id of the photo to download. It's recommended to get this
111
+ value from the photo_info list first.
112
+
113
+ :return: A response containing all of the photo bytes which may be rendered using
114
+ another library (like :mod:`PIL`)
115
+ """
116
+ req = protocol.PhotoRequest(photo_id=photo_id)
117
+ return await self.grpc_interface.Photo(req)
118
+
119
+ @connection.on_connection_thread(log_messaging=False)
120
+ async def get_thumbnail(self, photo_id: int) -> protocol.ThumbnailResponse:
121
+ """Download a thumbnail of a given photo from the robot's storage.
122
+
123
+ You may use this function to pull all of the images off the robot in a smaller format, and
124
+ then determine which one to download as full resolution.
125
+
126
+ .. testcode::
127
+
128
+ import anki_vector
129
+ from PIL import Image
130
+ import io
131
+
132
+ with anki_vector.Robot() as robot:
133
+ for photo_info in robot.photos.photo_info:
134
+ photo = robot.photos.get_thumbnail(photo_info.photo_id)
135
+ image = Image.open(io.BytesIO(photo.image))
136
+ image.show()
137
+
138
+ :param photo_id: The id of the thumbnail to download. It's recommended to get this
139
+ value from the photo_info list first.
140
+
141
+ :return: A response containing all of the thumbnail bytes which may be rendered using
142
+ another library (like :mod:`PIL`)
143
+ """
144
+ req = protocol.ThumbnailRequest(photo_id=photo_id)
145
+ return await self.grpc_interface.Thumbnail(req)
@@ -0,0 +1,176 @@
1
+ # Copyright (c) 2018 Anki, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License in the file LICENSE.txt or at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Support for Vector's distance sensor.
17
+
18
+ Vector's time-of-flight distance sensor has a usable range of about 30 mm to 1200 mm
19
+ (max useful range closer to 300mm for Vector) with a field of view of 25 degrees.
20
+
21
+ The distance sensor can be used to detect objects in front of the robot.
22
+ """
23
+
24
+ # __all__ should order by constants, event classes, other classes, functions.
25
+ __all__ = ["ProximityComponent", "ProximitySensorData"]
26
+
27
+ from . import util
28
+ from .events import Events
29
+ from .messaging import protocol
30
+
31
+
32
+ class ProximitySensorData:
33
+ """A distance sample from the time-of-flight sensor with metadata describing reliability of the measurement
34
+
35
+ The proximity sensor is located near the bottom of Vector between the two front wheels, facing forward. The
36
+ reported distance describes how far in front of this sensor the robot feels an obstacle is. The sensor estimates
37
+ based on time-of-flight information within a field of view which the engine resolves to a certain quality value.
38
+
39
+ Four additional flags are supplied by the engine to indicate whether this proximity data is considered valid
40
+ for the robot's internal pathfinding. Respecting these is optional, but will help python code respect the
41
+ behavior of the robot's innate object avoidance.
42
+ """
43
+
44
+ def __init__(self, proto_data: protocol.ProxData):
45
+ self._distance = util.Distance(distance_mm=proto_data.distance_mm)
46
+ self._signal_quality = proto_data.signal_quality
47
+ self._unobstructed = proto_data.unobstructed
48
+ self._found_object = proto_data.found_object
49
+ self._is_lift_in_fov = proto_data.is_lift_in_fov
50
+
51
+ @property
52
+ @util.block_while_none()
53
+ def distance(self) -> util.Distance:
54
+ """The distance between the sensor and a detected object
55
+
56
+ .. testcode::
57
+
58
+ import anki_vector
59
+
60
+ with anki_vector.Robot() as robot:
61
+ distance = robot.proximity.last_sensor_reading.distance
62
+ """
63
+ return self._distance
64
+
65
+ @property
66
+ @util.block_while_none()
67
+ def signal_quality(self) -> float:
68
+ """The quality of the detected object.
69
+
70
+ The proximity sensor detects obstacles within a given field of view,
71
+ this value represents the likelihood of the reported distance being
72
+ a solid surface.
73
+
74
+ .. testcode::
75
+
76
+ import anki_vector
77
+
78
+ with anki_vector.Robot() as robot:
79
+ signal_quality = robot.proximity.last_sensor_reading.signal_quality
80
+ """
81
+ return self._signal_quality
82
+
83
+ @property
84
+ @util.block_while_none()
85
+ def unobstructed(self) -> bool:
86
+ """The sensor has confirmed it has not detected anything up to its max range.
87
+
88
+ .. testcode::
89
+
90
+ import anki_vector
91
+
92
+ with anki_vector.Robot() as robot:
93
+ unobstructed = robot.proximity.last_sensor_reading.unobstructed
94
+ """
95
+ return self._unobstructed
96
+
97
+ @property
98
+ @util.block_while_none()
99
+ def found_object(self) -> bool:
100
+ """The sensor detected an object in the valid operating range.
101
+
102
+ .. testcode::
103
+
104
+ import anki_vector
105
+
106
+ with anki_vector.Robot() as robot:
107
+ found_object = robot.proximity.last_sensor_reading.found_object
108
+ """
109
+ return self._found_object
110
+
111
+ @property
112
+ @util.block_while_none()
113
+ def is_lift_in_fov(self) -> bool:
114
+ """Whether Vector's lift is blocking the time-of-flight sensor. While
115
+ the lift will send clear proximity signals, it's not useful for object
116
+ detection.
117
+
118
+ .. testcode::
119
+
120
+ import anki_vector
121
+
122
+ with anki_vector.Robot() as robot:
123
+ is_lift_in_fov = robot.proximity.last_sensor_reading.is_lift_in_fov
124
+ """
125
+ return self._is_lift_in_fov
126
+
127
+
128
+ class ProximityComponent(util.Component):
129
+ """Maintains the most recent proximity sensor data
130
+
131
+ This will be updated with every broadcast RobotState, and can be queried at any time. Two sensor readings are made available:
132
+ - the most recent data from the robot
133
+ - the most recent data which was considered valid by the engine for usage
134
+
135
+ An example of how to extract sensor data:
136
+
137
+ .. testcode::
138
+
139
+ import anki_vector
140
+
141
+ with anki_vector.Robot() as robot:
142
+ proximity_data = robot.proximity.last_sensor_reading
143
+ if proximity_data is not None:
144
+ print('Proximity distance: {0}'.format(proximity_data.distance))
145
+ """
146
+
147
+ def __init__(self, robot):
148
+ super().__init__(robot)
149
+ self._last_sensor_reading = None
150
+
151
+ # Subscribe to a callback that updates the robot's local properties - which includes proximity data.
152
+ self._robot.events.subscribe(self._on_robot_state,
153
+ Events.robot_state,
154
+ _on_connection_thread=True)
155
+
156
+ def close(self):
157
+ """Closing the touch component will unsubscribe from robot state updates."""
158
+ self._robot.events.unsubscribe(self._on_robot_state,
159
+ Events.robot_state)
160
+
161
+ @property
162
+ @util.block_while_none()
163
+ def last_sensor_reading(self) -> ProximitySensorData:
164
+ """:class:`anki_vector.proximity.ProximitySensorData`: The last reported sensor data.
165
+
166
+ .. testcode::
167
+
168
+ import anki_vector
169
+
170
+ with anki_vector.Robot() as robot:
171
+ last_sensor_reading = robot.proximity.last_sensor_reading
172
+ """
173
+ return self._last_sensor_reading
174
+
175
+ def _on_robot_state(self, _robot, _event_type, msg):
176
+ self._last_sensor_reading = ProximitySensorData(msg.prox_data)
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Copyright (c) 2019 Anki, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License in the file LICENSE.txt or at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ """ Reserve SDK Behavior Control
18
+
19
+ While this script runs, other SDK scripts may run and Vector will not perform most
20
+ default behaviors before/after they complete. This will keep Vector still.
21
+
22
+ High priority behaviors like returning to the charger in a low battery situation,
23
+ or retreating from a cliff will still take precedence.
24
+ """
25
+
26
+ from anki_vector import behavior, util
27
+
28
+
29
+ def hold_control():
30
+ args = util.parse_command_args()
31
+ with behavior.ReserveBehaviorControl(args.serial):
32
+ input("Vector behavior control reserved for SDK. Hit 'Enter' to release control.")
33
+
34
+
35
+ if __name__ == "__main__":
36
+ hold_control()