Skip to content

Commit 0b1050d

Browse files
authored
DOCS-3341: Add missing python methods and fix check (#3858)
1 parent 16e9861 commit 0b1050d

20 files changed

+341
-23
lines changed

Diff for: .github/workflows/check_python_methods.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
]
3131

3232
services_page_mapping = {
33-
"motion": "services/motion",
34-
"navigation": "services/navigation",
35-
"slam": "services/slam",
36-
"vision": "services/vision",
37-
"ml": "services/ml"
33+
"motion": "dev/reference/apis/services/motion/",
34+
"navigation": "dev/reference/apis/services/navigation",
35+
"slam": "dev/reference/apis/services/slam",
36+
"vision": "dev/reference/apis/services/vision",
37+
"ml": "dev/reference/apis/services/ml"
3838
}
3939

4040
def is_unimplemented(obj):
@@ -246,12 +246,12 @@ def parse(type, names):
246246
soup2 = BeautifulSoup(fp, 'html.parser')
247247
else:
248248
if type == "app" or type == "robot":
249-
soup2 = make_soup(f"https://docs.viam.com/program/apis/{service}/")
249+
soup2 = make_soup(f"https://docs.viam.com/dev/reference/apis/{service}/")
250250
else:
251251
if service in services_page_mapping.keys():
252252
soup2 = make_soup(f"https://docs.viam.com/{services_page_mapping[service]}/")
253253
else:
254-
soup2 = make_soup(f"https://docs.viam.com/configure/{type}/{service}/")
254+
soup2 = make_soup(f"https://docs.viam.com/dev/reference/apis/{type}/{service}/")
255255

256256
# Find all links on Docs site soup
257257
all_links = soup2.find_all('a')

Diff for: .github/workflows/sdk_protos_map.csv

+8-4
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,17 @@ gantry,GetGeometries,,,,
9191
## HACK: proto for these (and/or inherited in Go SDK), manually mapping:
9292
gantry,IsMoving,,is_moving,IsMoving,isMoving
9393
gantry,Stop,,stop,Stop,stop
94+
gantry,GetGeometries,,get_geometries,,
9495
gantry,Reconfigure,,,Reconfigure,
95-
gantry,DoCommand,,,,doCommand
96+
gantry,DoCommand,,do_command,,doCommand
9697
gantry,GetResourceName,,get_resource_name,,getResourceName
9798
gantry,Close,,close,Close,
9899

99100
## Generic Component
100101
## NOTED:Generic Component in Go SDK doesn't appear to implement (inherit) these:
101102
generic_component,DoCommand,Yes,do_command,DoCommand,doCommand
102-
# generic_component,GetGeometries,No,,,
103+
generic_component,GetGeometries,No,get_geometries,,
104+
generic_component,DoCommand,,do_command,,doCommand
103105
## HACK: No proto for close, manually mapping:
104106
## NOTED: Go SDK also missing Close, but we have it in our docs?:
105107
generic_component,GetResourceName,No,get_resource_name,,getResourceName
@@ -128,7 +130,7 @@ input_controller,GetGeometries,,get_geometries,,
128130
input_controller,RegisterControlCallback,,register_control_callback,RegisterControlCallback,
129131
## HACK: proto for these (and/or inherited in Go SDK), manually mapping:
130132
input_controller,Reconfigure,,,Reconfigure,
131-
input_controller,DoCommand,,,,
133+
input_controller,DoCommand,,do_command,,
132134
input_controller,GetResourceName,,get_resource_name,,
133135
input_controller,Close,,close,Close,
134136

