You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/module/README
+20-5Lines changed: 20 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,14 @@ Modular resources allows you to define custom components and services, and add t
9
9
For more information, see the [documentation](https://docs.viam.com/program/extend/modular-resources/).
10
10
11
11
## Project structure
12
-
The definition of the new resources are in the `src` directory. Within this directory are the `proto`and `gizmo` subdirectories.
12
+
The definition of the new resources are in the `src` directory. Within this directory are the `proto`, `gizmo`, and `summation` subdirectories.
13
13
14
-
The `proto` directory contains the `gizmo.proto` definition of all the message types and calls that can be made to the component. It also has the compiled python output of the protobuf definition.
14
+
The `proto` directory contains the `gizmo.proto` and `summation.proto` definitions of all the message types and calls that can be made to the Gizmo component and Summation service. It also has the compiled python output of the protobuf definition.
15
15
16
16
The `gizmo` directory contains all the necessary definitions for creating a custom `Gizmo` component type. The `api.py` file defines what a `Gizmo` can do (mirroring the `proto` definition), implements the gRPC `GizmoService` for receiving calls, and the gRPC `GizmoClient` for making calls. See the [API docs](https://docs.viam.com/program/extend/modular-resources/#apis) for more info. The `my_gizmo.py` file in contains the unique implementation of a `Gizmo`. This is defined as a specific `Model`. See the [Model docs](https://docs.viam.com/program/extend/modular-resources/#models) for more info.
17
17
18
+
Similarly, the `summation` directory contains the analogous definitions for the `Summation` service type. The files in this directory mirror the files in the `gizmo` directory.
19
+
18
20
There is also a `main.py` file, which creates a module, adds the desired resources, and starts the module. This file is called by the `run.sh` script, which is the entrypoint for this module. Read further to learn how to connect this module to your robot.
19
21
20
22
Outside the `src` directory, there is the `client.py` file. This can be used to test the module once it's connected to the robot. You will have to update the credentials and robot address in that file.
@@ -24,9 +26,9 @@ These steps assume that you have a robot available at [app.viam.com](app.viam.co
24
26
25
27
The `run.sh` script is the entrypoint for this module. To connect this module with your robot, you must add this module's entrypoint to the robot's config. For example, this could be `/home/viam-python-sdk/examples/module/run.sh`. See the [documentation](https://docs.viam.com/program/extend/modular-resources/#use-a-modular-resource-with-your-robot) for more details.
26
28
27
-
Once the module has been added to your robot, you will then need to add a component that uses the `MyGizmo` model. See the [documentation](https://docs.viam.com/program/extend/modular-resources/#configure-a-component-instance-for-a-modular-resource) for more details.
29
+
Once the module has been added to your robot, you will then need to add a component that uses the `MyGizmo` model. See the [documentation](https://docs.viam.com/program/extend/modular-resources/#configure-a-component-instance-for-a-modular-resource) for more details. You can add a service in a similar manner.
28
30
29
-
An example configuration for a Gizmo could look like this:
31
+
An example configuration for a Gizmo component and a Summation service could look like this:
30
32
```json
31
33
{
32
34
"components": [
@@ -41,11 +43,24 @@ An example configuration for a Gizmo could look like this:
After the robot has started and connected to the module, you can use the provided `client.py` to connect to your robot and make calls to your custom, modular resources.Ø
0 commit comments