Previous
Base Remote Control
The discovery service API allows you to get a list of resources available to configure on a machine based on the hardware that is connected to or part of the machine. Discoverable resources can include components that are physically connected to the machine, as well as components that are available on the machine’s local network.
The discovery service supports the following methods:
Method Name | Description |
---|---|
DiscoverResources | Get a list of component configs of all resources available to configure on a machine based on the hardware that is connected to or part of the machine. |
To get started using Viam’s SDKs to connect to and control your machine, go to your machine’s page on the Viam app, navigate to the CONNECT tab’s Code sample page, select your preferred programming language, and copy the sample code.
To show your machine’s API key in the sample code, toggle Include API key.
We strongly recommend that you add your API key and machine address as an environment variable. Anyone with these secrets can access your machine, and the computer running your machine.
When executed, this sample code creates a connection to your machine as a client.
The following code examples assume that you have a machine configured with a Discovery
service.
from viam.services.discovery import DiscoveryClient
import (
"go.viam.com/rdk/services/discovery"
)
Get a list of component configs of all resources available to configure on a machine based on the hardware that is connected to or part of the machine.
Parameters:
extra
(Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout
(float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.Returns:
Example:
my_discovery = DiscoveryClient.from_robot(machine, "my_discovery")
# Get the discovered resources
result = await my_discovery.discover_resources(
"my_discovery",
)
discoveries = result.discoveries
For more information, see the Python SDK Docs.
Parameters:
ctx
(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra
(map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
For more information, see the Go SDK Docs.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!