|
4 | 4 | [](https://github.com/viamrobotics/viam-python-sdk/blob/main/LICENSE)
|
5 | 5 |
|
6 | 6 | ## (In)stability Notice
|
7 |
| -This is an alpha release of the Viam Python SDK. Stability is not guaranteed. Breaking changes are likely to occur, and occur often. |
| 7 | + |
| 8 | +> **Warning** |
| 9 | +> This is an alpha release of the Viam Python SDK. Stability is not guaranteed. Breaking changes are likely to occur, and occur often. |
8 | 10 |
|
9 | 11 | ## Installation - pre PyPI
|
10 | 12 |
|
11 |
| -`pip install git+https://github.com/viamrobotics/python-sdk.git` |
| 13 | +To install the Viam Python SDK from the current `main` branch, use the following command: |
12 | 14 |
|
13 |
| -This will install the current `main` branch to your project. If you would like a specific branch or commit, you can do so with the command |
| 15 | +``` |
| 16 | +pip install git+https://github.com/viamrobotics/python-sdk.git |
| 17 | +``` |
14 | 18 |
|
15 |
| -`pip install git+https://github.com/viamrobotics/python-sdk.git@FULL_COMMIT_HASH` |
| 19 | +To install the the Viam Python SDK from a specific branch or commit, use the following command: |
| 20 | + |
| 21 | +``` |
| 22 | +pip install git+https://github.com/viamrobotics/python-sdk.git@FULL_COMMIT_HASH |
| 23 | +``` |
16 | 24 |
|
17 | 25 | ### Upgrading
|
18 |
| -Because the SDK is under active development, we suggest that you upgrade the package frequently. To do so, simply run the `pip install` command with the `-U` option: |
19 | 26 |
|
20 |
| -`pip install -U git+https://github.com/viamrobotics/python-sdk.git` |
| 27 | +> **Note** |
| 28 | +> Because the SDK is under active development, we suggest that you upgrade the package frequently. |
| 29 | + |
| 30 | +To upgrade, simply run the `pip install` command with the `-U` option: |
| 31 | + |
| 32 | +``` |
| 33 | +pip install -U git+https://github.com/viamrobotics/python-sdk.git |
| 34 | +``` |
| 35 | + |
| 36 | +## Configure a client application at [app.viam.com](https://app.viam.com) |
| 37 | + |
| 38 | +Your client application does not directly interact with your hardware. Instead, your client application makes calls to the viam-server which can then issues commands to your hardware or read from sensors. |
21 | 39 |
|
22 |
| -## Easy Setup via [app.viam.com](app.viam.com) |
23 |
| -The easiest way to get started writing a client application (that is, one which is not directly responsible for interacting with hardware, |
24 |
| -but rather calls into the viam-server to actuate hardware or read from sensors), is to navigate to the robot page on [app.viam.com](app.viam.com), |
25 |
| -select the `CONNECT` tab, and copy the boilerplate code from the section labeled `Python SDK`. |
| 40 | +To create a client application, to navigate to [app.viam.com](https://app.viam.com). After you log in, perform these steps: |
26 | 41 |
|
27 |
| -It is recommended that you save and run this simple program. Doing so will ensure that the python-sdk is properly installed, |
28 |
| -that the `viam-server` instance on your robot is alive, and that the computer running the program is able to connect to that instance. |
| 42 | +1. Create a location (for example `home`) |
| 43 | +2. Create a robot (for example `arduino`) |
| 44 | +3. Follow the steps on the setup tab: |
| 45 | + 1. Setup Viam App Config on Single Board Computer (SBC) |
| 46 | + 2. Download and Install Viam Server |
| 47 | + 3. Wait until the robot shows as connected. If this doesn't happen try restarting the viam-server: |
| 48 | + ``` |
| 49 | + sudo systemctl restart viam-server |
| 50 | + ``` |
| 51 | +
|
| 52 | +Next, select the `CONNECT` tab in the Viam Web UI, and copy the boilerplate code from the section labeled `Python SDK`. |
| 53 | +
|
| 54 | +To ensure the installation succeeded and the systems are functional, save and run this simple program. If the program runs successfully, the python-sdk is properly installed, the `viam-server` instance on your robot is alive, and the computer running the program is able to connect to that instance. |
29 | 55 |
|
30 | 56 | ## Examples
|
31 |
| -The [Example Usage](https://python.viam.dev/examples/example.html) has the info required to access a component, build a custom component, and expose |
| 57 | +Read the [Example Usage](https://python.viam.dev/examples/example.html) page, to learn how to access a component, build a custom component, and expose |
32 | 58 | custom components as a remote to existing robots.
|
33 | 59 |
|
34 |
| -Further examples can be found in the `examples` directory. |
| 60 | +More examples can be found in the [`examples`](/examples) directory. |
35 | 61 |
|
36 | 62 | ## The `do` method
|
37 | 63 | Every component provided by the SDK includes a generic `do` method which is useful to execute commands that are not already defined on the component.
|
38 | 64 | ```python
|
39 | 65 | async def do(self, command: Dict[str, Any]) -> Dict[str, Any]
|
40 | 66 | ```
|
41 | 67 |
|
42 |
| -If this is not generic enough, you can also create your own custom component by subclassing the `viam.components.generic.Generic` component |
43 |
| -class. For more details, you can view the documentation for the `Generic` component. |
| 68 | +If this is not generic enough, you can also create your own custom component by subclassing the [`viam.components.generic.Generic`](https://python.viam.dev/autoapi/viam/components/generic/index.html) component |
| 69 | +class. For more details, you can view the documentation for the [`Generic`](https://python.viam.dev/autoapi/viam/components/generic/index.html) component. |
44 | 70 |
|
45 | 71 | ## Documentation
|
46 | 72 | Documentation, like this entire project, is under active development, and can be found at [python.viam.dev](https://python.viam.dev).
|
47 | 73 |
|
48 | 74 | ---
|
49 | 75 | ## Development
|
50 |
| -To develop the python SDK, please see the [contribution guidelines](https://python.viam.dev/contributing.html). |
| 76 | +To contribute to the python SDK, please see the [contribution guidelines](https://python.viam.dev/contributing.html). |
| 77 | + |
51 | 78 | ### Adding new component types
|
52 |
| -The SDK provides a number of abstract base components to start. To add more abstract base components, please make sure you follow these guidelines: |
53 |
| - |
54 |
| -* Create a new directory in `viam.components` with the name of the new component |
55 |
| -* Implement 3 new files in the newly created directory: |
56 |
| - * `__init__.py`, where you should include the imports for the package |
57 |
| - * `{COMPONENT}.py`, which should define the requirements of the component |
58 |
| - * `service.py`, which should implement the gRPC service for this component |
59 |
| -* Add the new service in `viam.rpc.server` to expose the gRPC service |
60 |
| -* If the component needs to be included to the robot/status service, add it in `viam.robot.service` |
61 |
| -* Write tests and add the component to `tests.mocks.components` |
62 |
| -* Add the component to `examples.server.v1.components` and its corresponding concrete type in `examples.server.v1.server` |
| 79 | +The SDK provides a number of abstract base components. To add more abstract base components, follow these steps: |
| 80 | + |
| 81 | +1. Create a new directory in `viam.components` with the name of the new component |
| 82 | +2. Create 3 new files in the newly created directory: |
| 83 | + 1. Add all imports for the package in `__init__.py` |
| 84 | + 2. Define all requirements of the component in `{COMPONENT}.py` |
| 85 | + 3. Implement the gRPC service for the new component in `service.py` |
| 86 | +3. Add the new service to [`viam.rpc.server`](https://python.viam.dev/autoapi/viam/rpc/server/index.html) to expose the gRPC service |
| 87 | +4. If the component needs to be included in the robot/status service, add it in [`viam.robot.service`](https://python.viam.dev/autoapi/viam/robot/service/index.html) |
| 88 | +5. Write tests for the new component and add the component to `tests.mocks.components` |
| 89 | +6. Add the component to `examples.server.v1.components` and its corresponding concrete type in `examples.server.v1.server` |
63 | 90 |
|
64 | 91 | ## License
|
65 | 92 | Copyright 2021-2022 Viam Inc.
|
|
0 commit comments