You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/operate/hello-world/tutorial-desk-safari.md
+38-9Lines changed: 38 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,16 @@ description: "Follow this tutorial to learn about Viam while building a game."
18
18
authors: ["Naomi Pentrel"]
19
19
---
20
20
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:
22
22
23
23
-[Device setup](#device-setup) will walk you through installing Viam on your computer.
24
24
-[Use a webcam](#use-a-webcam) will guide you through configuring and testing camera resources in Viam.
25
25
-[Add computer vision](#add-computer-vision) will show you how to integrate higher-level services such as ML model and vision services.
26
26
-[Program your game](#program-your-game) will teach you to build custom modules and implement the game control logic.
27
27
-[Play the game](#play-the-game) will let you test and interact with your completed game.
28
28
29
+
You don't need any prior knowledge of Viam.
30
+
29
31
## Game overview
30
32
31
33
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
78
80
**Install `viam-server`.**
79
81
80
82
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`.
81
84
82
85
Wait until your machine has successfully connected to Viam.
83
86
@@ -117,7 +120,9 @@ There are different kinds of {{< glossary_tooltip term_id="resource" text="resou
117
120
118
121
Click the **+** icon next to your machine part in the left-hand menu and select **Component or service**.
119
122
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.
121
126
122
127
{{% /tablestep %}}
123
128
{{% tablestep %}}
@@ -136,7 +141,10 @@ The **TEST** panel is a good tool to ensure {{< glossary_tooltip term_id="resour
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).
140
148
141
149
{{% /tablestep %}}
142
150
{{< /table >}}
@@ -225,6 +233,16 @@ This saves you from writing boilerplate code.
225
233
You must have the Viam CLI installed to generate and upload modules:
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
+
638
661
2. Open the `DoCommand` panel, add `{ "action": "run_game_loop" }` as the input and click **Execute**.
639
662
This will call the game loop once and retrieve the score, the time the round started, and the current item to detect.
640
663
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.
650
673
3. Hold up the `item_to_detect` and click the **Execute** button to test the game.
651
674
Once successfully detected, the score increases and the `item_to_detect` changes.
652
675
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
+
653
684
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:
654
685
655
686
```json
@@ -674,7 +705,7 @@ To run game logic, we'll use a {{< glossary_tooltip term_id="job" text="job" >}}
674
705
Click the **+** icon next to your machine part in the left-hand menu and select **Job**.
675
706
You can use the default name, `job-1`, and click **Create**.
676
707
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**.
678
709
679
710
Then configure the job:
680
711
@@ -685,8 +716,6 @@ Then configure the job:
685
716
Click save.
686
717
687
718
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.
0 commit comments