@@ -161,7 +163,7 @@ movement_sensor,GetProperties,Yes,get_properties,Properties,properties
161163
movement_sensor,GetAccuracy,No,get_accuracy,Accuracy,accuracy
162164
movement_sensor,GetLinearAcceleration,Yes,get_linear_acceleration,LinearAcceleration,linearAcceleration
163165
## NOTED: Go SDK doesn't appear to implement this:
164-
# NOT implemented movement_sensor,GetGeometries,No,get_geometries,,
166+
movement_sensor,GetGeometries,No,get_geometries,,
165167
## HACK: No proto for these (and/or inherited in Go SDK), manually mapping:
166168
movement_sensor,GetReadings,Yes,get_readings,Readings,readings
167169
movement_sensor,Reconfigure,No,,Reconfigure,
@@ -187,6 +189,7 @@ power_sensor,Close,,close,Close,
187189
sensor,GetReadings,Yes,get_readings,Readings,readings
188190
# NOT implemented sensor,GetGeometries,No,get_geometries,,
189191
## HACK: No proto for close (and/or inherited in Go SDK), manually mapping:
192+
sensor,GetGeometries,,get_geometries,,
190193
sensor,Reconfigure,No,,Reconfigure,
191194
# NOT implemented in other languages
192195
sensor,DoCommand,,,,doCommand
@@ -443,6 +446,7 @@ robot,FrameSystemConfig,,get_frame_system_config,FrameSystemConfig,
443446
robot,TransformPose,,transform_pose,TransformPose,
444447
robot,TransformPCD,,,TransformPointCloud,
445448
robot,StreamStatus,,,,
449+
# DEPRECATED robot,DiscoverComponents,,discover_components,DiscoverComponents,
446450
robot,StopAll,,stop_all,StopAll,
447451
robot,RestartModule,,,RestartModule,
448452
robot,StartSession,,,,

Diff for: static/include/components/apis/generated/arm.md

+6
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
758758

759759
- [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html)
760760

761+
**Example:**
762+
763+
```dart {class="line-numbers linkable-line-numbers"}
764+
final myArmResourceName = myArm.getResourceName("my_arm");
765+
```
766+
761767
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Arm/getResourceName.html).
762768

763769
{{% /tab %}}

Diff for: static/include/components/apis/generated/board.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ myBoard, err := board.FromRobot(robot, "my_board")
5252
pin, err := myBoard.GPIOPinByName("15")
5353

5454
// Set the pin to high.
55-
err := pin.Set(context.Background(), "true", nil)
55+
err = pin.Set(context.Background(), true, nil)
5656
```
5757

5858
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/board#GPIOPin).
@@ -135,7 +135,7 @@ myBoard, err := board.FromRobot(robot, "my_board")
135135
pin, err := myBoard.GPIOPinByName("15")
136136

137137
// Get if it is true or false that the state of the pin is high.
138-
high := pin.Get(context.Background(), nil)
138+
high, err := pin.Get(context.Background(), nil)
139139
```
140140

141141
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/board#GPIOPin).
@@ -225,7 +225,7 @@ myBoard, err := board.FromRobot(robot, "my_board")
225225
pin, err := myBoard.GPIOPinByName("15")
226226

227227
// Returns the duty cycle.
228-
duty_cycle := pin.PWM(context.Background(), nil)
228+
duty_cycle, err := pin.PWM(context.Background(), nil)
229229
```
230230

231231
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/board#GPIOPin).
@@ -309,7 +309,7 @@ myBoard, err := board.FromRobot(robot, "my_board")
309309
pin, err := myBoard.GPIOPinByName("15")
310310

311311
// Set the duty cycle to .6, meaning that this pin will be in the high state for 60% of the duration of the PWM interval period.
312-
err := pin.SetPWM(context.Background(), .6, nil)
312+
err = pin.SetPWM(context.Background(), .6, nil)
313313
```
314314

315315
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/board#GPIOPin).
@@ -480,7 +480,7 @@ myBoard, err := board.FromRobot(robot, "my_board")
480480
pin, err := myBoard.GPIOPinByName("15")
481481

482482
// Set the PWM frequency of this pin to 1600 Hz.
483-
high := pin.SetPWMFreq(context.Background(), 1600, nil)
483+
err = pin.SetPWMFreq(context.Background(), 1600, nil)
484484
```
485485

486486
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/board#GPIOPin).
@@ -734,7 +734,7 @@ myBoard, err := board.FromRobot(robot, "my_board")
734734
analog, err := myBoard.AnalogByName("my_example_analog")
735735

736736
// Set the pin to value 48.
737-
err := analog.Write(context.Background(), 48, nil)
737+
err = analog.Write(context.Background(), 48, nil)
738738
```
739739

740740
For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/board#Analog).
@@ -1292,6 +1292,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
12921292

12931293
- [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html)
12941294

1295+
**Example:**
1296+
1297+
```dart {class="line-numbers linkable-line-numbers"}
1298+
final myBoardResourceName = myBoard.getResourceName("my_board");
1299+
```
1300+
12951301
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Board/getResourceName.html).
12961302

12971303
{{% /tab %}}

Diff for: static/include/components/apis/generated/camera.md

+6
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
449449

450450
- [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html)
451451

