Skip to content

Commit

Permalink
DOCS-1059, DOCS-1086: Add from Module UI (#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
andf-viam authored Sep 11, 2023
1 parent 78602ea commit 7be784a
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 52 deletions.
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 not shown.
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 not shown.
Binary file not shown.
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.
4 changes: 2 additions & 2 deletions docs/extend/custom-components-remotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ description: "Implement custom components and register them on a server configur
---

{{% alert title="Caution" color="caution" %}}
{{< glossary_tooltip term_id="module" text="Modular resources" >}} are the preferred method of creating custom resource implementations for SDKs with module support unless you are hosting `viam-server` on a non-Linux system or have another issue with compilation.
[Modular resources](/extend/modular-resources/key-concepts/) are the preferred method of creating custom resource implementations for SDKs with module support unless you are hosting `viam-server` on a non-Linux system or have another issue with compilation.
{{% /alert %}}

If a type or model of [component](/components/) you are working with is not built-in to the [Viam RDK](/internals/rdk/), you can use a [Viam SDK](/program/apis/) to code a custom resource implementation, host it on a server, and add it as a [remote](/manage/parts-and-remotes/) of your robot.
If a type or model of [component](/components/) you are working with is not [built-in to the Viam RDK](/internals/rdk/), or [available from the Viam Registry as a module](/extend/modular-resources/key-concepts/), you can use a [Viam SDK](/program/apis/) to code a custom resource implementation, host it on a server, and add it as a [remote](/manage/parts-and-remotes/) of your robot.

Once you have coded your custom component and configured the remote servers, you can control and monitor your component with the Viam SDKs, like any other component.

Expand Down
140 changes: 90 additions & 50 deletions docs/extend/modular-resources/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,87 @@ description: "Add and configure a module from the Viam Registry on your robot."
no_list: true
---

You can extend Viam by adding a module on your robot to make one or more modular resources available for configuration.
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).

A *module* makes one or more *modular resources* available for configuration.
See [Key Concepts of Modular Resource APIs](/extend/modular-resources/key-concepts/) for more information.

## Add a module from the Viam Registry

