@@ -279,7 +279,9 @@ If you want to understand the module structure, here's what each file does:
279279
280280- ** <FILE >README.md</FILE >** : Documentation template that gets uploaded to the registry when you upload the module.
281281- ** <FILE >meta.json</FILE >** : Module metadata that gets uploaded to the registry when you upload the module.
282- - TODO
282+ - ** <FILE >module/main.go</FILE > and <FILE >module.go</FILE >** : Core code that registers the module and resource and provides the model implementation.
283+ - ** <FILE >cli/main.go</FILE >** : You can run this file to test the model you are creating (` go run ./cmd/cli ` ).
284+ - ** Makefile** : Build and setup commands.
283285
284286{{% /tab %}}
285287{{< /tabs >}}
@@ -371,8 +373,16 @@ Edit the `description` to include both models.
371373 "markdown_link" : " README.md#model-exampleorghello-worldhello-sensor"
372374 }
373375 ],
376+ "applications" : null ,
377+ "markdown_link" : " README.md" ,
374378 "entrypoint" : " ./run.sh" ,
375- "first_run" : " "
379+ "first_run" : " " ,
380+ "build" : {
381+ "build" : " ./build.sh" ,
382+ "setup" : " ./setup.sh" ,
383+ "path" : " dist/archive.tar.gz" ,
384+ "arch" : [" linux/amd64" , " linux/arm64" , " darwin/arm64" , " windows/amd64" ]
385+ }
376386}
377387```
378388
@@ -457,8 +467,16 @@ Edit the `description` to include both models.
457467 "markdown_link" : " README.md#model-exampleorghello-worldhello-sensor"
458468 }
459469 ],
460- "entrypoint" : " ./run.sh" ,
461- "first_run" : " "
470+ "applications" : null ,
471+ "markdown_link" : " README.md" ,
472+ "entrypoint" : " bin/hello-world" ,
473+ "first_run" : " " ,
474+ "build" : {
475+ "build" : " make module.tar.gz" ,
476+ "setup" : " make setup" ,
477+ "path" : " module.tar.gz" ,
478+ "arch" : [" linux/amd64" , " linux/arm64" , " darwin/arm64" , " windows/amd64" ]
479+ }
462480}
463481```
464482
@@ -813,19 +831,31 @@ You can find details about the return types at [go.viam.com/rdk/components](http
813831{{< table >}}
814832{{< tablestep start=1 >}}
815833
816- The module generator created a stub for the ` Image ` function we want to implement in <file >hello-world/hello-camera.go</file >.
834+ The module generator created a stub for the ` Images ` function we want to implement in <file >hello-world/hello-camera.go</file >.
817835
818836You need to replace ` panic("not implemented") ` with code to implement the method:
819837
820- ``` go {class="line-numbers linkable-line-numbers" data-start="101" }
821- func (s *helloWorldHelloCamera ) Image (ctx context .Context , mimeType string , extra map [string ]interface {}) ([]byte , camera .ImageMetadata , error ) {
838+ ``` go {class="line-numbers linkable-line-numbers" data-start="111" }
839+ func (s *helloWorldHelloCamera ) Images (ctx context .Context , filterSourceNames []string , extra map [string ]interface {}) ([]camera .NamedImage , resource .ResponseMetadata , error ) {
840+ var responseMetadataRetVal resource.ResponseMetadata
841+
822842 imgFile , err := os.Open (imagePath)
823843 if err != nil {
824- return nil , camera. ImageMetadata {} , errors.New (" Error opening image." )
844+ return nil , responseMetadataRetVal , errors.New (" Error opening image." )
825845 }
826846 defer imgFile.Close ()
847+
827848 imgByte , err := os.ReadFile (imagePath)
828- return imgByte, camera.ImageMetadata {}, nil
849+ if err != nil {
850+ return nil , responseMetadataRetVal, err
851+ }
852+
853+ named , err := camera.NamedImageFromBytes (imgByte, " default" , " image/png" )
854+ if err != nil {
855+ return nil , responseMetadataRetVal, err
856+ }
857+
858+ return []camera.NamedImage {named}, responseMetadataRetVal, nil
829859}
830860```
831861
@@ -872,8 +902,6 @@ Add the following import to the list of imports at the top of <file>hello-world/
872902" math/rand"
873903```
874904
875- Save the file.
876-
877905{{% /tablestep %}}
878906{{< tablestep >}}
879907
0 commit comments