Skip to content

Commit 66aa096

Browse files
VIC-11360 Redesign to structure for submodules (anki#12)
0 parents  commit 66aa096

131 files changed

Lines changed: 43757 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CODESTYLE.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Code Style Guide
2+
3+
The code should generally follow [PEP8](https://www.python.org/dev/peps/pep-0008/)
4+
5+
Code documentation should be written using Google style, which can be extracted
6+
using Sphinx:
7+
* http://google.github.io/styleguide/pyguide.html
8+
* http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
9+
10+
11+
Main style points to consider:
12+
13+
## Line Length
14+
15+
PEP8 recommends a maximum line length of 80 characters. While some lines
16+
are easier to read if they're a bit longer than that, generally try to stay
17+
within the 80 character limit.
18+
19+
Parameter lists can be wrapped and long strings can be split by enclosing them
20+
in parentheses:
21+
22+
````python
23+
long_string = ('First long line...'
24+
'Second long line')
25+
````
26+
27+
or by using triple quotes.
28+
29+
## White Space
30+
31+
Indentation should be made using 4 space characters.
32+
33+
* Two blank lines between class definitions and top-level functions
34+
* One blank line between methods (generally)
35+
36+
Follow [PEP8 guidelines](https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements)
37+
for whitespace in expressions and statements.
38+
39+
## Imports
40+
41+
Import statements should be arranged in three blocks at the head of the file
42+
(though after the module documentation). Each block of imports should be in
43+
alphabetical order.
44+
45+
1. The first block should be Python-provided packages (eg. `sys`)
46+
2. The second block should be third-party packages (eg. `numpy`)
47+
3. The final block should be local packages and module (eg. `from . import camera`)
48+
49+
````python
50+
import os
51+
import sys
52+
53+
import numpy
54+
55+
from . import camera
56+
from . import event
57+
````
58+
59+
Wildcard imports (`from module import *`) should not be used outside of tests.
60+
61+
Additionally it is generally useful to avoid importing variables from modules
62+
directly into the local namespace (`from module import some_object`) - Doing
63+
so means you now have two references to to the same thing, which impedes
64+
mocking during unit tests.
65+
66+
Better instead to import the module and reference a qualified name (`import module`
67+
and `module.some_object`).
68+
69+
## Names
70+
71+
* Module level constants should be in CAPS
72+
* Class names should be CamelCase
73+
* Variables, attributes, functions, methods and properties should be lowercase_with_underscores
74+
* Variables, attributes, functions, methods and properties can be named with a
75+
leading underscore to indicate that they're "private"
76+
77+
## Documentation
78+
79+
See http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
80+
for documentation examples.
81+
82+
* Module-level documentation should appear first in the file, before imports
83+
* All public-facing classes, functions, methods etc should be documented
84+
* The first line of a docstring should contain the summary of what the item does.
85+
This should be followed by a blank line and the extended description, if any.
86+
* Use Sphinx-friendly markup (per the Google guide above) so that cross-references
87+
work automatically and examples are formatted correctly.
88+
89+
### Documenting properties and attributes
90+
91+
For class and object attributes, use the `#:` comment syntax rather than a
92+
trailing docstring. Instance attributes can be documented in the `__init__`
93+
constructor.
94+
95+
Properties should use a docstring like any other method, but should be
96+
written in the same style as an attribute, as that's how they'll be presented
97+
in Sphinx (ie. as `return_type: description`).
98+
99+
Properties with setters must have the docstring on the getter rather than
100+
the setter.
101+
102+
103+
```python
104+
class MyClass:
105+
"""One line summary of class.
106+
107+
Docstring for constructor should appear in the class description
108+
109+
:param default_timeout: Default number of seconds for operations to
110+
wait for timeout.
111+
"""
112+
#: string: Description of a class-level attribute. The description
113+
#: may span multiple lines as long as they all begin with #:
114+
class_level_attr = ''
115+
116+
def __init__(self, default_timeout: int = None):
117+
#: int: The default number of seconds for operations to wait for timeout.
118+
self.default_timeout = default_timeout
119+
120+
@property
121+
def timeout_enabled(self):
122+
"""bool: True if a value for :attr:`default_timeout` has been set."""
123+
return self.default_timeout is not None
124+
```
125+
126+
127+
## Exceptions
128+
129+
Wherever practical, catch explicit exception classes rather than using
130+
a bare try/except statement (or matching `Exception`).
131+
132+
To re-raise the original exception use `raise` by itself or
133+
`raise MyException() from exc`
134+
(rather than `raise exc`) to maintain the original stack trace.

LICENSE.txt

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
Unless otherwise stated in that file, or the folder containing that file, all
2+
files in the Anki Vector SDK are Copyright (c) 2018 Anki Inc. and licensed under
3+
the Apache 2.0 License:
4+
5+
Apache License
6+
Version 2.0, January 2004
7+
http://www.apache.org/licenses/
8+
9+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10+
11+
1. Definitions.
12+
13+
"License" shall mean the terms and conditions for use, reproduction,
14+
and distribution as defined by Sections 1 through 9 of this document.
15+
16+
"Licensor" shall mean the copyright owner or entity authorized by
17+
the copyright owner that is granting the License.
18+
19+
"Legal Entity" shall mean the union of the acting entity and all
20+
other entities that control, are controlled by, or are under common
21+
control with that entity. For the purposes of this definition,
22+
"control" means (i) the power, direct or indirect, to cause the
23+
direction or management of such entity, whether by contract or
24+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
25+
outstanding shares, or (iii) beneficial ownership of such entity.
26+
27+
"You" (or "Your") shall mean an individual or Legal Entity
28+
exercising permissions granted by this License.
29+
30+
"Source" form shall mean the preferred form for making modifications,
31+
including but not limited to software source code, documentation
32+
source, and configuration files.
33+
34+
"Object" form shall mean any form resulting from mechanical
35+
transformation or translation of a Source form, including but
36+
not limited to compiled object code, generated documentation,
37+
and conversions to other media types.
38+
39+
"Work" shall mean the work of authorship, whether in Source or
40+
Object form, made available under the License, as indicated by a
41+
copyright notice that is included in or attached to the work
42+
(an example is provided in the Appendix below).
43+
44+
"Derivative Works" shall mean any work, whether in Source or Object
45+
form, that is based on (or derived from) the Work and for which the
46+
editorial revisions, annotations, elaborations, or other modifications
47+
represent, as a whole, an original work of authorship. For the purposes
48+
of this License, Derivative Works shall not include works that remain
49+
separable from, or merely link (or bind by name) to the interfaces of,
50+
the Work and Derivative Works thereof.
51+
52+
"Contribution" shall mean any work of authorship, including
53+
the original version of the Work and any modifications or additions
54+
to that Work or Derivative Works thereof, that is intentionally
55+
submitted to Licensor for inclusion in the Work by the copyright owner
56+
or by an individual or Legal Entity authorized to submit on behalf of
57+
the copyright owner. For the purposes of this definition, "submitted"
58+
means any form of electronic, verbal, or written communication sent
59+
to the Licensor or its representatives, including but not limited to
60+
communication on electronic mailing lists, source code control systems,
61+
and issue tracking systems that are managed by, or on behalf of, the
62+
Licensor for the purpose of discussing and improving the Work, but
63+
excluding communication that is conspicuously marked or otherwise
64+
designated in writing by the copyright owner as "Not a Contribution."
65+
66+
"Contributor" shall mean Licensor and any individual or Legal Entity
67+
on behalf of whom a Contribution has been received by Licensor and
68+
subsequently incorporated within the Work.
69+
70+
2. Grant of Copyright License. Subject to the terms and conditions of
71+
this License, each Contributor hereby grants to You a perpetual,
72+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73+
copyright license to reproduce, prepare Derivative Works of,
74+
publicly display, publicly perform, sublicense, and distribute the
75+
Work and such Derivative Works in Source or Object form.
76+
77+
3. Grant of Patent License. Subject to the terms and conditions of
78+
this License, each Contributor hereby grants to You a perpetual,
79+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80+
(except as stated in this section) patent license to make, have made,
81+
use, offer to sell, sell, import, and otherwise transfer the Work,
82+
where such license applies only to those patent claims licensable
83+
by such Contributor that are necessarily infringed by their
84+
Contribution(s) alone or by combination of their Contribution(s)
85+
with the Work to which such Contribution(s) was submitted. If You
86+
institute patent litigation against any entity (including a
87+
cross-claim or counterclaim in a lawsuit) alleging that the Work
88+
or a Contribution incorporated within the Work constitutes direct
89+
or contributory patent infringement, then any patent licenses
90+
granted to You under this License for that Work shall terminate
91+
as of the date such litigation is filed.
92+
93+
4. Redistribution. You may reproduce and distribute copies of the
94+
Work or Derivative Works thereof in any medium, with or without
95+
modifications, and in Source or Object form, provided that You
96+
meet the following conditions:
97+
98+
(a) You must give any other recipients of the Work or
99+
Derivative Works a copy of this License; and
100+
101+
(b) You must cause any modified files to carry prominent notices
102+
stating that You changed the files; and
103+
104+
(c) You must retain, in the Source form of any Derivative Works
105+
that You distribute, all copyright, patent, trademark, and
106+
attribution notices from the Source form of the Work,
107+
excluding those notices that do not pertain to any part of
108+
the Derivative Works; and
109+
110+
(d) If the Work includes a "NOTICE" text file as part of its
111+
distribution, then any Derivative Works that You distribute must
112+
include a readable copy of the attribution notices contained
113+
within such NOTICE file, excluding those notices that do not
114+
pertain to any part of the Derivative Works, in at least one
115+
of the following places: within a NOTICE text file distributed
116+
as part of the Derivative Works; within the Source form or
117+
documentation, if provided along with the Derivative Works; or,
118+
within a display generated by the Derivative Works, if and
119+
wherever such third-party notices normally appear. The contents
120+
of the NOTICE file are for informational purposes only and
121+
do not modify the License. You may add Your own attribution
122+
notices within Derivative Works that You distribute, alongside
123+
or as an addendum to the NOTICE text from the Work, provided
124+
that such additional attribution notices cannot be construed
125+
as modifying the License.
126+
127+
You may add Your own copyright statement to Your modifications and
128+
may provide additional or different license terms and conditions
129+
for use, reproduction, or distribution of Your modifications, or
130+
for any such Derivative Works as a whole, provided Your use,
131+
reproduction, and distribution of the Work otherwise complies with
132+
the conditions stated in this License.
133+
134+
5. Submission of Contributions. Unless You explicitly state otherwise,
135+
any Contribution intentionally submitted for inclusion in the Work
136+
by You to the Licensor shall be under the terms and conditions of
137+
this License, without any additional terms or conditions.
138+
Notwithstanding the above, nothing herein shall supersede or modify
139+
the terms of any separate license agreement you may have executed
140+
with Licensor regarding such Contributions.
141+
142+
6. Trademarks. This License does not grant permission to use the trade
143+
names, trademarks, service marks, or product names of the Licensor,
144+
except as required for reasonable and customary use in describing the
145+
origin of the Work and reproducing the content of the NOTICE file.
146+
147+
7. Disclaimer of Warranty. Unless required by applicable law or
148+
agreed to in writing, Licensor provides the Work (and each
149+
Contributor provides its Contributions) on an "AS IS" BASIS,
150+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151+
implied, including, without limitation, any warranties or conditions
152+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
153+
PARTICULAR PURPOSE. You are solely responsible for determining the
154+
appropriateness of using or redistributing the Work and assume any
155+
risks associated with Your exercise of permissions under this License.
156+
157+
8. Limitation of Liability. In no event and under no legal theory,
158+
whether in tort (including negligence), contract, or otherwise,
159+
unless required by applicable law (such as deliberate and grossly
160+
negligent acts) or agreed to in writing, shall any Contributor be
161+
liable to You for damages, including any direct, indirect, special,
162+
incidental, or consequential damages of any character arising as a
163+
result of this License or out of the use or inability to use the
164+
Work (including but not limited to damages for loss of goodwill,
165+
work stoppage, computer failure or malfunction, or any and all
166+
other commercial damages or losses), even if such Contributor
167+
has been advised of the possibility of such damages.
168+
169+
9. Accepting Warranty or Additional Liability. While redistributing
170+
the Work or Derivative Works thereof, You may choose to offer,
171+
and charge a fee for, acceptance of support, warranty, indemnity,
172+
or other liability obligations and/or rights consistent with this
173+
License. However, in accepting such obligations, You may act only
174+
on Your own behalf and on Your sole responsibility, not on behalf
175+
of any other Contributor, and only if You agree to indemnify,
176+
defend, and hold each Contributor harmless for any liability
177+
incurred by, or claims asserted against, such Contributor by reason
178+
of your accepting any such warranty or additional liability.
179+
180+
END OF TERMS AND CONDITIONS

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Anki Vector - Python SDK
2+
3+
## Getting Started
4+
5+
Before connecting, you will need:
6+
7+
* Vector's Name: This is the name displayed on his face for BLE pairing after you double-click while Vector is on the charger. Example: `Vector-A1B2`
8+
* Vector's IP Address: The ip address can be found by first placing Vector on the charger, then double-clicking the button on his back, and finally raising and lowering his arms. It is possible for your ip to change based on your network settings, so it must be updated accordingly. Example: `192.168.43.48`
9+
* Vector's Serial Number: You may find this number on the underside of your robot. Example: `00e20115`
10+
11+
These will be needed to run the configure.py script and set up authentication from your device to your Vector.
12+
13+
Your device must have Python 3.6.1 or later installed. Please see the documentation pages mentioned below for instructions to install Python.
14+
15+
16+
---
17+
18+
Check out the documentation for setup instructions by opening docs/build/html/index.html in your browser.
19+
20+
---
21+
22+
During setup, you will configure your `anki_vector` SDK authentication from a terminal using `configure.py`.
23+
24+
By running this script, you will be asked to provide your Anki account credentials, and the script will download an authentication token and cert that will grant you access to the robot and his capabilities (such as camera and audio) as well as data stored on the robot (such as faces and photos).
25+
26+
The downloaded access token is equivalent to your account credentials. It will be stored in your user directory (~/.anki_vector) along with a robot identity certificate and other useful data for establishing a connection. Do not share your access token.
27+
28+
If you have any trouble, please post to the Vector forums at https://forums.anki.com/
29+
30+
---
31+
32+
If you encounter any issues, please reach out to the forums team and let us know at https://forums.anki.com/
33+
34+
---
35+
36+
Use of Vector and the Vector SDK is subject to Anki's Privacy Policy and Terms and Conditions.
37+
38+
https://www.anki.com/en-us/company/privacy
39+
https://www.anki.com/en-us/company/terms-and-conditions

anki_vector/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
# http://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+
SDK for programming with the Anki Vector robot.
17+
"""
18+
19+
import sys
20+
import logging
21+
22+
from . import messaging
23+
from .robot import Robot, AsyncRobot
24+
from .version import __version__
25+
26+
logger = logging.getLogger('vector') # pylint: disable=invalid-name
27+
28+
if sys.version_info < (3, 6, 1):
29+
sys.exit('anki_vector requires Python 3.6.1 or later')
30+
31+
__all__ = ['Robot', 'AsyncRobot', 'logger', 'messaging']

0 commit comments

Comments
 (0)