From d75116cdea451b18fb0344060c6279ffcdfbd2b6 Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 26 Oct 2023 11:32:06 -0400 Subject: [PATCH 1/2] add mapping --- docs/services/navigation/_index.md | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/services/navigation/_index.md b/docs/services/navigation/_index.md index 4a2469bc39..86952c615f 100644 --- a/docs/services/navigation/_index.md +++ b/docs/services/navigation/_index.md @@ -581,6 +581,61 @@ obstacles = await my_nav.get_obstacles() {{% /tab %}} {{< /tabs >}} +### DoCommand + +Execute model-specific commands that are not otherwise defined by the service API. +For built-in service models, any model-specific commands available are covered with each model's documentation. +If you are implementing your own navigation service and add features that have no built-in API method, you can access them with `DoCommand`. + +{{< tabs >}} +{{% tab name="Go" %}} + +**Parameters:** + +- `ctx` [(Context)](https://pkg.go.dev/context): A Context carries a deadline, a cancellation signal, and other values across API boundaries. +- `cmd` [(map\[string\]interface{})](https://go.dev/blog/maps): The command to execute. + +**Returns:** + +- [(map\[string\]interface{})](https://go.dev/blog/maps): Result of the executed command. +- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred. + +```go {class="line-numbers linkable-line-numbers"} +myNav, err := navigation.FromRobot(robot, "my_nav_service") + +resp, err := myNav.DoCommand(ctx, map[string]interface{}{"command": "dosomething", "someparameter": 52}) +``` + +For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource). + +{{% /tab %}} +{{% tab name="Python" %}} + +**Parameters:** + +- `command` [(Mapping[str, ValueTypes])](https://docs.python.org/3/library/stdtypes.html#typesmapping): The command to execute. +- `timeout` [(Optional\[float\])](https://docs.python.org/library/typing.html#typing.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, ValueTypes])](https://docs.python.org/3/library/stdtypes.html#typesmapping): Result of the executed command. + +```python {class="line-numbers linkable-line-numbers"} +my_nav = NavigationClient.from_robot(robot=robot, name="my_nav_service") + +my_command = { + "command": "dosomething", + "someparameter": 52 +} + +await my_nav.do_command(my_command) +``` + +For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/services/navigation/client/index.html#viam.services.navigation.client.NavigationClient.do_command). + +{{% /tab %}} +{{< /tabs >}} + ## Control Tab Usage After configuring the navigation service for your robot, navigate to the **Control** tab of the robot's page in the [Viam app](https://app.viam.com) and expand the card matching the name of your service to use an interface for rover navigation. From 5dfa92dd8788b479670b86817046cfce129dfb5c Mon Sep 17 00:00:00 2001 From: Sierra Guequierre Date: Thu, 26 Oct 2023 11:36:20 -0400 Subject: [PATCH 2/2] add to includes --- static/include/services/apis/navigation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/static/include/services/apis/navigation.md b/static/include/services/apis/navigation.md index e26263408e..5cc74945df 100644 --- a/static/include/services/apis/navigation.md +++ b/static/include/services/apis/navigation.md @@ -7,3 +7,4 @@ Method Name | Description [`AddWaypoint`](/services/navigation/#addwaypoint) | Add a waypoint to the service's data storage. [`RemoveWaypoint`](/services/navigation/#removewaypoint) | Remove a waypoint from the service's data storage. [`GetObstacles`](/services/navigation/#getobstacles) | Get the obstacles currently in the service's data storage. +[`DoCommand`](/services/navigation/#docommand) | Execute model-specific commands that are not otherwise defined by the service API.