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
This guide will walk you through creating a {{< glossary_tooltip term_id="modular-resource" text="modular" >}} camera component that responds to API calls by returning a configured image.
25
+
This guide walks you through creating a {{< glossary_tooltip term_id="modular-resource" text="modular" >}} camera component that returns a configured image.
26
26
This guide also includes optional steps to create a modular sensor that returns random numbers, to demonstrate how you can include two modular resources within one {{< glossary_tooltip term_id="module" text="module" >}}.
27
-
By the end of this guide, you will be able to create your own modular resources and package them into modules so you can use them on your machines.
27
+
By the end, you will know how to create your own modular resources and package them into modules so you can use them on your machines.
28
28
29
29
{{% alert title="Note" color="note" %}}
30
30
31
-
This guide provides a basic example for learning purposes.
31
+
This guide provides a basic learning example.
32
32
For a more comprehensive guide including usage of cloud build tools for deployment across different platforms, see [Integrate other hardware](/operate/get-started/other-hardware/).
33
33
34
34
{{% /alert %}}
@@ -57,116 +57,17 @@ You can check by running `python3 --version` or `python --version` in your termi
57
57
58
58
{{< /expand >}}
59
59
60
-
## Create a test script
60
+
## Decide what your module will do
61
61
62
-
The point of creating a module is to add functionality to your machine.
63
-
For the purposes of this guide, you're going to make a module that does two things: It opens an image file from a configured path on your machine, and it returns a random number.
62
+
The functionality you want to add to your machine determines the APIs you need to implement, so let's start by deciding what your module will do.
63
+
For the purposes of this guide, you're going to make a module that does two things:
64
64
65
-
1. Find an image you'd like to display when your program runs.
66
-
We used [this image of a computer with "hello world" on the screen](https://unsplash.com/photos/a-laptop-computer-sitting-on-top-of-a-wooden-desk-8q6e5hu3Ilc).
67
-
Save the image to your computer.
68
-
69
-
1. Create a test script on your computer and copy the following code into it:
The image you saved should open on your screen, and a random number should print to your terminal.
148
-
149
-
In later steps, the module generator will create a new virtual environment with required dependencies, so you can deactivate the one you just ran the test script in:
You can leave the rest of the functions not implemented, because this module is not meant to return a point cloud (`get_point_cloud()`), and does not need to return multiple images simultaneously (`get_images()`).
353
+
Leave the rest of the functions not implemented, because this module is not meant to return a point cloud (`get_point_cloud()`), and does not need to return multiple images simultaneously (`get_images()`).
453
354
454
355
Save the file.
455
356
@@ -579,7 +480,7 @@ First, implement the camera API methods by editing the camera class definition:
579
480
580
481
1. Delete the `SubscribeRTP` and `Unsubscribe` methods, since they are not applicable to this camera.
581
482
582
-
1. You can leave the rest of the functions not implemented, because this module is not meant to return a point cloud (`NextPointCloud`), and does not need to return multiple images simultaneously (`Images`).
483
+
1. Leave the rest of the functions not implemented, because this module is not meant to return a point cloud (`NextPointCloud`), and does not need to return multiple images simultaneously (`Images`).
583
484
584
485
However, you do need to edit the return statements to return empty structs that match the API.
585
486
Edit these methods so they look like this:
@@ -824,9 +725,9 @@ viam module upload --version 1.0.0 --platform any .
824
725
{{% /tab %}}
825
726
{{< /tabs >}}
826
727
827
-
Now, if you look at the [Viam Registry page](https://app.viam.com/registry) while logged into your account, you'll be able to find your private module listed.
828
-
Because the module is now in the registry, you can configure the hello-sensor and hello-camera on your machines just as you would configure other components and services; there's no more need for local module configuration.
829
-
The local module configuration is primarily for testing purposes.
728
+
Now, if you look at the [Viam Registry page](https://app.viam.com/registry) while logged into your account, you can find your private module listed.
729
+
With the module now in the registry, you can configure the hello-sensor and hello-camera on your machines just as you would configure other components and services.
730
+
There's no more need forlocal module configuration;local modules are primarily used for testing.
830
731
831
732
{{<imgproc src="/how-tos/hello-config.png" resize="x1100" declaredimensions=true alt="The create a component menu open, searching for hello. The hello-camera and hello-sensor components are shown in the search results." style="max-width:500px" class="shadow aligncenter">}}
0 commit comments