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/modules/support-hardware/_index.md
+39-41Lines changed: 39 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,29 +110,29 @@ print(random_number)
110
110
package main
111
111
112
112
import (
113
-
"fmt"
114
-
"math/rand"
115
-
"os"
113
+
"fmt"
114
+
"math/rand"
115
+
"os"
116
116
)
117
117
118
118
funcmain() {
119
-
// Open an image
120
-
imgFile, err:= os.Open("example.png")
121
-
if err != nil {
122
-
fmt.Printf("Error opening image file: %v\n", err)
123
-
return
124
-
}
125
-
defer imgFile.Close()
126
-
imgByte, err:= os.ReadFile("example.png")
127
-
fmt.Printf("Image file type: %T\n", imgByte)
128
-
if err != nil {
129
-
fmt.Printf("Error reading image file: %v\n", err)
130
-
return
131
-
}
132
-
133
-
// Return a random number
134
-
number:= rand.Float64()
135
-
fmt.Printf("Random number: %f\n", number)
119
+
// Open an image
120
+
imgFile, err:= os.Open("example.png")
121
+
if err != nil {
122
+
fmt.Printf("Error opening image file: %v\n", err)
123
+
return
124
+
}
125
+
defer imgFile.Close()
126
+
imgByte, err:= os.ReadFile("example.png")
127
+
fmt.Printf("Image file type: %T\n", imgByte)
128
+
if err != nil {
129
+
fmt.Printf("Error reading image file: %v\n", err)
130
+
return
131
+
}
132
+
133
+
// Return a random number
134
+
number:= rand.Float64()
135
+
fmt.Printf("Random number: %f\n", number)
136
136
}
137
137
```
138
138
@@ -147,7 +147,7 @@ The module takes the functionality of the script and maps it to a standardized A
147
147
Review the available [component APIs](/dev/reference/apis/#component-apis) and choose the one whose methods map most closely to the functionality you need.
148
148
149
149
If you need a method that is not in your chosen API, you can use the flexible `DoCommand` (which is built into all component APIs) to create custom commands.
150
-
See [Run control logic](/docs/operate/modules/support-hardware/) for more information.
150
+
See [Run control logic](/docs/operate/modules/control-logic/) for more information.
151
151
152
152
**Example module:** To choose the Viam [APIs](/dev/reference/apis/#component-apis) that make sense for your module, think about the functionality you want to implement.
153
153
You need a way to return an image and you need a way to return a number.
@@ -336,13 +336,12 @@ from viam.module.module import Module
336
336
try:
337
337
from models.hello_camera import HelloCamera
338
338
from models.hello_sensor import HelloSensor
339
-
exceptModuleNotFoundError: # when running as local module with run.sh
339
+
exceptModuleNotFoundError: # when running as local module with run.sh
340
340
from .models.hello_camera import HelloCamera
341
341
from .models.hello_sensor import HelloSensor
342
342
343
343
if__name__=='__main__':
344
344
asyncio.run(Module.run_from_registry())
345
-
346
345
```
347
346
348
347
Save the file.
@@ -423,19 +422,19 @@ This file must add resource imports and register the module's models:
423
422
package main
424
423
425
424
import (
426
-
"helloworld"
427
-
"go.viam.com/rdk/module"
428
-
"go.viam.com/rdk/resource"
429
-
camera "go.viam.com/rdk/components/camera"
430
-
sensor "go.viam.com/rdk/components/sensor"
425
+
"helloworld"
426
+
"go.viam.com/rdk/module"
427
+
"go.viam.com/rdk/resource"
428
+
camera "go.viam.com/rdk/components/camera"
429
+
sensor "go.viam.com/rdk/components/sensor"
431
430
)
432
431
433
432
funcmain() {
434
-
// ModularMain can take multiple APIModel arguments, if your module implements multiple models.
0 commit comments