The Viam Registry is a central repository of modules from both Viam and the robotics community that allows you to easily extend Viam's capabilities on your robot.
The [Viam Registry](https://app.viam.com/registry) is a central repository of modules from both Viam and the robotics community that allows you to easily extend Viam's capabilities on your robot.

To add a module from the Viam Registry to your robot:
A module provides one or more {{< glossary_tooltip term_id="resource" text="modular resources" >}} (either a [component](/components/) or [service](/services/)).

Follow the instructions below depending on the type of modular resource you would like to add to your robot:

- [Add a modular component](#add-a-modular-component-from-the-viam-registry)
- [Add a modular service](#add-a-modular-service-from-the-viam-registry)

### Add a modular component from the Viam registry

To add a modular [component](/components/) from the Viam Registry to your robot:

1. Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com).
1. Click on the **Components** subtab and click the **Create component** button.
1. Enter the name of the module you would like to add to your robot.
To find the name of a module you're interested in, you can:
1. Browse the list of available component types, and select the specific modular component you'd like to add.

{{<imgproc src="extend/modular-resources/configure/add-component-by-category.png" resize="400x" declaredimensions=true alt="The add a component modal showing results for the intel realsense module when searching by the category 'camera'">}}

You can also start typing to search for a module by name or to narrow down your search results.

- Start typing to search for modules by name.
Modules available from the Viam Registry will be listed under the `From Registry` section of the search results.
- [Browse the Viam Registry](https://app.viam.com/modules) directly to search available modules.
{{<imgproc src="extend/modular-resources/configure/add-component-by-name.png" resize="400x" declaredimensions=true alt="The add a component modal showing results for the intel realsense module when searching by the name 'realsense'">}}

{{<imgproc src="extend/modular-resources/configure/add-module-from-registry.png" resize="400x" declaredimensions=true alt="The add a component modal showing results for the intel realsense module ">}}
1. After selecting the modular component, click the **Add module** button, enter a name for your modular component, and click **Create** to add it to your robot.

1. After entering the name of the module that you would like to add to your robot, select the matching module in the search results and click the **Add module** button.
{{<imgproc src="extend/modular-resources/configure/add-component-screen.png" resize="400x" declaredimensions=true alt="The add a component modal showing the intel realsense module pane, with the 'Add module' button shown">}}

When you add a module from the Viam Registry, the custom modular component it provides appears under the **Components** subtab like any other component.
You can also find [the module itself](#configure-a-module-from-the-viam-registry) listed as **Deployed** under the **Modules** subtab.

{{<imgproc src="extend/modular-resources/configure/conf-component-from-module.png" resize="400x" declaredimensions=true alt="The components subtab of the config tab showing the camera component configuration pane for the realsense module">}}

If the module requires you to configure specific **Atrributes**, click the **URL** link in the module's configuration pane to view the specific documentation on the module's GitHub page.
If the module requires you to configure specific **Attributes**, click the **URL** link in the [module's configuration pane](#configure-a-module-from-the-viam-registry) to view the specific attribute requirements on the module's GitHub page.

To delete a module added from the Viam Registry, click the trash can icon in the upper-right corner of the module configuration pane in the **Components** tab.
Deleting a module *does not* delete any configured modular resources it provides.

### Configure a module from the Viam Registry
### Add a modular service from the Viam registry

Once you have added a module from the Viam Registry, you can view and configure the module from the **Modules** subtab:
To add a modular [service](/services/) from the Viam Registry to your robot:

1. Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com).
1. Click on the **Services** subtab and click the **Create service** button.
1. Browse the list of available service types and select the specific modular service you'd like to add.

{{<imgproc src="extend/modular-resources/configure/add-service-by-category.png" resize="400x" declaredimensions=true alt="The add a component modal showing results for the mlmodelservice triton module when searching by the category 'ML Model'">}}

You can also start typing to search for a module by name or to narrow down your search results.

{{<imgproc src="extend/modular-resources/configure/add-service-by-name.png" resize="400x" declaredimensions=true alt="The add a component modal showing results for the mlmodelservice triton module when searching by the name 'triton'">}}

1. After selecting the modular service, click the **Add module** button, enter a name for your modular service, and click **Create** to add it to your robot.

{{<imgproc src="extend/modular-resources/configure/add-service-screen.png" resize="400x" declaredimensions=true alt="The add a component modal showing the mlmodelservice triton module pane, with the 'Add module' button shown">}}

When you add a module from the Viam Registry, the custom modular service it provides appears under the **Services** subtab like any other service.
You can also find [the module itself](#configure-a-module-from-the-viam-registry) listed as **Deployed** under the **Modules** subtab.

If the module requires you to configure specific **Attributes**, click the **URL** link in the [module's configuration pane](#configure-a-module-from-the-viam-registry) to view the specific attribute requirements on the module's GitHub page.

To delete a module added from the Viam Registry, click the trash can icon in the upper-right corner of the module configuration pane in the **Services** tab.
Deleting a module *does not* delete any configured modular resources it provides.

## Configure a module from the Viam Registry

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.
All modules you have added to your robot appear under the **Deployed** section.

This pane lists the models provided by the module, any [components](/components/) on your robot that are currently using those models, and allows you to configure [how the module updates](#configure-version-update-management-for-a-registry-module) when a new version is available from the Viam Registry.
This pane lists the models provided by the module, any [components](/components/) or [services](/services/) on your robot that are currently using the module, and allows you to configure [how the module updates](#configure-version-update-management-for-a-registry-module) when a new version is available from the Viam Registry.

{{<imgproc src="extend/modular-resources/configure/conf-module-from-registry.png" resize="1000x" declaredimensions=true alt="The module subtab of the config tab showing the realsense custom module configuration pane includes the update management section showing version update management options version type, set to Patch (X.Y.Z) and version set to 0.0.3">}}
{{<imgproc src="extend/modular-resources/configure/deployed-module-with-component.png" resize="1000x" declaredimensions=true alt="The module subtab of the config tab showing the realsense custom module configuration pane includes the update management section showing version update management options version type, set to Patch (X.Y.Z) and version set to 0.0.3">}}

#### Configure version update management for a Registry module
### Configure version update management for a Registry module

When you add a module to your robot, you can also configure how that module updates itself when a newer version becomes available from the Viam Registry.
By default, a newly-added module is set to pin to the specific patch release (**Patch (X.Y.Z)**) of the version you added, meaning that the module will *never automatically update itself*.
Expand Down Expand Up @@ -82,9 +116,9 @@ For any version type other than **Patch (X.Y.Z)**, the module will upgrade as so
If, for example, the module provides a motor component, and the motor is running, it will stop while the module upgrades.
{{% /alert %}}

### Configure a modular resource from a Registry module
### Create a new modular resource from a Registry module

Once you have configured a module from the Viam Registry, 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 module](#add-a-module-from-the-viam-registry), from the Viam Registry, you can add any number of the modular resources it provides to your robot by adding new components or services configured with your modular resources' [model](/extend/modular-resources/key-concepts/#models).

The following properties are available for modular resources:

Expand All @@ -98,6 +132,7 @@ The following properties are available for modular resources:

All standard properties for configuration, such as `attributes` and `depends_on`, are also supported for modular resources.
The `attributes` available vary depending on your implementation.
If the module requires you to configure specific **Attributes**, click the **URL** link in the module's configuration pane to view the specific attribute requirements on the module's GitHub page.

{{< tabs >}}
{{% tab name="JSON Template" %}}
Expand All @@ -106,47 +141,51 @@ The `attributes` available vary depending on your implementation.
{
"components": [
{
"namespace": "<your-module-namespace>",
"type": "<your-resource-subtype>",
"model": "<model-namespace>:<model-family>:<model-name>",
"name": "<your-model-instance-name>",
"depends_on": [],
"model": "<model-namespace>:<model-family>:<model-name>",
"type": "<your-resource-subtype>",
"namespace": "<your-module-namespace>",
"attributes": {},
"depends_on": []
}
],
"modules": [ ... ] // < INSERT YOUR MODULE CONFIGURATION >
"modules": [
{
"type": "registry",
"name": "<module-name>",
"module_id": "<module-namespace>:<module-name>",
"version": "<module-version>"
}
]
}
```

{{% /tab %}}
{{% tab name="JSON Example" %}}

The following is an example configuration for a base modular resource implementation.
The configuration adds `acme:demo:mybase` as a modular resource from the module `my_base`.
The custom model is configured as a component with the name "my-custom-base-1".
You can send commands to the base according to the Viam [base API](/components/base/#api):
The following is an example configuration for for the [Intel Realsense module](https://app.viam.com/module/viam/realsense).
The configuration adds `viam:camera:realsense` as a modular resource from the module `viam:realsense`.
The custom model is configured as a component with the name "my-realsense".

```json {class="line-numbers linkable-line-numbers"}
{
"components": [
{
"type": "board",
"name": "main-board",
"model": "pi"
},
{
"type": "base",
"name": "my-custom-base-1",
"model": "acme:demo:mybase",
"namespace": "rdk",
"attributes": {},
"depends_on": [ "main-board" ]
}
],
"modules": [
{
"name": "my-custom-base",
"executable_path": "/home/my_username/my_base/run.sh"
}
{
"name": "my-realsense",
"model": "viam:camera:realsense",
"type": "camera",
"namespace": "rdk",
"attributes": {},
"depends_on": []
}
],
"modules": [
{
"type": "registry",
"name": "viam_realsense",
"module_id": "viam:realsense",
"version": "0.0.3"
}
]
}
```
Expand Down Expand Up @@ -240,7 +279,8 @@ The `attributes` available vary depending on your implementation.
"type": "<your-resource-subtype>",
"model": "<model-namespace>:<model-family>:<model-name>",
"name": "<your-model-instance-name>",
"depends_on": [],
"attributes": {},
"depends_on": []
}
],
"modules": [ ... ] // < INSERT YOUR MODULE CONFIGURATION >
Expand Down

0 comments on commit 7be784a

Please sign in to comment.