:py:mod:`viam.services.sensors` =============================== .. py:module:: viam.services.sensors Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 client/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: viam.services.sensors.SensorsClient .. py:class:: SensorsClient(name: str, channel: grpclib.client.Channel) Bases: :py:obj:`viam.services.service_client_base.ServiceClientBase`, :py:obj:`viam.resource.rpc_client_base.ReconfigurableResourceRPCClientBase` Connect to the SensorService, which centralizes all Sensors in a single place .. py:attribute:: SUBTYPE :type: Final .. py:attribute:: client :type: viam.proto.service.sensors.SensorsServiceStub .. py:method:: get_sensors(*, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None) -> List[viam.proto.common.ResourceName] :async: Get the ``ResourceName`` of all the ``Sensor`` resources connected to this Robot :returns: The list of all Sensors :rtype: List[viam.proto.common.ResourceName] .. py:method:: get_readings(sensors: List[viam.proto.common.ResourceName], *, extra: Optional[Mapping[str, Any]] = None, timeout: Optional[float] = None) -> Mapping[viam.proto.common.ResourceName, Mapping[str, viam.utils.SensorReading]] :async: Get the readings from the specific sensors provided :param sensors: The ``ResourceName`` of the the ``Sensor`` resources to get readings from :type sensors: List[viam.proto.common.ResourceName] :returns: The readings from the sensors, mapped by ``ResourceName`` :rtype: Mapping[viam.proto.common.ResourceName, Mapping[str, Any]] .. py:method:: do_command(command: Mapping[str, viam.utils.ValueTypes], *, timeout: Optional[float] = None, **__) -> Mapping[str, viam.utils.ValueTypes] :async: Send/receive arbitrary commands :param command: The command to execute :type command: Dict[str, ValueTypes] :returns: Result of the executed command :rtype: Dict[str, ValueTypes] .. py:method:: from_robot(robot: viam.robot.client.RobotClient, name: str = 'builtin') -> typing_extensions.Self :classmethod: Get the service client named ``name`` from the provided robot. :param robot: The robot :type robot: RobotClient :param name: The name of the service client :type name: str :returns: The service client, if it exists on the robot :rtype: Self .. py:method:: get_resource_name(name: str) -> viam.proto.common.ResourceName :classmethod: Get the ResourceName for this Resource with the given name :: # Can be used with any resource, using an arm as an example my_arm_name = my_arm.get_resource_name("my_arm") :param name: The name of the Resource :type name: str :returns: The ResourceName of this Resource :rtype: ResourceName .. py:method:: 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. ). :param kwargs: The kwargs object containing the operation :type kwargs: Mapping[str, Any] :returns: The operation associated with this function :rtype: viam.operations.Operation .. py:method:: close() :async: Safely shut down the resource and prevent further use. Close must be idempotent. Later configuration may allow a resource to be "open" again. If a resource does not want or need a close function, it is assumed that the resource does not need to return errors when future non-Close methods are called. :: await component.close()