452+
**Example:**
453+
454+
```dart {class="line-numbers linkable-line-numbers"}
455+
final myCameraResourceName = myCamera.getResourceName("my_camera");
456+
```
457+
452458
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Camera/getResourceName.html).
453459

454460
{{% /tab %}}

Diff for: static/include/components/apis/generated/gantry-table.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
| [`Home`](/dev/reference/apis/components/gantry/#home) | Run the homing sequence of the gantry to re-calibrate the axes with respect to the limit switches. |
88
| [`IsMoving`](/dev/reference/apis/components/gantry/#ismoving) | Get if the gantry is currently moving. |
99
| [`Stop`](/dev/reference/apis/components/gantry/#stop) | Stop all motion of the gantry. |
10+
| [`GetGeometries`](/dev/reference/apis/components/gantry/#getgeometries) | Get all the geometries associated with the gantry in its current configuration, in the frame of the gantry. |
1011
| [`Reconfigure`](/dev/reference/apis/components/gantry/#reconfigure) | Reconfigure this resource. |
1112
| [`DoCommand`](/dev/reference/apis/components/gantry/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. |
1213
| [`GetResourceName`](/dev/reference/apis/components/gantry/#getresourcename) | Get the `ResourceName` for this gantry with the given name. |

Diff for: static/include/components/apis/generated/gantry.md

+65
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,39 @@ For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_s
460460
{{% /tab %}}
461461
{{< /tabs >}}
462462

463+
### GetGeometries
464+
465+
Get all the geometries associated with the gantry in its current configuration, in the [frame](/operate/mobility/define-geometry/) of the gantry.
466+
The [motion](/operate/reference/services/motion/) and [navigation](/operate/reference/services/navigation/) services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.
467+
468+
{{< tabs >}}
469+
{{% tab name="Python" %}}
470+
471+
**Parameters:**
472+
473+
- `extra` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
474+
- `timeout` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
475+
476+
**Returns:**
477+
478+
- ([List[viam.proto.common.Geometry]](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.Geometry)): The geometries associated with the Component.
479+
480+
**Example:**
481+
482+
```python {class="line-numbers linkable-line-numbers"}
483+
my_gantry = Gantry.from_robot(robot=machine, name="my_gantry")
484+
geometries = await my_gantry.get_geometries()
485+
486+
if geometries:
487+
# Get the center of the first geometry
488+
print(f"Pose of the first geometry's centerpoint: {geometries[0].center}")
489+
```
490+
491+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/gantry/client/index.html#viam.components.gantry.client.GantryClient.get_geometries).
492+
493+
{{% /tab %}}
494+
{{< /tabs >}}
495+
463496
### Reconfigure
464497

465498
Reconfigure this resource.
@@ -490,6 +523,32 @@ For built-in models, model-specific commands are covered with each model's docum
490523
If you are implementing your own gantry and add features that have no built-in API method, you can access them with `DoCommand`.
491524

492525
{{< tabs >}}
526+
{{% tab name="Python" %}}
527+
528+
**Parameters:**
529+
530+
- `command` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute.
531+
- `timeout` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
532+
533+
**Returns:**
534+
535+
- (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.ValueTypes]): Result of the executed command.
536+
537+
**Raises:**
538+
539+
- (NotImplementedError): Raised if the Resource does not support arbitrary commands.
540+
541+
**Example:**
542+
543+
```python {class="line-numbers linkable-line-numbers"}
544+
my_gantry = Gantry.from_robot(robot=machine, name="my_gantry")
545+
command = {"cmd": "test", "data1": 500}
546+
result = await my_gantry.do_command(command)
547+
```
548+
549+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/gantry/client/index.html#viam.components.gantry.client.GantryClient.do_command).
550+
551+
{{% /tab %}}
493552
{{% tab name="Flutter" %}}
494553

495554
**Parameters:**
@@ -547,6 +606,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
547606

548607
- [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html)
549608

609+
**Example:**
610+
611+
```dart {class="line-numbers linkable-line-numbers"}
612+
final myGantryResourceName = myGantry.getResourceName("my_gantry");
613+
```
614+
550615
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Gantry/getResourceName.html).
551616

552617
{{% /tab %}}

Diff for: static/include/components/apis/generated/generic_component-table.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
| Method Name | Description | `viam-micro-server` Support |
33
| ----------- | ----------- | --------------------------- |
44
| [`DoCommand`](/dev/reference/apis/components/generic/#docommand) | Execute model-specific commands. | <p class="center-text"><i class="fas fa-check" title="yes"></i></p> |
5+
| [`GetGeometries`](/dev/reference/apis/components/generic/#getgeometries) | Get all the geometries associated with the generic component in its current configuration, in the frame of the generic component. | <p class="center-text"><i class="fas fa-times" title="no"></i></p> |
6+
| [`DoCommand`](/dev/reference/apis/components/generic/#docommand) | Execute model-specific commands. |
57
| [`GetResourceName`](/dev/reference/apis/components/generic/#getresourcename) | Get the `ResourceName` for this generic component with the given name. | <p class="center-text"><i class="fas fa-times" title="no"></i></p> |
68
| [`Close`](/dev/reference/apis/components/generic/#close) | Safely shut down the resource and prevent further use. | <p class="center-text"><i class="fas fa-times" title="no"></i></p> |

Diff for: static/include/components/apis/generated/generic_component.md

+95-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,95 @@ For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/r
6363

6464
**Returns:**
6565

66-
- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)\<[Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>\>
66+
- [Future](https://api.flutter.dev/flutter/dart-core/Future-class.html)\<[Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>\>
67+
68+
**Example:**
69+
70+
```dart {class="line-numbers linkable-line-numbers"}
71+
// Example using doCommand with an arm component
72+
const command = {'cmd': 'test', 'data1': 500};
73+
var result = myArm.doCommand(command);
74+
```
75+
76+
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Resource/doCommand.html).
77+
78+
{{% /tab %}}
79+
{{< /tabs >}}
80+
81+
### GetGeometries
82+
83+
Get all the geometries associated with the generic component in its current configuration, in the [frame](/operate/mobility/define-geometry/) of the generic component.
84+
The [motion](/operate/reference/services/motion/) and [navigation](/operate/reference/services/navigation/) services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.
85+
86+
{{< tabs >}}
87+
{{% tab name="Python" %}}
88+
89+
**Parameters:**
90+
91+
- `extra` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
92+
- `timeout` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
93+
94+
**Returns:**
95+
96+
- ([List[viam.proto.common.Geometry]](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.Geometry)): The geometries associated with the Component.
97+
98+
**Example:**
99+
100+
```python {class="line-numbers linkable-line-numbers"}
101+
my_generic_component = Generic.from_robot(robot=machine, name="my_generic_component")
102+
geometries = await my_generic_component.get_geometries()
103+
104+
if geometries:
105+
# Get the center of the first geometry
106+
print(f"Pose of the first geometry's centerpoint: {geometries[0].center}")
107+
```
108+
109+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/generic/client/index.html#viam.components.generic.client.GenericClient.get_geometries).
110+
111+
{{% /tab %}}
112+
{{< /tabs >}}
113+
114+
### DoCommand
115+
116+
Execute model-specific commands.
117+
If you are implementing your own generic component and add features that have no built-in API method, you can access them with `DoCommand`.
118+
119+
{{< tabs >}}
120+
{{% tab name="Python" %}}
121+
122+
**Parameters:**
123+
124+
- `command` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute.
125+
- `timeout` ([float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
126+
127+
**Returns:**
128+
129+
- (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]): Result of the executed command.
130+
131+
**Raises:**
132+
133+
- (NotImplementedError): Raised if the Resource does not support arbitrary commands.
134+
135+
**Example:**
136+
137+
```python {class="line-numbers linkable-line-numbers"}
138+
my_generic_component = Generic.from_robot(robot=machine, name="my_generic_component")
139+
command = {"cmd": "test", "data1": 500}
140+
result = await my_generic_component.do_command(command)
141+
```
142+
143+
For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/generic/client/index.html#viam.components.generic.client.GenericClient.do_command).
144+
145+
{{% /tab %}}
146+
{{% tab name="Flutter" %}}
147+
148+
**Parameters:**
149+
150+
- `command` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\> (required)
151+
152+
**Returns:**
153+
154+
- [Future](https://api.flutter.dev/flutter/dart-core/Future-class.html)\<[Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>\>
67155

68156
**Example:**
69157

@@ -112,6 +200,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
112200

113201
- [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html)
114202

203+
**Example:**
204+
205+
```dart {class="line-numbers linkable-line-numbers"}
206+
final myGenericResourceName = myGeneric.getResourceName("my_generic");
207+
```
208+
115209
For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Generic/getResourceName.html).
116210

117211
{{% /tab %}}

0 commit comments

Comments
 (0)