From 0b1050d372044d98d8d70c7874bf371d29edfd3e Mon Sep 17 00:00:00 2001 From: Naomi Pentrel <5212232+npentrel@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:07:45 +0100 Subject: [PATCH] DOCS-3341: Add missing python methods and fix check (#3858) --- .github/workflows/check_python_methods.py | 14 +-- .github/workflows/sdk_protos_map.csv | 12 ++- .../include/components/apis/generated/arm.md | 6 ++ .../components/apis/generated/board.md | 18 ++-- .../components/apis/generated/camera.md | 6 ++ .../components/apis/generated/gantry-table.md | 1 + .../components/apis/generated/gantry.md | 65 +++++++++++++ .../apis/generated/generic_component-table.md | 2 + .../apis/generated/generic_component.md | 96 ++++++++++++++++++- .../components/apis/generated/gripper.md | 6 ++ .../apis/generated/input_controller-table.md | 1 + .../apis/generated/input_controller.md | 35 +++++++ .../apis/generated/movement_sensor.md | 39 ++++++++ .../components/apis/generated/power_sensor.md | 6 ++ .../components/apis/generated/sensor-table.md | 1 + .../components/apis/generated/sensor.md | 39 ++++++++ .../components/apis/generated/servo.md | 2 +- .../protos/robot.DiscoverComponents.md | 1 + .../include/services/apis/generated/motion.md | 8 +- .../include/services/apis/generated/vision.md | 6 ++ 20 files changed, 341 insertions(+), 23 deletions(-) create mode 100644 static/include/robot/apis/overrides/protos/robot.DiscoverComponents.md diff --git a/.github/workflows/check_python_methods.py b/.github/workflows/check_python_methods.py index bdbf624d5a..beced9d9a5 100644 --- a/.github/workflows/check_python_methods.py +++ b/.github/workflows/check_python_methods.py @@ -30,11 +30,11 @@ ] services_page_mapping = { - "motion": "services/motion", - "navigation": "services/navigation", - "slam": "services/slam", - "vision": "services/vision", - "ml": "services/ml" + "motion": "dev/reference/apis/services/motion/", + "navigation": "dev/reference/apis/services/navigation", + "slam": "dev/reference/apis/services/slam", + "vision": "dev/reference/apis/services/vision", + "ml": "dev/reference/apis/services/ml" } def is_unimplemented(obj): @@ -246,12 +246,12 @@ def parse(type, names): soup2 = BeautifulSoup(fp, 'html.parser') else: if type == "app" or type == "robot": - soup2 = make_soup(f"https://docs.viam.com/program/apis/{service}/") + soup2 = make_soup(f"https://docs.viam.com/dev/reference/apis/{service}/") else: if service in services_page_mapping.keys(): soup2 = make_soup(f"https://docs.viam.com/{services_page_mapping[service]}/") else: - soup2 = make_soup(f"https://docs.viam.com/configure/{type}/{service}/") + soup2 = make_soup(f"https://docs.viam.com/dev/reference/apis/{type}/{service}/") # Find all links on Docs site soup all_links = soup2.find_all('a') diff --git a/.github/workflows/sdk_protos_map.csv b/.github/workflows/sdk_protos_map.csv index 24605701a8..64458487e2 100644 --- a/.github/workflows/sdk_protos_map.csv +++ b/.github/workflows/sdk_protos_map.csv @@ -91,15 +91,17 @@ gantry,GetGeometries,,,, ## HACK: proto for these (and/or inherited in Go SDK), manually mapping: gantry,IsMoving,,is_moving,IsMoving,isMoving gantry,Stop,,stop,Stop,stop +gantry,GetGeometries,,get_geometries,, gantry,Reconfigure,,,Reconfigure, -gantry,DoCommand,,,,doCommand +gantry,DoCommand,,do_command,,doCommand gantry,GetResourceName,,get_resource_name,,getResourceName gantry,Close,,close,Close, ## Generic Component ## NOTED:Generic Component in Go SDK doesn't appear to implement (inherit) these: generic_component,DoCommand,Yes,do_command,DoCommand,doCommand -# generic_component,GetGeometries,No,,, +generic_component,GetGeometries,No,get_geometries,, +generic_component,DoCommand,,do_command,,doCommand ## HACK: No proto for close, manually mapping: ## NOTED: Go SDK also missing Close, but we have it in our docs?: generic_component,GetResourceName,No,get_resource_name,,getResourceName @@ -128,7 +130,7 @@ input_controller,GetGeometries,,get_geometries,, input_controller,RegisterControlCallback,,register_control_callback,RegisterControlCallback, ## HACK: proto for these (and/or inherited in Go SDK), manually mapping: input_controller,Reconfigure,,,Reconfigure, -input_controller,DoCommand,,,, +input_controller,DoCommand,,do_command,, input_controller,GetResourceName,,get_resource_name,, input_controller,Close,,close,Close, @@ -161,7 +163,7 @@ movement_sensor,GetProperties,Yes,get_properties,Properties,properties movement_sensor,GetAccuracy,No,get_accuracy,Accuracy,accuracy movement_sensor,GetLinearAcceleration,Yes,get_linear_acceleration,LinearAcceleration,linearAcceleration ## NOTED: Go SDK doesn't appear to implement this: -# NOT implemented movement_sensor,GetGeometries,No,get_geometries,, +movement_sensor,GetGeometries,No,get_geometries,, ## HACK: No proto for these (and/or inherited in Go SDK), manually mapping: movement_sensor,GetReadings,Yes,get_readings,Readings,readings movement_sensor,Reconfigure,No,,Reconfigure, @@ -187,6 +189,7 @@ power_sensor,Close,,close,Close, sensor,GetReadings,Yes,get_readings,Readings,readings # NOT implemented sensor,GetGeometries,No,get_geometries,, ## HACK: No proto for close (and/or inherited in Go SDK), manually mapping: +sensor,GetGeometries,,get_geometries,, sensor,Reconfigure,No,,Reconfigure, # NOT implemented in other languages sensor,DoCommand,,,,doCommand @@ -443,6 +446,7 @@ robot,FrameSystemConfig,,get_frame_system_config,FrameSystemConfig, robot,TransformPose,,transform_pose,TransformPose, robot,TransformPCD,,,TransformPointCloud, robot,StreamStatus,,,, +# DEPRECATED robot,DiscoverComponents,,discover_components,DiscoverComponents, robot,StopAll,,stop_all,StopAll, robot,RestartModule,,,RestartModule, robot,StartSession,,,, diff --git a/static/include/components/apis/generated/arm.md b/static/include/components/apis/generated/arm.md index e716b830d0..dc2d3c750c 100644 --- a/static/include/components/apis/generated/arm.md +++ b/static/include/components/apis/generated/arm.md @@ -758,6 +758,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myArmResourceName = myArm.getResourceName("my_arm"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Arm/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/board.md b/static/include/components/apis/generated/board.md index 8d355a4ee1..34e3c8e304 100644 --- a/static/include/components/apis/generated/board.md +++ b/static/include/components/apis/generated/board.md @@ -52,7 +52,7 @@ myBoard, err := board.FromRobot(robot, "my_board") pin, err := myBoard.GPIOPinByName("15") // Set the pin to high. -err := pin.Set(context.Background(), "true", nil) +err = pin.Set(context.Background(), true, nil) ``` 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") pin, err := myBoard.GPIOPinByName("15") // Get if it is true or false that the state of the pin is high. -high := pin.Get(context.Background(), nil) +high, err := pin.Get(context.Background(), nil) ``` 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") pin, err := myBoard.GPIOPinByName("15") // Returns the duty cycle. -duty_cycle := pin.PWM(context.Background(), nil) +duty_cycle, err := pin.PWM(context.Background(), nil) ``` 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") pin, err := myBoard.GPIOPinByName("15") // 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. -err := pin.SetPWM(context.Background(), .6, nil) +err = pin.SetPWM(context.Background(), .6, nil) ``` 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") pin, err := myBoard.GPIOPinByName("15") // Set the PWM frequency of this pin to 1600 Hz. -high := pin.SetPWMFreq(context.Background(), 1600, nil) +err = pin.SetPWMFreq(context.Background(), 1600, nil) ``` 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") analog, err := myBoard.AnalogByName("my_example_analog") // Set the pin to value 48. -err := analog.Write(context.Background(), 48, nil) +err = analog.Write(context.Background(), 48, nil) ``` 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/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myBoardResourceName = myBoard.getResourceName("my_board"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Board/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/camera.md b/static/include/components/apis/generated/camera.md index f1be2a8c3a..2fa51f036d 100644 --- a/static/include/components/apis/generated/camera.md +++ b/static/include/components/apis/generated/camera.md @@ -449,6 +449,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myCameraResourceName = myCamera.getResourceName("my_camera"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Camera/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/gantry-table.md b/static/include/components/apis/generated/gantry-table.md index f2c6c713fa..9dd8d2b469 100644 --- a/static/include/components/apis/generated/gantry-table.md +++ b/static/include/components/apis/generated/gantry-table.md @@ -7,6 +7,7 @@ | [`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. | | [`IsMoving`](/dev/reference/apis/components/gantry/#ismoving) | Get if the gantry is currently moving. | | [`Stop`](/dev/reference/apis/components/gantry/#stop) | Stop all motion of the gantry. | +| [`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. | | [`Reconfigure`](/dev/reference/apis/components/gantry/#reconfigure) | Reconfigure this resource. | | [`DoCommand`](/dev/reference/apis/components/gantry/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. | | [`GetResourceName`](/dev/reference/apis/components/gantry/#getresourcename) | Get the `ResourceName` for this gantry with the given name. | diff --git a/static/include/components/apis/generated/gantry.md b/static/include/components/apis/generated/gantry.md index 4c6f86312b..3e2d0f3f45 100644 --- a/static/include/components/apis/generated/gantry.md +++ b/static/include/components/apis/generated/gantry.md @@ -460,6 +460,39 @@ For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_s {{% /tab %}} {{< /tabs >}} +### GetGeometries + +Get all the geometries associated with the gantry in its current configuration, in the [frame](/operate/mobility/define-geometry/) of the gantry. +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. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `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. +- `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. + +**Returns:** + +- ([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. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_gantry = Gantry.from_robot(robot=machine, name="my_gantry") +geometries = await my_gantry.get_geometries() + +if geometries: + # Get the center of the first geometry + print(f"Pose of the first geometry's centerpoint: {geometries[0].center}") +``` + +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). + +{{% /tab %}} +{{< /tabs >}} + ### Reconfigure Reconfigure this resource. @@ -490,6 +523,32 @@ For built-in models, model-specific commands are covered with each model's docum If you are implementing your own gantry and add features that have no built-in API method, you can access them with `DoCommand`. {{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `command` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute. +- `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. + +**Returns:** + +- (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.ValueTypes]): Result of the executed command. + +**Raises:** + +- (NotImplementedError): Raised if the Resource does not support arbitrary commands. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_gantry = Gantry.from_robot(robot=machine, name="my_gantry") +command = {"cmd": "test", "data1": 500} +result = await my_gantry.do_command(command) +``` + +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). + +{{% /tab %}} {{% tab name="Flutter" %}} **Parameters:** @@ -547,6 +606,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myGantryResourceName = myGantry.getResourceName("my_gantry"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Gantry/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/generic_component-table.md b/static/include/components/apis/generated/generic_component-table.md index 4949bf8a79..a3d109994b 100644 --- a/static/include/components/apis/generated/generic_component-table.md +++ b/static/include/components/apis/generated/generic_component-table.md @@ -2,5 +2,7 @@ | Method Name | Description | `viam-micro-server` Support | | ----------- | ----------- | --------------------------- | | [`DoCommand`](/dev/reference/apis/components/generic/#docommand) | Execute model-specific commands. |
| +| [`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. |
| +| [`DoCommand`](/dev/reference/apis/components/generic/#docommand) | Execute model-specific commands. | | [`GetResourceName`](/dev/reference/apis/components/generic/#getresourcename) | Get the `ResourceName` for this generic component with the given name. |
| | [`Close`](/dev/reference/apis/components/generic/#close) | Safely shut down the resource and prevent further use. |
| diff --git a/static/include/components/apis/generated/generic_component.md b/static/include/components/apis/generated/generic_component.md index 1b983e44e9..99f8181b5b 100644 --- a/static/include/components/apis/generated/generic_component.md +++ b/static/include/components/apis/generated/generic_component.md @@ -63,7 +63,95 @@ For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/r **Returns:** -- [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\>\> +- [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\>\> + +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +// Example using doCommand with an arm component +const command = {'cmd': 'test', 'data1': 500}; +var result = myArm.doCommand(command); +``` + +For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Resource/doCommand.html). + +{{% /tab %}} +{{< /tabs >}} + +### GetGeometries + +Get all the geometries associated with the generic component in its current configuration, in the [frame](/operate/mobility/define-geometry/) of the generic component. +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. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `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. +- `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. + +**Returns:** + +- ([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. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_generic_component = Generic.from_robot(robot=machine, name="my_generic_component") +geometries = await my_generic_component.get_geometries() + +if geometries: + # Get the center of the first geometry + print(f"Pose of the first geometry's centerpoint: {geometries[0].center}") +``` + +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). + +{{% /tab %}} +{{< /tabs >}} + +### DoCommand + +Execute model-specific commands. +If you are implementing your own generic component and add features that have no built-in API method, you can access them with `DoCommand`. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `command` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute. +- `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. + +**Returns:** + +- (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]): Result of the executed command. + +**Raises:** + +- (NotImplementedError): Raised if the Resource does not support arbitrary commands. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_generic_component = Generic.from_robot(robot=machine, name="my_generic_component") +command = {"cmd": "test", "data1": 500} +result = await my_generic_component.do_command(command) +``` + +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). + +{{% /tab %}} +{{% tab name="Flutter" %}} + +**Parameters:** + +- `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) + +**Returns:** + +- [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\>\> **Example:** @@ -112,6 +200,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myGenericResourceName = myGeneric.getResourceName("my_generic"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Generic/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/gripper.md b/static/include/components/apis/generated/gripper.md index 98b14a76ee..1b7bd059d5 100644 --- a/static/include/components/apis/generated/gripper.md +++ b/static/include/components/apis/generated/gripper.md @@ -444,6 +444,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myGripperResourceName = myGripper.getResourceName("my_gripper"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Gripper/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/input_controller-table.md b/static/include/components/apis/generated/input_controller-table.md index 5e22099891..7feeedf3e4 100644 --- a/static/include/components/apis/generated/input_controller-table.md +++ b/static/include/components/apis/generated/input_controller-table.md @@ -7,5 +7,6 @@ | [`GetGeometries`](/dev/reference/apis/components/input-controller/#getgeometries) | Get all the geometries associated with the input controller in its current configuration, in the frame of the input controller. | | [`RegisterControlCallback`](/dev/reference/apis/components/input-controller/#registercontrolcallback) | Defines a callback function to execute whenever one of the EventTypes selected occurs on the given Control. | | [`Reconfigure`](/dev/reference/apis/components/input-controller/#reconfigure) | Reconfigure this resource. | +| [`DoCommand`](/dev/reference/apis/components/input-controller/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. | | [`GetResourceName`](/dev/reference/apis/components/input-controller/#getresourcename) | Get the `ResourceName` for this input controller with the given name. | | [`Close`](/dev/reference/apis/components/input-controller/#close) | Safely shut down the resource and prevent further use. | diff --git a/static/include/components/apis/generated/input_controller.md b/static/include/components/apis/generated/input_controller.md index 09c5ad37e2..6c383cefc5 100644 --- a/static/include/components/apis/generated/input_controller.md +++ b/static/include/components/apis/generated/input_controller.md @@ -348,6 +348,41 @@ For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/r {{% /tab %}} {{< /tabs >}} +### DoCommand + +Execute model-specific commands that are not otherwise defined by the component API. +For built-in models, model-specific commands are covered with each model's documentation. +If you are implementing your own input controller and add features that have no built-in API method, you can access them with `DoCommand`. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `command` (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute. +- `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. + +**Returns:** + +- (Mapping[[str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.ValueTypes]): Result of the executed command. + +**Raises:** + +- (NotImplementedError): Raised if the Resource does not support arbitrary commands. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_input_controller = InputController.from_robot(robot=machine, name="my_input_controller") +command = {"cmd": "test", "data1": 500} +result = await my_input_controller.do_command(command) +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/input/client/index.html#viam.components.input.client.ControllerClient.do_command). + +{{% /tab %}} +{{< /tabs >}} + ### GetResourceName Get the `ResourceName` for this input controller with the given name. diff --git a/static/include/components/apis/generated/movement_sensor.md b/static/include/components/apis/generated/movement_sensor.md index 26e7f2b2e5..d2aff2bf7b 100644 --- a/static/include/components/apis/generated/movement_sensor.md +++ b/static/include/components/apis/generated/movement_sensor.md @@ -631,6 +631,39 @@ For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_s {{% /tab %}} {{< /tabs >}} +### GetGeometries + +Get all the geometries associated with the movement sensor in its current configuration, in the [frame](/operate/mobility/define-geometry/) of the movement sensor. +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. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `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. +- `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. + +**Returns:** + +- ([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. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_movement_sensor = MovementSensor.from_robot(robot=machine, name="my_movement_sensor") +geometries = await my_movement_sensor.get_geometries() + +if geometries: + # Get the center of the first geometry + print(f"Pose of the first geometry's centerpoint: {geometries[0].center}") +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_geometries). + +{{% /tab %}} +{{< /tabs >}} + ### GetReadings Get all the measurements/data from the sensor. @@ -843,6 +876,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myMovementSensorResourceName = myMovementSensor.getResourceName("my_movement_sensor"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/MovementSensor/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/power_sensor.md b/static/include/components/apis/generated/power_sensor.md index 8430209f88..6c741242ca 100644 --- a/static/include/components/apis/generated/power_sensor.md +++ b/static/include/components/apis/generated/power_sensor.md @@ -428,6 +428,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myPowerSensorResourceName = myPowerSensor.getResourceName("my_power_sensor"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/PowerSensor/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/sensor-table.md b/static/include/components/apis/generated/sensor-table.md index 6c916e9014..fcce48bf96 100644 --- a/static/include/components/apis/generated/sensor-table.md +++ b/static/include/components/apis/generated/sensor-table.md @@ -2,6 +2,7 @@ | Method Name | Description | `viam-micro-server` Support | | ----------- | ----------- | --------------------------- | | [`GetReadings`](/dev/reference/apis/components/sensor/#getreadings) | Get the measurements or readings that this sensor provides. |
| +| [`GetGeometries`](/dev/reference/apis/components/sensor/#getgeometries) | Get all the geometries associated with the sensor in its current configuration, in the frame of the sensor. | | [`Reconfigure`](/dev/reference/apis/components/sensor/#reconfigure) | Reconfigure this resource. |
| | [`DoCommand`](/dev/reference/apis/components/sensor/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. | | [`GetResourceName`](/dev/reference/apis/components/sensor/#getresourcename) | Get the `ResourceName` for this sensor with the given name. |
| diff --git a/static/include/components/apis/generated/sensor.md b/static/include/components/apis/generated/sensor.md index 6cba6b44bb..01387b5f1d 100644 --- a/static/include/components/apis/generated/sensor.md +++ b/static/include/components/apis/generated/sensor.md @@ -70,6 +70,39 @@ For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_s {{% /tab %}} {{< /tabs >}} +### GetGeometries + +Get all the geometries associated with the sensor in its current configuration, in the [frame](/operate/mobility/define-geometry/) of the sensor. +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. + +{{< tabs >}} +{{% tab name="Python" %}} + +**Parameters:** + +- `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. +- `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. + +**Returns:** + +- ([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. + +**Example:** + +```python {class="line-numbers linkable-line-numbers"} +my_sensor = Sensor.from_robot(robot=machine, name="my_sensor") +geometries = await my_sensor.get_geometries() + +if geometries: + # Get the center of the first geometry + print(f"Pose of the first geometry's centerpoint: {geometries[0].center}") +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/sensor/client/index.html#viam.components.sensor.client.SensorClient.get_geometries). + +{{% /tab %}} +{{< /tabs >}} + ### Reconfigure Reconfigure this resource. @@ -157,6 +190,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final mySensorResourceName = mySensor.getResourceName("my_sensor"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Sensor/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/generated/servo.md b/static/include/components/apis/generated/servo.md index 98eee445e9..98b96b98ba 100644 --- a/static/include/components/apis/generated/servo.md +++ b/static/include/components/apis/generated/servo.md @@ -421,7 +421,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ ```dart {class="line-numbers linkable-line-numbers"} // Example: -var name = Servo.getResourceName('myServo'); +var name = Servo.getResourceName('my_servo'); ``` For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Servo/getResourceName.html). diff --git a/static/include/robot/apis/overrides/protos/robot.DiscoverComponents.md b/static/include/robot/apis/overrides/protos/robot.DiscoverComponents.md new file mode 100644 index 0000000000..6f788e1779 --- /dev/null +++ b/static/include/robot/apis/overrides/protos/robot.DiscoverComponents.md @@ -0,0 +1 @@ +Get a list of discovered potential component configurations, for example listing different supported resolutions. Currently only works for some cameras. \ No newline at end of file diff --git a/static/include/services/apis/generated/motion.md b/static/include/services/apis/generated/motion.md index 1615dbeb3f..59773de3e5 100644 --- a/static/include/services/apis/generated/motion.md +++ b/static/include/services/apis/generated/motion.md @@ -144,7 +144,7 @@ Make sure the [SLAM service](/operate/reference/services/slam/) you use alongsid - `component_name` ([viam.proto.common.ResourceName](https://python.viam.dev/autoapi/viam/gen/common/v1/common_pb2/index.html#viam.gen.common.v1.common_pb2.ResourceName)) (required): The `ResourceName` of the base to move. - `destination` ([viam.proto.common.Pose](https://python.viam.dev/autoapi/viam/components/arm/index.html#viam.components.arm.Pose)) (required): The destination, which can be any [Pose](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.Pose) with respect to the SLAM map's origin. - `slam_service_name` ([viam.proto.common.ResourceName](https://python.viam.dev/autoapi/viam/gen/common/v1/common_pb2/index.html#viam.gen.common.v1.common_pb2.ResourceName)) (required): The `ResourceName` of the [SLAM service](/operate/reference/services/slam/) from which the SLAM map is requested. -- `configuration` ([viam.proto.service.motion.MotionConfiguration](https://python.viam.dev/autoapi/viam/gen/service/motion/v1/motion_pb2/index.html#viam.gen.service.motion.v1.motion_pb2.MotionConfiguration)) (optional): +- `configuration` ([viam.proto.service.motion.MotionConfiguration](https://python.viam.dev/autoapi/viam/gen/service/motion/v1/motion_pb2/index.html#viam.gen.service.motion.v1.motion_pb2.MotionConfiguration)) (optional): The configuration you want to set across this machine for this motion service. This parameter and each of its fields are optional. - `obstacle_detectors` [(Iterable[ObstacleDetector])](https://python.viam.dev/autoapi/viam/proto/service/motion/index.html#viam.proto.service.motion.ObstacleDetector): The names of each [vision service](/operate/reference/services/vision/) and [camera](/operate/reference/components/camera/) resource pair you want to use for transient obstacle avoidance. @@ -188,7 +188,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ **Parameters:** - `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries. -- `req` [(MoveOnMapReq)](https://pkg.go.dev/go.viam.com/rdk/services/motion#MoveOnMapReq): +- `req` [(MoveOnMapReq)](https://pkg.go.dev/go.viam.com/rdk/services/motion#MoveOnMapReq): A `MoveOnMapReq` which contains the following values: - `ComponentName` [(resource.Name)](https://pkg.go.dev/go.viam.com/rdk/resource#Name): The `resource.Name` of the base to move. @@ -290,7 +290,7 @@ Translation in obstacles is not supported by the [navigation service](/operate/r - `movement_sensor_name` ([viam.proto.common.ResourceName](https://python.viam.dev/autoapi/viam/gen/common/v1/common_pb2/index.html#viam.gen.common.v1.common_pb2.ResourceName)) (required): The `ResourceName` of the [movement sensor](/operate/reference/components/movement-sensor/) that you want to use to check the machine's location. - `obstacles` ([Sequence[viam.proto.common.GeoGeometry]](https://python.viam.dev/autoapi/viam/gen/common/v1/common_pb2/index.html#viam.gen.common.v1.common_pb2.GeoGeometry)) (optional): Obstacles to consider when planning the motion of the component, with each represented as a `GeoGeometry`.