viam.components.input.client

Module Contents

Classes

ControllerClient

gRPC client for an Input Controller

Attributes

LOGGER

viam.components.input.client.LOGGER
class viam.components.input.client.ControllerClient(name: str, channel: grpclib.client.Channel)[source]

Bases: viam.components.input.input.Controller, viam.resource.rpc_client_base.ReconfigurableResourceRPCClientBase

gRPC client for an Input Controller

async get_controls(*, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) List[viam.components.input.input.Control][source]

Returns a list of Controls provided by the Controller

Returns:

List of controls provided by the Controller

Return type:

List[Control]

async get_events(*, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) Dict[viam.components.input.input.Control, viam.components.input.input.Event][source]

Returns the most recent Event for each input (which should be the current state)

Returns:

The most recent event for each input

Return type:

Dict[Control, Event]

register_control_callback(control: viam.components.input.input.Control, triggers: List[viam.components.input.input.EventType], function: Optional[viam.components.input.input.ControlFunction], extra: Optional[Dict[str, Any]] = None)[source]

Register a function that will fire on given EventTypes for a given Control

Parameters:
  • control (Control) – The control to register the function for

  • triggers (List[EventType]) – The events that will trigger the function

  • function (ControlFunction) – The function to run on specific triggers

reset_channel(channel: grpclib.client.Channel)[source]

Called when the RPC channel was reset. Passes in the new channel.

Parameters:

channel (Channel) – The new RPC Channel

async trigger_event(event: viam.components.input.input.Event, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None)[source]

Directly send an Event (such as a button press) from external code

Parameters:

event (Event) – The event to trigger

async do_command(command: Mapping[str, viam.utils.ValueTypes], *, timeout: Optional[float] = None) Mapping[str, viam.utils.ValueTypes][source]

Send/Receive arbitrary commands to the Resource

Parameters:

command (Mapping[str, ValueTypes]) – The command to execute

Raises:

NotImplementedError – Raised if the Resource does not support arbitrary commands

Returns:

Result of the executed command

Return type:

Mapping[str, ValueTypes]

async get_geometries(*, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) List[viam.proto.common.Geometry][source]

Get all geometries associated with the Component, in their current configuration, in the frame of the Component.

Returns:

The geometries associated with the Component.

Return type:

List[Geometry]

classmethod from_robot(robot: viam.robot.client.RobotClient, name: str) typing_extensions.Self

Get the component named name from the provided robot.

Parameters:
  • robot (RobotClient) – The robot

  • name (str) – The name of the component

Returns:

The component, if it exists on the robot

Return type:

Self

classmethod get_resource_name(name: str) viam.proto.common.ResourceName

Get the ResourceName for this Resource with the given name

Parameters:

name (str) – The name of the Resource

get_operation(kwargs: Mapping[str, Any]) viam.operations.Operation

Get the Operation associated with the currently running function.

When writing custom resources, you should get the Operation by calling this function and check to see if it’s cancelled. If the Operation is cancelled, then you can perform any necessary (terminating long running tasks, cleaning up connections, etc. ).

Parameters:

kwargs (Mapping[str, Any]) – The kwargs object containing the operation

Returns:

The operation associated with this function

Return type:

viam.operations.Operation