Skip to content

Commit

Permalink
Merge branch 'main' into DOCS-1028-add-movement-sensor-test
Browse files Browse the repository at this point in the history
  • Loading branch information
skyleilani authored Sep 14, 2023
2 parents 56f4541 + 0dfd884 commit a64acff
Show file tree
Hide file tree
Showing 46 changed files with 737 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lexi-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
- uses: npentrel/lexi@v1.1
- uses: Rebilly/lexi@v2
with:
github-token: ${{ secrets.PR_TOKEN }}
glob: '**/*.md'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/services/ml-models-service.png
Binary file not shown.
Binary file removed assets/services/vision/color_detector.png
Binary file not shown.
Binary file removed assets/services/vision/detector_3d_segmenter.png
Binary file not shown.
Binary file removed assets/services/vision/mlmodel.png
Binary file not shown.
Binary file removed assets/services/vision/obstacles_pointcloud.png
Binary file not shown.
Binary file removed assets/tutorials/confetti-bot/app-board-create.png
Binary file not shown.
Binary file removed assets/tutorials/tipsy/app-board-create.png
Binary file not shown.
Binary file removed assets/tutorials/tipsy/app-motor-create.png
Binary file not shown.
Binary file removed assets/tutorials/tipsy/app-service-ml-create.png
Binary file not shown.
Binary file removed assets/tutorials/tipsy/app-service-vision-create.png
Binary file not shown.
7 changes: 4 additions & 3 deletions docs/extend/modular-resources/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Integrate Modular Resources into your Robot"
title: "Extend Viam with Modular Resources"
linkTitle: "Modular Resources"
weight: 10
type: "docs"
Expand Down Expand Up @@ -35,7 +35,7 @@ Once the module has been uploaded to the Registry, you can [deploy the module](/
### Uploading to Viam Registry

After you finish programming your module, you can [upload your module to the Viam registry](/extend/modular-resources/upload/) to make it available for deployment to robots.
As part of the upload process, you decide whether your module is *public* (visible to all users) or *private* (visible only to other members of your [organization](/manage/fleet/organizations/)).
As part of the upload process, you decide whether your module is *private* (visible only to other members of your [organization](/manage/fleet/organizations/)), or *public* (visible to all Viam users).

You can see details about each module in the [Viam registry](https://app.viam.com/registry) on its module details page.
See the [Odrive module](https://app.viam.com/module/viam/odrive) for an example.
Expand All @@ -47,7 +47,8 @@ When you make changes to your module, you can [uploaded the newer version](/exte

Once you [upload a module to the Viam registry](/extend/modular-resources/upload/), you can [deploy the module](/extend/modular-resources/configure/) to any robot in your organization from [the Viam app](https://app.viam.com/).
Navigate to your robot's **Configuration** tab, click the **+ Create component** button, then start typing the name of the module you would like to deploy.
If you uploaded your module and set its visibility to private, the module will only appear for users within your [organization](/manage/fleet/organizations/).

By default, a newly-created module is *private*, meaning that the module will only appear for users within your [organization](/manage/fleet/organizations/), but you can later [update your module](/extend/modular-resources/upload/#update-an-existing-module) to set it to be *public*, which makes your module available to all Viam users.

When you deploy a module to your robot, you can [choose how to update that module](/extend/modular-resources/configure/#configure-version-update-management-for-a-registry-module) when new versions become available.

Expand Down
86 changes: 65 additions & 21 deletions docs/extend/modular-resources/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ no_list: true
---

You can extend Viam by adding a module on your robot that provides one or more {{< glossary_tooltip term_id="resource" text="modular resources" >}} ([components](/components/) or [services](/services/)).
You can [add a module from the Viam registry](#add-a-module-from-the-viam-registry), or you can [code your own module and add it to your robot locally](#add-a-local-module-to-your-robot).

You can [add a module from the Viam registry](#add-a-module-from-the-viam-registry), or you can [add a local module](#local-modules).

See [Key Concepts of Modular Resource APIs](/extend/modular-resources/key-concepts/) for more information.

Expand Down Expand Up @@ -199,46 +200,89 @@ The custom model is configured as a component with the name "my-realsense".
{{% /tab %}}
{{% /tabs %}}

## Add a local module to your robot
## Local modules

If you are developing your own modular resource, and intend to deploy it to your robot locally, first follow [these steps](/extend/modular-resources/create/) to code your own module and generate an executable.
If you are using a pre-built modular resource, make sure you install the module and determine the filename of [the module's executable](/extend/modular-resources/create/#compile-the-module-into-an-executable).
If you wish to add a module to your robot without uploading it to the Viam registry, you can add your module as a *local module*.

Follow these steps to configure a module and its modular resources locally:
You can add your own custom modules as local modules, or you can add pre-built modules written by other Viam users.

1. [Save the executable](#make-sure-viam-server-can-access-your-executable) in a location your `viam-server` instance can access.
2. [Add a **module**](#configure-your-module) referencing this executable to the configuration of your robot.
3. [Add a new component or service](#configure-your-modular-resource) referencing the modular resource provided by the configured **module** to the configuration of your robot.
### Prepare a local module

### Make sure `viam-server` can access your executable
First determine the module you wish to add as a local module:

Ensure that your module executable is saved where the instance of `viam-server` behind your robot can read and execute it.
- If you are adding your own custom module, be sure that you have followed the steps to [create your own module](/extend/modular-resources/create/) to code and compile your module and generate an executable.
- If you are using a pre-built module, make sure you have installed the module and determined the filename of [the module's executable](/extend/modular-resources/create/#compile-the-module-into-an-executable).

For example, if you are running `viam-server` on an Raspberry Pi, you'll need to save the module on the Pi's filesystem.
Then, ensure that `viam-server` is able to find and run the executable:

Obtain the real (absolute) path to the executable file on your computer's filesystem by running the following command in your terminal:
- Ensure that the module executable is saved to a location on the filesystem of your robot that `viam-server` can access.
For example, if you are running `viam-server` on an Raspberry Pi, you must save the module executable on the Pi's filesystem.
- Ensure that this file is executable (runnable) with the following command:

``` shell
realpath <path-to-your-module-directory>/<your-module>
```
``` shell
sudo chmod a+rx <path-to-your-module-executable>
```

See the instructions to [compile your module into an executable](/extend/modular-resources/create/#compile-the-module-into-an-executable) for more information.

### Add a local module

To add a local module on your robot:

1. Navigate to the **Config** tab of your robot's page on [the Viam app](https://app.viam.com).
- If you are adding a modular [component](/components/), click the **Components** subtab and click **Create component**.
- If you are adding a modular [service](/services/), click the **Services** subtab and click **Create service**.

1. Then, select the `local modular resource` type from the list.

{{<imgproc src="extend/modular-resources/configure/add-local-module-list.png" resize="300x" declaredimensions=true alt="The add a component modal showing the list of components to add with 'local modular resource' shown at the bottom">}}

1. On the next screen:
- Select the type of modular resource provided by your module, such as a [camera](/components/camera/), from the drop down menu.
- Enter the {{< glossary_tooltip term_id="model-namespace-triplet" text="model namespace triplet">}} of your modular resource's [model](/extend/modular-resources/key-concepts/#models).
If you are adding a pre-built modular resource, the model triplet should be provided for you in the module's documentation.
- Enter a name for this instance of your modular resource.
This name must be different from the module name.

{{<imgproc src="extend/modular-resources/configure/add-local-module-create.png" resize="400x" declaredimensions=true alt="The add a component modal showing the create a module step for an intel realsense module">}}

1. Click **Create** to create the modular resource provided by the local module.

### Configure your module
You can also add the module directly, without first adding its modular component or service:

To configure your new *module* on your robot, navigate to the **Config** tab of your robot's page on [the Viam app](https://app.viam.com) and click on the **Modules** subtab.
1. Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com).
1. Click on the **Modules** subtab.
1. Scroll to the **Add local module** section.
1. Enter a **Name** for this instance of your modular resource.
1. Enter the [module's executable path](/extend/modular-resources/create/#compile-the-module-into-an-executable).
This path must be the absolute path to the executable on your robot's filesystem.
1. Then, click the **Add module** button, and click **Save config**.

{{<imgproc src="extend/modular-resources/configure/add-local-module-csi-cam.png" resize="600x" declaredimensions=true alt="The add a local module pane with name 'my-csi-ca' and executable path '/usr/local/bin/viam-csi'">}}

This example shows the configuration for adding a [CSI camera](/extend/modular-resources/examples/csi/) as a local module.

## Configure a local module

Once you have added a modular resource to your robot, you can view and configure the module itself from the **Modules** subtab:

1. Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com).
1. Click on the **Modules** subtab.
Local modules you have added to your robot appear under the **Local** section.

The following properties are available for modules:

| Name | Type | Inclusion | Description |
| ---- | ---- | --------- | ----------- |
`name` | string | **Required**| Name of the module you are registering. |
`executable_path` | string | **Required**| The robot's computer's filesystem path to the module executable. |
`executable_path` | string | **Required**| The absolute path to the executable on your robot's filesystem. |

Add these properties to your module's configuration:

{{< tabs >}}
{{% tab name="Config Builder" %}}

{{< imgproc src="/program/modular-resources/module-ui-config.png" alt="Creation of a new module in the Viam app config builder." resize="1000x" >}}
{{<imgproc src="extend/modular-resources/configure/add-local-module-config-builder.png" resize="600x" declaredimensions=true alt="The add a local module pane with an example name and executable path">}}

{{% /tab %}}
{{% tab name="JSON Template" %}}
Expand All @@ -257,9 +301,9 @@ Add these properties to your module's configuration:
{{% /tab %}}
{{% /tabs %}}

### Configure your modular resource
### Configure a modular resource

Once you have configured a module as part of your robot configuration, you can add any number of the resources that the module makes available to your robot by adding new components or services configured with your modular resources' [model](/extend/modular-resources/key-concepts/#models).
Once you have added a local module to your robot, you can add any number of the {{< glossary_tooltip term_id="resource" text="resources" >}} provided by that module to your robot by adding new components or services that use your modular resources' [model](/extend/modular-resources/key-concepts/#models).

The following properties are available for modular resources:

Expand Down
4 changes: 2 additions & 2 deletions docs/extend/modular-resources/create/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A common use case for modular resources is to create a new [model](/extend/modul
Once you have created your modular resource, you can use the [Viam CLI](/manage/cli/) to [upload your modular resource](/extend/modular-resources/upload/) to the [Viam registry](https://app.viam.com/registry), to share it with other Viam users or just to other users in your organization.
You can also configure [automatic uploads of new versions of your module](/extend/modular-resources/upload/#update-an-existing-module-using-a-github-action) as part of a continuous integration (CI) workflow, using a GitHub Action.

Alternatively, you can add your module locally to your robot without uploading to the Viam registry.
You can also add your module to your robot as a [local module](/extend/modular-resources/configure/#local-modules), without uploading it to the Viam registry.

## Create a custom module

Expand Down Expand Up @@ -468,7 +468,7 @@ Otherwise, the class won’t instantiate.

### Compile the module into an executable

To [add a module](/extend/modular-resources/configure/#configure-your-module) to the configuration of your robot, you need to have an [executable](https://en.wikipedia.org/wiki/Executable) that runs your module when executed, can take a local socket as a command line argument, and cleanly exits when sent a termination signal.
To [add a module](/extend/modular-resources/configure/) to the configuration of your robot, you need to have an [executable](https://en.wikipedia.org/wiki/Executable) that runs your module when executed, can take a local socket as a command line argument, and cleanly exits when sent a termination signal.

Your options for completing this step are flexible, as this file does not need to be in a raw binary format.

Expand Down
4 changes: 4 additions & 0 deletions docs/extend/modular-resources/examples/csi.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ Next, add the following JSON object to your components array to configure a `csi
{{% /tab %}}
{{< /tabs >}}

For more information, see [installing local modules](/extend/modular-resources/configure/#local-modules).

Edit and fill in the attributes to configure your component.

The following attributes are available for the `viam:camera:csi` model:
Expand All @@ -138,3 +140,5 @@ The following attributes are available for the `viam:camera:csi` model:
Then, save the config.

Check the [**Logs** tab](/program/debug/) of your robot in the Viam app to make sure your camera has connected and no errors are being raised.

For more information, see [installing local modules](/extend/modular-resources/configure/#local-modules).
2 changes: 1 addition & 1 deletion docs/extend/modular-resources/examples/custom-arm.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ The best practice with the Python SDK is to put `pass` or raise an `NotImplement

### Compile the module into an executable

To [add a module](/extend/modular-resources/configure/#configure-your-module) to the configuration of your robot, you need to have an [executable](https://en.wikipedia.org/wiki/Executable) that runs your module when executed, can take a local socket as a command line argument, and cleanly exits when sent a termination signal.
To [add a module](/extend/modular-resources/configure/) to the configuration of your robot, you need to have an [executable](https://en.wikipedia.org/wiki/Executable) that runs your module when executed, can take a local socket as a command line argument, and cleanly exits when sent a termination signal.

Your options for completing this step are flexible, as this file does not need to be in a raw binary format.

Expand Down
4 changes: 2 additions & 2 deletions docs/extend/modular-resources/upload/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To upload your custom module to the [Viam registry](https://app.viam.com/registr
<td><code>visibility</code></td>
<td>string</td>
<td><strong>Required</strong></td>
<td>Whether the module is visible to all Viam users (<code>public</code>), or accessible only to members of your <a href="/manage/fleet/organizations/">organization</a> (<code>private</code>). You can change this setting later using the <code>viam module update</code> command.<br><br>Default: <code>private</code></td>
<td>Whether the module is accessible only to members of your <a href="/manage/fleet/organizations/">organization</a> (<code>private</code>), or visible to all Viam users (<code>public</code>). You can change this setting later using the <code>viam module update</code> command.<br><br>Default: <code>private</code></td>
</tr>
<tr>
<td><code>url</code></td>
Expand Down Expand Up @@ -102,7 +102,7 @@ To upload your custom module to the [Viam registry](https://app.viam.com/registr
```

{{% alert title="Important" color="note" %}}
If you are publishing a public module (`visibility: "public"`), the [namespace of your model](/extend/modular-resources/key-concepts/#naming-your-model) must match the [namespace of your organization](/manage/fleet/organizations/#create-a-namespace-for-your-organization).
If you are publishing a public module (`"visibility": "public"`), the [namespace of your model](/extend/modular-resources/key-concepts/#naming-your-model) must match the [namespace of your organization](/manage/fleet/organizations/#create-a-namespace-for-your-organization).
In the example above, the model namespace is set to `acme` to match the owning organization's namespace.
If the two namespaces do not match, the command will return an error.
{{% /alert %}}
Expand Down
13 changes: 10 additions & 3 deletions docs/manage/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ sudo curl -o /usr/local/bin/viam https://storage.googleapis.com/packages.viam.co
sudo chmod a+rx /usr/local/bin/viam
```

You can also install the Viam CLI using [brew](https://brew.sh/) on Linux `amd64` (Intel `x86_64`):

```{class="command-line" data-prompt="$"}
brew tap viamrobotics/brews
brew install viam
```

{{% /tab %}}
{{% tab name="Source" %}}

Expand Down Expand Up @@ -349,7 +356,7 @@ All of the `module` commands accept either the `--org-id` or `--public-namespace
* Use the `--public-namespace` argument to supply the [namespace](/manage/fleet/organizations/#create-a-namespace-for-your-organization) of your organization, suitable for uploading your module to the Viam registry and sharing with other users.
* Use the `--org-id` to provide your organization ID instead, suitable for sharing your module privately within your organization.

You may use either argument for the `viam module create` command, but must use `--public-namespace` for the `update` and `upload` commands when uploading as a public module (`visibility: "public"`) to the Viam registry.
You may use either argument for the `viam module create` command, but must use `--public-namespace` for the `update` and `upload` commands when uploading as a public module (`"visibility": "public"`) to the Viam registry.

##### Using the `--platform` argument

Expand Down Expand Up @@ -413,7 +420,7 @@ The `meta.json` file includes the following configuration options:
<td><code>visibility</code></td>
<td>string</td>
<td><strong>Required</strong></td>
<td>Whether the module is visible to all Viam users (<code>public</code>), or accessible only to members of your <a href="/manage/fleet/organizations/">organization</a> (<code>private</code>). You can change this setting later using the <code>viam module update</code> command.<br><br>Default: <code>private</code></td>
<td>Whether the module is accessible only to members of your <a href="/manage/fleet/organizations/">organization</a> (<code>private</code>), or visible to all Viam users (<code>public</code>). You can change this setting later using the <code>viam module update</code> command.<br><br>Default: <code>private</code></td>
</tr>
<tr>
<td><code>url</code></td>
Expand Down Expand Up @@ -460,7 +467,7 @@ For example, the following represents the configuration of an example `my-module
```

{{% alert title="Important" color="note" %}}
If you are publishing a public module (`visibility: "public"`), the [namespace of your model](/extend/modular-resources/key-concepts/#naming-your-model) must match the [namespace of your organization](/manage/fleet/organizations/#create-a-namespace-for-your-organization).
If you are publishing a public module (`"visibility": "public"`), the [namespace of your model](/extend/modular-resources/key-concepts/#naming-your-model) must match the [namespace of your organization](/manage/fleet/organizations/#create-a-namespace-for-your-organization).
In the example above, the model namespace is set to `acme` to match the owning organization's namespace.
If the two namespaces do not match, the command will return an error.
{{% /alert %}}
Expand Down
Loading

0 comments on commit a64acff

Please sign in to comment.