Skip to content

Commit 4d53502

Browse files
authored
Improve safari tutorial (#4685)
1 parent 04bebfa commit 4d53502

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

docs/operate/hello-world/tutorial-desk-safari.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ description: "Follow this tutorial to learn about Viam while building a game."
1818
authors: ["Naomi Pentrel"]
1919
---
2020

21-
This tutorial assumes no prior knowledge of Viam and will teach you the fundamentals that allow you to build any machine that interacts with the physical world:
21+
In this tutorial you will build a game with your webcam while learning how to use Viam to build any machine that interacts with the physical world:
2222

2323
- [Device setup](#device-setup) will walk you through installing Viam on your computer.
2424
- [Use a webcam](#use-a-webcam) will guide you through configuring and testing camera resources in Viam.
2525
- [Add computer vision](#add-computer-vision) will show you how to integrate higher-level services such as ML model and vision services.
2626
- [Program your game](#program-your-game) will teach you to build custom modules and implement the game control logic.
2727
- [Play the game](#play-the-game) will let you test and interact with your completed game.
2828

29+
You don't need any prior knowledge of Viam.
30+
2931
## Game overview
3032

3133
The Desk Safari game you will build works as follows:
@@ -78,6 +80,7 @@ A {{< glossary_tooltip term_id="machine" text="machine" >}} represents at least
7880
**Install `viam-server`.**
7981

8082
On the machine's page, follow the {{< glossary_tooltip term_id="setup" text="setup instructions" >}} to install `viam-server` on the computer you're using for your project.
83+
If you can choose an installation method, use `viam-agent`.
8184

8285
Wait until your machine has successfully connected to Viam.
8386

@@ -117,7 +120,9 @@ There are different kinds of {{< glossary_tooltip term_id="resource" text="resou
117120

118121
Click the **+** icon next to your machine part in the left-hand menu and select **Component or service**.
119122
Select the `camera` type, then select the `webcam` model.
120-
Enter the name `webcam` for your camera and click **Create**.
123+
Use the default name `camera-1` for your camera and click **Create**.
124+
125+
You can leave the `video_path` empty.
121126

122127
{{% /tablestep %}}
123128
{{% tablestep %}}
@@ -136,7 +141,10 @@ The **TEST** panel is a good tool to ensure {{< glossary_tooltip term_id="resour
136141

137142
{{< imgproc src="/components/camera/example_camera_2.png" alt="Example Camera view" resize="800x" style="width:500px" class="imgzoom shadow" >}}
138143

139-
If your camera is not working, see [Troubleshooting](/operate/reference/components/camera/webcam/#troubleshooting) and [Common errors](/operate/reference/components/camera/webcam/#common-errors).
144+
If your camera is not working, follow the info in the camera panel to add the webcam discovery service.
145+
Once you save, use the discovery service's test panel to find camera configurations and add a new camera
146+
Make sure to name the camera `camera-1`.
147+
If this doesn't work, see [Troubleshooting](/operate/reference/components/camera/webcam/#troubleshooting) and [Common errors](/operate/reference/components/camera/webcam/#common-errors).
140148

141149
{{% /tablestep %}}
142150
{{< /table >}}
@@ -225,6 +233,16 @@ This saves you from writing boilerplate code.
225233
You must have the Viam CLI installed to generate and upload modules:
226234

227235
{{< readfile "/static/include/how-to/install-cli.md" >}}
236+
{{% /tablestep %}}
237+
{{% tablestep %}}
238+
**Log in with the CLI.**
239+
240+
Run the following command to log in:
241+
242+
```sh {class="command-line" data-prompt="$" data-output="2-10"}
243+
viam login
244+
```
245+
228246
{{% /tablestep %}}
229247
{{% tablestep %}}
230248
**Find your organization ID.**
@@ -613,11 +631,11 @@ Click **+**, click **Local module**, then click **Local component** and fill in
613631
- type: `button`
614632
- name: `button-1`
615633
616-
Configure the camera and vision service names by pasting the following in the attributes field:
634+
Configure the camera and vision service names by pasting the following in the configuration field:
617635
618636
```json {class="line-numbers linkable-line-numbers"}
619637
{
620-
"camera_name": "webcam",
638+
"camera_name": "camera-1",
621639
"detector_name": "object-detector"
622640
}
623641
```
@@ -634,7 +652,12 @@ Save the config.
634652
Navigate to your machine's **CONTROL** tab and find the button's panel.
635653
636654
1. Click the **PUSH** button to start the game.
637-
You should see a log message saying "`push` is called" in the **LOGS** tab.
655+
You should see a log message saying "`push` is called" in the **LOGS** tab:
656+
657+
```sh {class="command-line" data-prompt="$" data-output="1-10"}
658+
10/6/2025, 5:18:23 PM info rdk:component:button/button-1 game_logic.py:110 `push` is called log_ts 2025-10-06T17:18:23.672Z
659+
```
660+
638661
2. Open the `DoCommand` panel, add `{ "action": "run_game_loop" }` as the input and click **Execute**.
639662
This will call the game loop once and retrieve the score, the time the round started, and the current item to detect.
640663
You will see a response in the UI of the format:
@@ -650,6 +673,14 @@ Navigate to your machine's **CONTROL** tab and find the button's panel.
650673
3. Hold up the `item_to_detect` and click the **Execute** button to test the game.
651674
Once successfully detected, the score increases and the `item_to_detect` changes.
652675
676+
{{< alert title="Tip: Don't spend too long testing" color="tip" >}}
677+
Sometimes the model struggles to detect certain items.
678+
If that is the case, move on to the next step, once you've ensured there are no errors.
679+
680+
You can test the game more thorougly with a dedicated UI in [Play the game](#play-the-game).
681+
682+
{{< /alert >}}
683+
653684
4. If you wait 60 seconds, the game ends and the response you get if you then click **Execute** contains the default values for `item_to_detect` and `time_round_start` and the last score:
654685
655686
```json
@@ -674,7 +705,7 @@ To run game logic, we'll use a {{< glossary_tooltip term_id="job" text="job" >}}
674705
Click the **+** icon next to your machine part in the left-hand menu and select **Job**.
675706
You can use the default name, `job-1`, and click **Create**.
676707
677-
In the job panel, set the **Schedule** to **Cron** and enter `* * * * * *` which will run the job every second.
708+
In the job panel, set the **Schedule** to **Interval** and set it to run **Every 1 second**.
678709
679710
Then configure the job:
680711
@@ -685,8 +716,6 @@ Then configure the job:
685716
Click save.
686717
687718
Now, check the **LOGS** tab; you'll see the job triggered every second.
688-
If you now open another tab and go back to the **CONTROL** tab and click the **PUSH** button and then look at the logs in the other tab, you'll see periodic output from the running game.
689-
To see more visual input, scroll to the vision service panel on the **CONTROL** tab which will show you current detections as you hold objects up to the camera.
690719
691720
{{% /tablestep %}}
692721
{{< /table >}}

0 commit comments

Comments
 (0)