Skip to content

Commit

Permalink
DOCS-1113: Add clarification for running code remotely to client SDK …
Browse files Browse the repository at this point in the history
…Run Code page (#1819)

Co-authored-by: Naomi Pentrel <[email protected]>
sguequierre and npentrel authored Sep 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 68f7efc commit 4b09eca
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions docs/program/run.md
Original file line number Diff line number Diff line change
@@ -10,13 +10,28 @@ tags: ["client", "sdk", "application", "sdk", "fleet", "program"]

After saving your [code sample](/program/#hello-world-the-code-sample-tab) and adding control logic with [Viam's SDKs](/program/apis/), run your program to control your Viam-connected robot.

## Run Code Remotely
### Authentication

You must reference a robot's location secret to authenticate yourself to the robot.
However, the app hides the robot location secret from the sample by default for your security.

To copy the robot location secret, select **Include Secret** on the **Code sample** tab of your robot's page on the [Viam app](https://app.viam.com).
Paste it into your SDK code as directed by the code sample.

You must also include the robot's remote address, like `12345.somerobot-main.viam.cloud`, as an external or public address to connect to your robot.
The code sample includes this address at default.
You can find it at the top of the robot's **Control** tab.

As long as you are connecting to your robot through an external signaling address, you can remotely control your robot without editing the app-generated connection code in your SDK program beyond including the necessary [authentication credentials](#authentication).
{{% snippet "secret-share.md" %}}

## Run Code Remotely

Do this by running a command to execute the program in the terminal of a machine with the appropriate programming language and Viam SDK installed.
Most of the time, as long as both you and your robot are connected to the internet, you will want to run code to control your robot remotely.
The advantage of this method is that your robot and your computer do not have to be connected to the same WAN/LAN to issue control commands.
You can remotely control your robot with any application you implement from anywhere in the world.
For example, you can run code on your personal computer, creating a client [session](/program/apis/sessions/), where the code running on that computer sends instructions to your robot's `viam-server` instance over the internet.

For example:
After editing your code to include your robot's [authentication credentials](#authentication), run a command to execute the program in the terminal of a machine with the appropriate programming language and Viam SDK installed:

{{< tabs >}}
{{% tab name="Python" %}}
@@ -54,20 +69,6 @@ flutter run <DART_FILE>

This is useful because as long as that computer is able to establish a network connection with the robot's computer, your control logic will be executed on the robot.

### Authentication

You must reference a robot's location secret to authenticate yourself to the robot.
However, the app hides the robot location secret from the sample by default for your security.

To copy the robot location secret, select **Include Secret** on the **Code sample** tab of your robot's page on the [Viam app](https://app.viam.com).
Paste it into your SDK code as directed by the code sample.

You must also include the robot's remote address, like `12345.somerobot-main.viam.cloud`, as an external or public address to connect to your robot.
The code sample should include this address at default.
You can find it at the top of the robot's **Control** tab.

{{% snippet "secret-share.md" %}}

## Run Code On-Robot

{{< alert title="Info" color="info" >}}

0 comments on commit 4b09eca

Please sign in to comment.