Skip to content

Commit

Permalink
More updates to configure a machine
Browse files Browse the repository at this point in the history
  • Loading branch information
sguequierre committed Mar 8, 2024
1 parent 2b70380 commit 053701d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 74 deletions.
Binary file added assets/build/configure/mode-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 62 additions & 74 deletions docs/build/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ Before you can program a smart machine, you must configure it.

A machine's configuration tells the code running the machine what _{{< glossary_tooltip term_id="resource" text="resources" >}}_ (hardware _{{< glossary_tooltip term_id="component" text="components" >}}_ and software _{{< glossary_tooltip term_id="service" text="services" >}}_) it has access to, as well as any relevant parameters for those resources.

To start configuring, go to the [Viam app](https://app.viam.com), create a new machine and follow the steps on your new machine’s **Setup** tab.
To start configuring, go to the [Viam app](https://app.viam.com) and create a new machine.
Open the part status dropdown menu in the top left corner of the page, next to the machine's name.
Click **View setup instructions** to open the setup instructions.
Follow the appropriate instructions for your machine's architecture.

The setup steps copy your machine's credentials to your machine and store them at <file>/etc/viam.json</file>.
The credentials look like this:
Expand Down Expand Up @@ -48,28 +51,30 @@ The configuration is cached locally.
If your machine will never connect to the internet, you can also create a [local configuration file](/internals/local-configuration-file/) on the machine itself.
{{% /alert %}}

## The Config tab
## The CONFIGURE tab

The **CONFIGURE** tab on the [Viam app](https://app.viam.com) is the place to configure everything about your machine.

You can use the mode selector to switch between **Builder** and **Raw JSON**:
You can switch between **Builder**, **JSON**, and **Frame** modes by clicking on the icon in the upper left-hand corner:

- **Builder** mode provides a graphical interface for configuring your machine resources.
- **Raw JSON** mode provides a text editing field where you can write and edit the config manually.
![Mode selector on CONFIGURE tab.](/build/configure/mode-selector.png)

![The CONFIG tab of the Viam app with a box highlighting the CONFIG tab and the Mode selector (where you can select Builder or Raw JSON).](/build/configure/config-tab.png)
- **Builder** mode provides a graphical interface for configuring your machine resources.
- **JSON** mode provides a text editing field where you can write and edit the config manually.
- **Frame** mode provides a graphical interface for configuring and visualizing the relative position of components in space.
For more information, see the [Frame System documentation](/mobility/frame-system/).

Regardless of the mode you choose, Viam stores the configuration file in [JSON (JavaScript Object Notation)](https://en.wikipedia.org/wiki/JSON).
Regardless of the editing mode you choose, Viam stores the configuration file in [JSON (JavaScript Object Notation)](https://en.wikipedia.org/wiki/JSON).

{{< alert title="Caution: Simultaneous config edits" color="caution" >}}
If you edit a config while someone else edits the same config, the person who saves last will overwrite any prior changes that aren't reflected in the new config.

Before editing a config, we recommend you refresh the page to ensure you have all the latest changes.
{{< /alert >}}

If you add components in **Builder** mode and click **Save Config** at the bottom of the screen, you can switch to **Raw JSON** and see the JSON that has been generated by the builder.
If you add components in **Builder** mode and click **Save** in the top right corner of the screen, you can switch to **JSON** and see the JSON that has been generated by the builder.

{{% expand "An example config file for a machine with a board component, motor component, camera component, and vision service configured" %}}
{{% expand "An example JSON config file for a machine with a board component, motor component, camera component, and vision service configured" %}}

```json
{
Expand Down Expand Up @@ -134,29 +139,15 @@ See [Example JSON configuration file](/internals/local-configuration-file/#examp

{{% /expand %}}

The **CONFIGURE** tab has subtabs for each section of your machine's config:

- [Components](#components): Components are the hardware of your machine.
- [Services](#services): Services are the software that runs on your machine.
- [Modules](#modules): {{< glossary_tooltip term_id="module" text="Modules" >}} provide {{< glossary_tooltip term_id="modular-resource" text="modular resources" >}}, which are a way to add resource types or models that are not built into Viam.
- [Remotes](#remotes): Remotes are a way to connect two separate machines so one can access the resources of the other.
- [Processes](#processes): Processes automatically run specified scripts when the machine boots.
- [Fragments](#fragments): Fragments are a way of sharing and managing identical configuration files (or parts of config files) across multiple machines.
- [Auth/Network](#authnetwork): The auth and network section allows you to configure machine-level API keys and set a bind address for `viam-server`.
- [Frames](#frame-system): Frames hold reference frame information for the relative position of components in space.
<!-- While in **Builder** mode, if you select the **+** (Create) icon next to your {{ < glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu, the following options are displayed:
{{% alert title="Tip" color="tip" %}}

Simple machines often use only a few components (and perhaps services).
Depending on your machine, you may not need to configure any modules, remotes, processes, fragments or frames.
TODO R2D2 add image once "insert fragment" option is removed -->

See [Build a simple smart machine](/use-cases/configure/) for a quick overview.

{{% /alert %}}

## Components
### Add a component

Components represent the pieces of hardware on your machine that you want to control with Viam.
To add a new component, click the **+** icon next to your {{< glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu of the **CONFIGURE** tab and select **Component** or hit **C**.
Search for and select your desired {{< glossary_tooltip term_id="model" text="model" >}}.

You must configure each component with a type, a model, a name, attributes, and dependencies:

Expand All @@ -172,71 +163,89 @@ You must configure each component with a type, a model, a name, attributes, and
- `attributes`: A struct to define things like how the component is wired to the machine, its dimensions, and other specifications; attributes vary widely between models.
See the [component documentation](/components/) for a given component type and model for more details.

{{% alert title="Tip" color="tip" %}}

Some optional attributes have default values.
If you omit these attributes from your config, or if you include them but leave their values empty, `viam-server` will apply these default values at runtime, even though they are not reflected in the configuration file.

{{% /alert %}}

- `depends_on`: Any components that a given component relies upon, and that must be initialized on boot before this component is initialized.
Many built-in components have convenient implicit dependencies, in which case `depends_on` can be left blank.
For example, a [`gpio` motor](/components/motor/gpio/) depends on the `board` to which it is wired, but it has a dedicated `board` attribute and `viam-server` will automatically initialize that board before it looks for the motor.

If you are configuring several similar components, you can use the **Duplicate component** button in the upper-right of a component's configuration pane to create a new identical component beneath your existing one.
If you are configuring several similar components, you can click **...** in the upper-right of a component's configuration pane, then select the **Duplicate** button to create a new identical component beneath your existing one.
Be sure to edit the duplicated component to change any parameters that are unique to the new component, such as its name and pins.

To delete a component, click the trash can icon in the upper-right of the component configuration pane.
To delete a component, click **...** in the upper-right of the component's configuration pane, then select the trash can icon.
Confirm that you are sure.

For specific information on how to configure each supported component type, see the [components documentation](/components/).

{{% alert title="Tip" color="tip" %}}

When you configure a component on the **CONFIGURE** tab, it will also appear on the **Control** tab which gives you an interface to test and interact with it.
When you configure a component on the **CONFIGURE** tab, it will also appear on the **CONTROL** tab which gives you an interface to test and interact with it.
The **Code sample** page on the **CONNECT** tab will also update to include code for some basic interaction with that component using the Viam [SDKs](/build/program/apis/).

{{<gif webm_src="/manage/control.webm" mp4_src="/manage/control.mp4" alt="Using the control tab">}}

{{% /alert %}}

## Services
<!-- TODO: R2D2 need to update this section with updated control tab view-->

### Add a service

[Services](/services/) are built-in software packages that make it easier to add complex capabilities such as motion planning or object detection to your machine.
To add a new service, click the **+** icon next to your {{< glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu of the **CONFIGURE** tab and select **Service** or hit **S**.
Search for and select your desired {{< glossary_tooltip term_id="model" text="model" >}}.

For services, the `type` specifies which of the Viam services you want to use on your machine, such as the vision service or the motion service.
You must configure a service with a `name` and a `type`:

The `name` serves as an identifier when accessing the resource from your code, as well as when configuring other resources that are dependent on that resource.
You can choose any unique name for a service.
- `type`: specifies which of the Viam services you want to use on your machine, such as the vision service or the motion service.
- `name`: serves as an identifier when accessing the resource from your code, as well as when configuring other resources that are dependent on that resource.
You can choose any unique name for a service.

The other aspects of configuring a service are highly specific to the type of service.
See the [services documentation](/services/) for more information.

## Modules
### Add a process

To automatically run a specified command when the machine boots, configure a _{{< glossary_tooltip term_id="process" text="process" >}}_.
You can configure any command, for example one that executes a binary or a script, to run as a process.

To add a new process, click the **+** icon next to your {{< glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu of the **CONFIGURE** tab and select **Process**.
Find more information in the [processes documentation](/build/configure/processes/).

### Add a local module

[Modular resources](/registry/) are a way to add resource types or models that are not built into Viam.
Many models are available in the [registry](https://app.viam.com/registry) and you are able to add them as components or services.

To add a modular resource as a component or service of your machine, configure a module per the [modular resource documentation](/registry/).
To add a module that is not in the registry and is local to your machine, click the **+** icon next to your {{< glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu of the **CONFIGURE** tab and select **Local module**.
Follow the instructions in our [registry documentation](/registry/configure/#add-a-local-module) to configure the module.

## Remotes
### Add a remote part

Configuring a remote is a way to connect two separate machines so one can access the resources of the other.
Find more information in our [remotes documentation](/build/configure/parts-and-remotes/).

## Processes
To configure a remote part, click the **+** icon next to your {{< glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu of the **CONFIGURE** tab and select **Remote part**.
Find more information in our [machine parts documentation](/build/configure/parts-and-remotes/).

To automatically run a specified command when the machine boots, configure a _{{< glossary_tooltip term_id="process" text="process" >}}_.
You can configure any command, for example one that executes a binary or a script, to run as a process.
### Add a sub-part

Find more information in the [processes documentation](/build/configure/processes/).
Configure a sub-part to connect two computers inside the same machine.

To configure a sub-part, click the **+** icon next to your {{< glossary_tooltip term_id="part" text="machine part" >}} in the left-hand menu of the **CONFIGURE** tab and select **Sub-part**.
Find more information in our [machine parts documentation](/build/configure/parts-and-remotes/).

## Fragments

You can use fragments to share similar {{< glossary_tooltip term_id="resource" text="resource" >}} configuration files across multiple machines in your fleet.
For example, if you have multiple machines with the same motor hardware, wired the same way, you can create a fragment to configure that motor and share it easily across all of your machines, without needing to individually configure the motor component for each machine.

See [Use Fragments to Configure a Fleet](/fleet/configure-a-fleet/) for more information on creating and deploying fragments.

## Webhooks

Webhooks allow you to trigger actions when certain types of data are sent from your machine to the cloud.
For example, you can configure a webhook to send you a notification when your robot's sensor collects a new reading.

Switch to **Raw JSON** mode to configure webhooks as follows:
Switch to **JSON** mode to configure webhooks as follows:

1. Paste the following JSON template into your raw JSON config.
1. Paste the following JSON template into your JSON config.
`"webhooks"` is a top-level section like `"components"`, `"services"`, or any of the other config sections.

{{< tabs >}}
Expand Down Expand Up @@ -344,32 +353,11 @@ Switch to **Raw JSON** mode to configure webhooks as follows:

```

## Fragments

You can use fragments to share similar {{< glossary_tooltip term_id="resource" text="resource" >}} configuration files across multiple machines in your fleet.
For example, if you have multiple machines with the same motor hardware, wired the same way, you can create a fragment to configure that motor and share it easily across all of your machines, without needing to individually configure the motor component for each machine.

See [Use Fragments to Configure a Fleet](/fleet/configure-a-fleet/) for more information on creating and deploying fragments.

## Auth/network

The auth section allows you to configure machine-level API keys for connecting over LAN.

The network section allows you to set the address `viam-server` binds to for accepting connections.
By default, `viam-server` binds to `0.0.0.0:8080` when managed by the Viam app or when authentication and TLS are enabled.

## Frame system

The frame system holds reference frame information for the relative position of components in space.

Configure a frame for a given component on its panel on the **Components** tab, then switch to the **Frame System** tab to visualize the relative positions.
Find more information in the [frame system documentation](/mobility/frame-system/).

## Troubleshooting

If you run into issues, here are some things to try:

- Check the [**Logs** tab](/fleet/machines/#logs) to view log messages and errors from `viam-server`.
- Check the [**LOGS** tab](/fleet/machines/#logs) to view log messages and errors from `viam-server`.
You can also [access the local log file](/get-started/installation/manage/#view-viam-server-logs) on your machine if needed.
- Make sure all configured components are actually saved to your config.
If they aren't, you will see an **Unsaved Changes** note next to the **Save Config** button at the bottom of the config screen.
Expand Down

0 comments on commit 053701d

Please sign in to comment.