diff --git a/src/viam/components/audio_in/__init__.py b/src/viam/components/audio_in/__init__.py index 867aa01b0..ca61c6a94 100644 --- a/src/viam/components/audio_in/__init__.py +++ b/src/viam/components/audio_in/__init__.py @@ -1,7 +1,7 @@ +from viam.media.audio import AudioCodec +from viam.proto.common import AudioInfo from viam.resource.registry import Registry, ResourceRegistration -from viam.proto.common import AudioInfo -from viam.media.audio import AudioCodec from .audio_in import AudioIn from .client import AudioInClient from .service import AudioInRPCService diff --git a/src/viam/components/audio_in/audio_in.py b/src/viam/components/audio_in/audio_in.py index 303f2a1b6..5ee090edf 100644 --- a/src/viam/components/audio_in/audio_in.py +++ b/src/viam/components/audio_in/audio_in.py @@ -2,11 +2,10 @@ import sys from typing import Final, Optional -from viam.streams import Stream - from viam.proto.common import GetPropertiesResponse from viam.proto.component.audioin import GetAudioResponse from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT +from viam.streams import Stream from ..component_base import ComponentBase @@ -32,12 +31,10 @@ class AudioIn(ComponentBase): AudioResponse: "TypeAlias" = GetAudioResponse AudioStream = Stream[AudioResponse] - @abc.abstractmethod - async def get_audio(self, codec: str, - duration_seconds: float, - previous_timestamp_ns:int, - *, timeout: Optional[float] = None, **kwargs) -> AudioStream: + async def get_audio( + self, codec: str, duration_seconds: float, previous_timestamp_ns: int, *, timeout: Optional[float] = None, **kwargs + ) -> AudioStream: """ Get a stream of audio from the device diff --git a/src/viam/components/audio_in/client.py b/src/viam/components/audio_in/client.py index fd45c1f0c..c025d6c25 100644 --- a/src/viam/components/audio_in/client.py +++ b/src/viam/components/audio_in/client.py @@ -1,44 +1,42 @@ -from typing import Any, Dict, List, Mapping, Optional import uuid +from typing import Any, Dict, List, Mapping, Optional from grpclib.client import Channel - -from viam.proto.component.audioin import GetAudioRequest, GetAudioResponse -from viam.proto.common import ( - DoCommandRequest, - DoCommandResponse, - GetPropertiesRequest, - Geometry) from grpclib.client import Stream as ClientStream -from viam.proto.component.audioin import AudioInServiceStub + +from viam.proto.common import DoCommandRequest, DoCommandResponse, Geometry, GetPropertiesRequest +from viam.proto.component.audioin import AudioInServiceStub, GetAudioRequest, GetAudioResponse from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase from viam.streams import StreamWithIterator +from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict from .audio_in import AudioIn -from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict class AudioInClient(AudioIn, ReconfigurableResourceRPCClientBase): - def __init__(self, name: str, channel: Channel) -> None: self.channel = channel self.client = AudioInServiceStub(channel) super().__init__(name) + async def get_audio( + self, + codec: str, + duration_seconds: float, + previous_timestamp_ns: int, + *, + extra: Optional[Dict[str, Any]] = None, + **kwargs, + ): + request = GetAudioRequest( + name=self.name, + codec=codec, + duration_seconds=duration_seconds, + previous_timestamp_nanoseconds=previous_timestamp_ns, + request_id=str(uuid.uuid4()), + extra=dict_to_struct(extra), + ) - async def get_audio(self, - codec:str, - duration_seconds: float, - previous_timestamp_ns:int, - *, - extra: Optional[Dict[str, Any]] = None, - **kwargs, - ): - request = GetAudioRequest(name=self.name, codec = codec, - duration_seconds=duration_seconds, - previous_timestamp_nanoseconds = previous_timestamp_ns, - request_id = str(uuid.uuid4()), - extra=dict_to_struct(extra)) async def read(): md = kwargs.get("metadata", self.Metadata()).proto audio_stream: ClientStream[GetAudioRequest, GetAudioResponse] @@ -52,7 +50,6 @@ async def read(): return StreamWithIterator(read()) - async def get_properties( self, *, diff --git a/src/viam/components/audio_in/service.py b/src/viam/components/audio_in/service.py index 1cc11c43a..cf23cd6b9 100644 --- a/src/viam/components/audio_in/service.py +++ b/src/viam/components/audio_in/service.py @@ -1,21 +1,16 @@ from grpclib.server import Stream from h2.exceptions import StreamClosedError - from viam.logging import getLogger from viam.proto.common import ( DoCommandRequest, DoCommandResponse, + GetGeometriesRequest, + GetGeometriesResponse, GetPropertiesRequest, GetPropertiesResponse, - GetGeometriesRequest, - GetGeometriesResponse -) -from viam.proto.component.audioin import ( - AudioInServiceBase, - GetAudioRequest, - GetAudioResponse ) +from viam.proto.component.audioin import AudioInServiceBase, GetAudioRequest, GetAudioResponse from viam.resource.rpc_service_base import ResourceRPCServiceBase from viam.utils import dict_to_struct, struct_to_dict @@ -23,6 +18,7 @@ LOGGER = getLogger(__name__) + class AudioInRPCService(AudioInServiceBase, ResourceRPCServiceBase[AudioIn]): """ gRPC Service for a generic audio in. @@ -30,14 +26,17 @@ class AudioInRPCService(AudioInServiceBase, ResourceRPCServiceBase[AudioIn]): RESOURCE_TYPE = AudioIn - async def GetAudio(self, stream: Stream[GetAudioRequest, GetAudioResponse]) -> None: request = await stream.recv_message() assert request is not None name = request.name audio_in = self.get_resource(name) - audio_stream = await audio_in.get_audio(codec=request.codec, duration_seconds=request.duration_seconds, - previous_timestamp_ns=request.previous_timestamp_nanoseconds, metadata=stream.metadata) + audio_stream = await audio_in.get_audio( + codec=request.codec, + duration_seconds=request.duration_seconds, + previous_timestamp_ns=request.previous_timestamp_nanoseconds, + metadata=stream.metadata, + ) async for response in audio_stream: try: response.request_id = request.request_id @@ -48,7 +47,6 @@ async def GetAudio(self, stream: Stream[GetAudioRequest, GetAudioResponse]) -> N LOGGER.error(e) return - async def GetProperties(self, stream: Stream[GetPropertiesRequest, GetPropertiesResponse]) -> None: request = await stream.recv_message() assert request is not None @@ -65,7 +63,7 @@ async def DoCommand(self, stream: Stream[DoCommandRequest, DoCommandResponse]) - request = await stream.recv_message() assert request is not None name = request.name - audio_in= self.get_resource(name) + audio_in = self.get_resource(name) timeout = stream.deadline.time_remaining() if stream.deadline else None result = await audio_in.do_command( command=struct_to_dict(request.command), diff --git a/src/viam/components/audio_input/audio_input.py b/src/viam/components/audio_input/audio_input.py index e808543ea..10b56e0ba 100644 --- a/src/viam/components/audio_input/audio_input.py +++ b/src/viam/components/audio_input/audio_input.py @@ -15,7 +15,7 @@ class AudioInput(ComponentBase, StreamSource[Audio]): - """ DEPRECATED: AudioInput is deprecated, use AudioIn instead + """DEPRECATED: AudioInput is deprecated, use AudioIn instead AudioInput represents a component that can capture audio. This acts as an abstract base class for any drivers representing specific diff --git a/src/viam/components/audio_input/client.py b/src/viam/components/audio_input/client.py index 3826b368b..d086dd30f 100644 --- a/src/viam/components/audio_input/client.py +++ b/src/viam/components/audio_input/client.py @@ -1,5 +1,5 @@ -from typing import Any, AsyncIterator, Dict, List, Mapping, Optional, Union import warnings +from typing import Any, AsyncIterator, Dict, List, Mapping, Optional, Union from grpclib.client import Channel @@ -28,8 +28,7 @@ class AudioInputClient(AudioInput, ReconfigurableResourceRPCClientBase): def __init__(self, name: str, channel: Channel): warnings.warn( - "AudioInputClient is deprecated and will be removed in a future release. " - "Use AudioIn instead.", + "AudioInputClient is deprecated and will be removed in a future release. " "Use AudioIn instead.", DeprecationWarning, stacklevel=2, ) diff --git a/src/viam/components/audio_input/service.py b/src/viam/components/audio_input/service.py index 4ecc5f5b7..23586a485 100644 --- a/src/viam/components/audio_input/service.py +++ b/src/viam/components/audio_input/service.py @@ -1,5 +1,5 @@ -import wave import warnings +import wave from datetime import timedelta from io import BytesIO @@ -32,8 +32,7 @@ class AudioInputRPCService(AudioInputServiceBase, ResourceRPCServiceBase[AudioIn def __init__(self, *args, **kwargs): warnings.warn( - "AudioInput is deprecated and will be removed in a future release. " - "Use AudioIn instead.", + "AudioInput is deprecated and will be removed in a future release. " "Use AudioIn instead.", DeprecationWarning, stacklevel=2, ) diff --git a/src/viam/components/audio_out/__init__.py b/src/viam/components/audio_out/__init__.py index 170204575..ce29703e0 100644 --- a/src/viam/components/audio_out/__init__.py +++ b/src/viam/components/audio_out/__init__.py @@ -1,7 +1,7 @@ +from viam.media.audio import AudioCodec +from viam.proto.common import AudioInfo from viam.resource.registry import Registry, ResourceRegistration -from viam.proto.common import AudioInfo -from viam.media.audio import AudioCodec from .audio_out import AudioOut from .client import AudioOutClient from .service import AudioOutRPCService diff --git a/src/viam/components/audio_out/audio_out.py b/src/viam/components/audio_out/audio_out.py index ae8c21e50..7c441f19f 100644 --- a/src/viam/components/audio_out/audio_out.py +++ b/src/viam/components/audio_out/audio_out.py @@ -29,13 +29,15 @@ class AudioOut(ComponentBase): Properties: "TypeAlias" = GetPropertiesResponse @abc.abstractmethod - async def play(self, - data: bytes, - info: Optional[AudioInfo] = None, - *, - extra: Optional[Dict[str, Any]] = None, - timeout: Optional[float] = None, - **kwargs) -> None: + async def play( + self, + data: bytes, + info: Optional[AudioInfo] = None, + *, + extra: Optional[Dict[str, Any]] = None, + timeout: Optional[float] = None, + **kwargs, + ) -> None: """ Play the given audio data. @@ -55,11 +57,7 @@ async def play(self, """ @abc.abstractmethod - async def get_properties(self, - *, - extra: Optional[Dict[str, Any]] = None, - timeout: Optional[float] = None, - **kwargs) -> Properties: + async def get_properties(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> Properties: """ Get the audio output device's properties. diff --git a/src/viam/components/audio_out/client.py b/src/viam/components/audio_out/client.py index 2b986ea0e..f520ffde0 100644 --- a/src/viam/components/audio_out/client.py +++ b/src/viam/components/audio_out/client.py @@ -2,24 +2,12 @@ from grpclib.client import Channel -from viam.proto.common import ( - DoCommandRequest, - DoCommandResponse, - GetPropertiesRequest, - GetPropertiesResponse, - Geometry -) -from viam.proto.component.audioout import ( - AudioOutServiceStub, - PlayRequest -) - - +from viam.proto.common import DoCommandRequest, DoCommandResponse, Geometry, GetPropertiesRequest, GetPropertiesResponse +from viam.proto.component.audioout import AudioOutServiceStub, PlayRequest from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase - from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict -from .audio_out import AudioOut, AudioInfo +from .audio_out import AudioInfo, AudioOut class AudioOutClient(AudioOut, ReconfigurableResourceRPCClientBase): @@ -30,13 +18,15 @@ def __init__(self, name: str, channel: Channel) -> None: self.client = AudioOutServiceStub(channel) super().__init__(name) - async def play(self, - data: bytes, - info: Optional[AudioInfo] = None, - *, - extra: Optional[Dict[str, Any]] = None, - timeout: Optional[float] = None, - **kwargs) -> None: + async def play( + self, + data: bytes, + info: Optional[AudioInfo] = None, + *, + extra: Optional[Dict[str, Any]] = None, + timeout: Optional[float] = None, + **kwargs, + ) -> None: if extra is None: extra = {} @@ -49,11 +39,9 @@ async def play(self, ) await self.client.Play(request, timeout=timeout, metadata=md) - async def get_properties(self, - *, - extra: Optional[Dict[str, Any]] = None, - timeout: Optional[float] = None, - **kwargs) -> AudioOut.Properties: + async def get_properties( + self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs + ) -> AudioOut.Properties: if extra is None: extra = {} diff --git a/src/viam/gen/common/v1/common_pb2.py b/src/viam/gen/common/v1/common_pb2.py index d08735690..b759660e0 100644 --- a/src/viam/gen/common/v1/common_pb2.py +++ b/src/viam/gen/common/v1/common_pb2.py @@ -9,17 +9,19 @@ from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2 from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16common/v1/common.proto\x12\x0eviam.common.v1\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"n\n\x0cResourceName\x12\x1c\n\tnamespace\x18\x01 \x01(\tR\tnamespace\x12\x12\n\x04type\x18\x02 \x01(\tR\x04type\x12\x18\n\x07subtype\x18\x03 \x01(\tR\x07subtype\x12\x12\n\x04name\x18\x04 \x01(\tR\x04name"y\n\x04Pose\x12\x0c\n\x01x\x18\x01 \x01(\x01R\x01x\x12\x0c\n\x01y\x18\x02 \x01(\x01R\x01y\x12\x0c\n\x01z\x18\x03 \x01(\x01R\x01z\x12\x0f\n\x03o_x\x18\x04 \x01(\x01R\x02oX\x12\x0f\n\x03o_y\x18\x05 \x01(\x01R\x02oY\x12\x0f\n\x03o_z\x18\x06 \x01(\x01R\x02oZ\x12\x14\n\x05theta\x18\x07 \x01(\x01R\x05theta"V\n\x0bOrientation\x12\x0f\n\x03o_x\x18\x01 \x01(\x01R\x02oX\x12\x0f\n\x03o_y\x18\x02 \x01(\x01R\x02oY\x12\x0f\n\x03o_z\x18\x03 \x01(\x01R\x02oZ\x12\x14\n\x05theta\x18\x04 \x01(\x01R\x05theta"`\n\x0bPoseInFrame\x12\'\n\x0freference_frame\x18\x01 \x01(\tR\x0ereferenceFrame\x12(\n\x04pose\x18\x02 \x01(\x0b2\x14.viam.common.v1.PoseR\x04pose"3\n\x07Vector3\x12\x0c\n\x01x\x18\x01 \x01(\x01R\x01x\x12\x0c\n\x01y\x18\x02 \x01(\x01R\x01y\x12\x0c\n\x01z\x18\x03 \x01(\x01R\x01z"%\n\x06Sphere\x12\x1b\n\tradius_mm\x18\x01 \x01(\x01R\x08radiusMm"C\n\x07Capsule\x12\x1b\n\tradius_mm\x18\x01 \x01(\x01R\x08radiusMm\x12\x1b\n\tlength_mm\x18\x02 \x01(\x01R\x08lengthMm"D\n\x10RectangularPrism\x120\n\x07dims_mm\x18\x01 \x01(\x0b2\x17.viam.common.v1.Vector3R\x06dimsMm"=\n\x04Mesh\x12!\n\x0ccontent_type\x18\x01 \x01(\tR\x0bcontentType\x12\x12\n\x04mesh\x18\x02 \x01(\x0cR\x04mesh"-\n\nPointCloud\x12\x1f\n\x0bpoint_cloud\x18\x01 \x01(\x0cR\npointCloud"\xe6\x02\n\x08Geometry\x12,\n\x06center\x18\x01 \x01(\x0b2\x14.viam.common.v1.PoseR\x06center\x120\n\x06sphere\x18\x02 \x01(\x0b2\x16.viam.common.v1.SphereH\x00R\x06sphere\x124\n\x03box\x18\x03 \x01(\x0b2 .viam.common.v1.RectangularPrismH\x00R\x03box\x123\n\x07capsule\x18\x05 \x01(\x0b2\x17.viam.common.v1.CapsuleH\x00R\x07capsule\x12*\n\x04mesh\x18\x06 \x01(\x0b2\x14.viam.common.v1.MeshH\x00R\x04mesh\x12<\n\npointcloud\x18\x07 \x01(\x0b2\x1a.viam.common.v1.PointCloudH\x00R\npointcloud\x12\x14\n\x05label\x18\x04 \x01(\tR\x05labelB\x0f\n\rgeometry_type"v\n\x11GeometriesInFrame\x12\'\n\x0freference_frame\x18\x01 \x01(\tR\x0ereferenceFrame\x128\n\ngeometries\x18\x02 \x03(\x0b2\x18.viam.common.v1.GeometryR\ngeometries"v\n\x10PointCloudObject\x12\x1f\n\x0bpoint_cloud\x18\x01 \x01(\x0cR\npointCloud\x12A\n\ngeometries\x18\x02 \x01(\x0b2!.viam.common.v1.GeometriesInFrameR\ngeometries"D\n\x08GeoPoint\x12\x1a\n\x08latitude\x18\x01 \x01(\x01R\x08latitude\x12\x1c\n\tlongitude\x18\x02 \x01(\x01R\tlongitude"}\n\x0bGeoGeometry\x124\n\x08location\x18\x01 \x01(\x0b2\x18.viam.common.v1.GeoPointR\x08location\x128\n\ngeometries\x18\x02 \x03(\x0b2\x18.viam.common.v1.GeometryR\ngeometries"\xbd\x02\n\tTransform\x12\'\n\x0freference_frame\x18\x01 \x01(\tR\x0ereferenceFrame\x12P\n\x16pose_in_observer_frame\x18\x02 \x01(\x0b2\x1b.viam.common.v1.PoseInFrameR\x13poseInObserverFrame\x12F\n\x0fphysical_object\x18\x03 \x01(\x0b2\x18.viam.common.v1.GeometryH\x00R\x0ephysicalObject\x88\x01\x01\x12\x12\n\x04uuid\x18\x04 \x01(\x0cR\x04uuid\x128\n\x08metadata\x18\x05 \x01(\x0b2\x17.google.protobuf.StructH\x01R\x08metadata\x88\x01\x01B\x12\n\x10_physical_objectB\x0b\n\t_metadata"\x88\x01\n\nWorldState\x12?\n\tobstacles\x18\x01 \x03(\x0b2!.viam.common.v1.GeometriesInFrameR\tobstacles\x129\n\ntransforms\x18\x03 \x03(\x0b2\x19.viam.common.v1.TransformR\ntransforms"-\n\x0eActuatorStatus\x12\x1b\n\tis_moving\x18\x01 \x01(\x08R\x08isMoving"d\n\x10ResponseMetadata\x12@\n\x0bcaptured_at\x18\x01 \x01(\x0b2\x1a.google.protobuf.TimestampH\x00R\ncapturedAt\x88\x01\x01B\x0e\n\x0c_captured_at"Y\n\x10DoCommandRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x121\n\x07command\x18\x02 \x01(\x0b2\x17.google.protobuf.StructR\x07command"D\n\x11DoCommandResponse\x12/\n\x06result\x18\x01 \x01(\x0b2\x17.google.protobuf.StructR\x06result"Y\n\x14GetKinematicsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"~\n\x15GetKinematicsResponse\x12<\n\x06format\x18\x01 \x01(\x0e2$.viam.common.v1.KinematicsFileFormatR\x06format\x12\'\n\x0fkinematics_data\x18\x02 \x01(\x0cR\x0ekinematicsData"Y\n\x14GetGeometriesRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"Q\n\x15GetGeometriesResponse\x128\n\ngeometries\x18\x01 \x03(\x0b2\x18.viam.common.v1.GeometryR\ngeometries"W\n\x12GetReadingsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\xb9\x01\n\x13GetReadingsResponse\x12M\n\x08readings\x18\x01 \x03(\x0b21.viam.common.v1.GetReadingsResponse.ReadingsEntryR\x08readings\x1aS\n\rReadingsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12,\n\x05value\x18\x02 \x01(\x0b2\x16.google.protobuf.ValueR\x05value:\x028\x01"\x97\x02\n\x08LogEntry\x12\x12\n\x04host\x18\x01 \x01(\tR\x04host\x12\x14\n\x05level\x18\x02 \x01(\tR\x05level\x12.\n\x04time\x18\x03 \x01(\x0b2\x1a.google.protobuf.TimestampR\x04time\x12\x1f\n\x0blogger_name\x18\x04 \x01(\tR\nloggerName\x12\x18\n\x07message\x18\x05 \x01(\tR\x07message\x12/\n\x06caller\x18\x06 \x01(\x0b2\x17.google.protobuf.StructR\x06caller\x12\x14\n\x05stack\x18\x07 \x01(\tR\x05stack\x12/\n\x06fields\x18\x08 \x03(\x0b2\x17.google.protobuf.StructR\x06fields"j\n\tAudioInfo\x12\x14\n\x05codec\x18\x01 \x01(\tR\x05codec\x12$\n\x0esample_rate_hz\x18\x02 \x01(\x05R\x0csampleRateHz\x12!\n\x0cnum_channels\x18\x03 \x01(\x05R\x0bnumChannels"Y\n\x14GetPropertiesRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x8b\x01\n\x15GetPropertiesResponse\x12)\n\x10supported_codecs\x18\x01 \x03(\tR\x0fsupportedCodecs\x12$\n\x0esample_rate_hz\x18\x02 \x01(\x05R\x0csampleRateHz\x12!\n\x0cnum_channels\x18\x03 \x01(\x05R\x0bnumChannels*\x7f\n\x14KinematicsFileFormat\x12&\n"KINEMATICS_FILE_FORMAT_UNSPECIFIED\x10\x00\x12\x1e\n\x1aKINEMATICS_FILE_FORMAT_SVA\x10\x01\x12\x1f\n\x1bKINEMATICS_FILE_FORMAT_URDF\x10\x02:a\n\x1asafety_heartbeat_monitored\x12\x1e.google.protobuf.MethodOptions\x18\xa4\x92\x05 \x01(\x08R\x18safetyHeartbeatMonitored\x88\x01\x01B/\n\x12com.viam.common.v1Z\x19go.viam.com/api/common/v1b\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16common/v1/common.proto\x12\x0eviam.common.v1\x1a google/protobuf/descriptor.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"n\n\x0cResourceName\x12\x1c\n\tnamespace\x18\x01 \x01(\tR\tnamespace\x12\x12\n\x04type\x18\x02 \x01(\tR\x04type\x12\x18\n\x07subtype\x18\x03 \x01(\tR\x07subtype\x12\x12\n\x04name\x18\x04 \x01(\tR\x04name"y\n\x04Pose\x12\x0c\n\x01x\x18\x01 \x01(\x01R\x01x\x12\x0c\n\x01y\x18\x02 \x01(\x01R\x01y\x12\x0c\n\x01z\x18\x03 \x01(\x01R\x01z\x12\x0f\n\x03o_x\x18\x04 \x01(\x01R\x02oX\x12\x0f\n\x03o_y\x18\x05 \x01(\x01R\x02oY\x12\x0f\n\x03o_z\x18\x06 \x01(\x01R\x02oZ\x12\x14\n\x05theta\x18\x07 \x01(\x01R\x05theta"V\n\x0bOrientation\x12\x0f\n\x03o_x\x18\x01 \x01(\x01R\x02oX\x12\x0f\n\x03o_y\x18\x02 \x01(\x01R\x02oY\x12\x0f\n\x03o_z\x18\x03 \x01(\x01R\x02oZ\x12\x14\n\x05theta\x18\x04 \x01(\x01R\x05theta"`\n\x0bPoseInFrame\x12\'\n\x0freference_frame\x18\x01 \x01(\tR\x0ereferenceFrame\x12(\n\x04pose\x18\x02 \x01(\x0b2\x14.viam.common.v1.PoseR\x04pose"3\n\x07Vector3\x12\x0c\n\x01x\x18\x01 \x01(\x01R\x01x\x12\x0c\n\x01y\x18\x02 \x01(\x01R\x01y\x12\x0c\n\x01z\x18\x03 \x01(\x01R\x01z"%\n\x06Sphere\x12\x1b\n\tradius_mm\x18\x01 \x01(\x01R\x08radiusMm"C\n\x07Capsule\x12\x1b\n\tradius_mm\x18\x01 \x01(\x01R\x08radiusMm\x12\x1b\n\tlength_mm\x18\x02 \x01(\x01R\x08lengthMm"D\n\x10RectangularPrism\x120\n\x07dims_mm\x18\x01 \x01(\x0b2\x17.viam.common.v1.Vector3R\x06dimsMm"=\n\x04Mesh\x12!\n\x0ccontent_type\x18\x01 \x01(\tR\x0bcontentType\x12\x12\n\x04mesh\x18\x02 \x01(\x0cR\x04mesh"-\n\nPointCloud\x12\x1f\n\x0bpoint_cloud\x18\x01 \x01(\x0cR\npointCloud"\xe6\x02\n\x08Geometry\x12,\n\x06center\x18\x01 \x01(\x0b2\x14.viam.common.v1.PoseR\x06center\x120\n\x06sphere\x18\x02 \x01(\x0b2\x16.viam.common.v1.SphereH\x00R\x06sphere\x124\n\x03box\x18\x03 \x01(\x0b2 .viam.common.v1.RectangularPrismH\x00R\x03box\x123\n\x07capsule\x18\x05 \x01(\x0b2\x17.viam.common.v1.CapsuleH\x00R\x07capsule\x12*\n\x04mesh\x18\x06 \x01(\x0b2\x14.viam.common.v1.MeshH\x00R\x04mesh\x12<\n\npointcloud\x18\x07 \x01(\x0b2\x1a.viam.common.v1.PointCloudH\x00R\npointcloud\x12\x14\n\x05label\x18\x04 \x01(\tR\x05labelB\x0f\n\rgeometry_type"v\n\x11GeometriesInFrame\x12\'\n\x0freference_frame\x18\x01 \x01(\tR\x0ereferenceFrame\x128\n\ngeometries\x18\x02 \x03(\x0b2\x18.viam.common.v1.GeometryR\ngeometries"v\n\x10PointCloudObject\x12\x1f\n\x0bpoint_cloud\x18\x01 \x01(\x0cR\npointCloud\x12A\n\ngeometries\x18\x02 \x01(\x0b2!.viam.common.v1.GeometriesInFrameR\ngeometries"D\n\x08GeoPoint\x12\x1a\n\x08latitude\x18\x01 \x01(\x01R\x08latitude\x12\x1c\n\tlongitude\x18\x02 \x01(\x01R\tlongitude"}\n\x0bGeoGeometry\x124\n\x08location\x18\x01 \x01(\x0b2\x18.viam.common.v1.GeoPointR\x08location\x128\n\ngeometries\x18\x02 \x03(\x0b2\x18.viam.common.v1.GeometryR\ngeometries"\xbd\x02\n\tTransform\x12\'\n\x0freference_frame\x18\x01 \x01(\tR\x0ereferenceFrame\x12P\n\x16pose_in_observer_frame\x18\x02 \x01(\x0b2\x1b.viam.common.v1.PoseInFrameR\x13poseInObserverFrame\x12F\n\x0fphysical_object\x18\x03 \x01(\x0b2\x18.viam.common.v1.GeometryH\x00R\x0ephysicalObject\x88\x01\x01\x12\x12\n\x04uuid\x18\x04 \x01(\x0cR\x04uuid\x128\n\x08metadata\x18\x05 \x01(\x0b2\x17.google.protobuf.StructH\x01R\x08metadata\x88\x01\x01B\x12\n\x10_physical_objectB\x0b\n\t_metadata"\x88\x01\n\nWorldState\x12?\n\tobstacles\x18\x01 \x03(\x0b2!.viam.common.v1.GeometriesInFrameR\tobstacles\x129\n\ntransforms\x18\x03 \x03(\x0b2\x19.viam.common.v1.TransformR\ntransforms"-\n\x0eActuatorStatus\x12\x1b\n\tis_moving\x18\x01 \x01(\x08R\x08isMoving"d\n\x10ResponseMetadata\x12@\n\x0bcaptured_at\x18\x01 \x01(\x0b2\x1a.google.protobuf.TimestampH\x00R\ncapturedAt\x88\x01\x01B\x0e\n\x0c_captured_at"Y\n\x10DoCommandRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x121\n\x07command\x18\x02 \x01(\x0b2\x17.google.protobuf.StructR\x07command"D\n\x11DoCommandResponse\x12/\n\x06result\x18\x01 \x01(\x0b2\x17.google.protobuf.StructR\x06result"Y\n\x14GetKinematicsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"~\n\x15GetKinematicsResponse\x12<\n\x06format\x18\x01 \x01(\x0e2$.viam.common.v1.KinematicsFileFormatR\x06format\x12\'\n\x0fkinematics_data\x18\x02 \x01(\x0cR\x0ekinematicsData"Y\n\x14GetGeometriesRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"Q\n\x15GetGeometriesResponse\x128\n\ngeometries\x18\x01 \x03(\x0b2\x18.viam.common.v1.GeometryR\ngeometries"W\n\x12Get3DModelsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\xaf\x01\n\x13Get3DModelsResponse\x12G\n\x06models\x18\x01 \x03(\x0b2/.viam.common.v1.Get3DModelsResponse.ModelsEntryR\x06models\x1aO\n\x0bModelsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12*\n\x05value\x18\x02 \x01(\x0b2\x14.viam.common.v1.MeshR\x05value:\x028\x01"W\n\x12GetReadingsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\xb9\x01\n\x13GetReadingsResponse\x12M\n\x08readings\x18\x01 \x03(\x0b21.viam.common.v1.GetReadingsResponse.ReadingsEntryR\x08readings\x1aS\n\rReadingsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12,\n\x05value\x18\x02 \x01(\x0b2\x16.google.protobuf.ValueR\x05value:\x028\x01"\x97\x02\n\x08LogEntry\x12\x12\n\x04host\x18\x01 \x01(\tR\x04host\x12\x14\n\x05level\x18\x02 \x01(\tR\x05level\x12.\n\x04time\x18\x03 \x01(\x0b2\x1a.google.protobuf.TimestampR\x04time\x12\x1f\n\x0blogger_name\x18\x04 \x01(\tR\nloggerName\x12\x18\n\x07message\x18\x05 \x01(\tR\x07message\x12/\n\x06caller\x18\x06 \x01(\x0b2\x17.google.protobuf.StructR\x06caller\x12\x14\n\x05stack\x18\x07 \x01(\tR\x05stack\x12/\n\x06fields\x18\x08 \x03(\x0b2\x17.google.protobuf.StructR\x06fields"j\n\tAudioInfo\x12\x14\n\x05codec\x18\x01 \x01(\tR\x05codec\x12$\n\x0esample_rate_hz\x18\x02 \x01(\x05R\x0csampleRateHz\x12!\n\x0cnum_channels\x18\x03 \x01(\x05R\x0bnumChannels"Y\n\x14GetPropertiesRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x8b\x01\n\x15GetPropertiesResponse\x12)\n\x10supported_codecs\x18\x01 \x03(\tR\x0fsupportedCodecs\x12$\n\x0esample_rate_hz\x18\x02 \x01(\x05R\x0csampleRateHz\x12!\n\x0cnum_channels\x18\x03 \x01(\x05R\x0bnumChannels*\x7f\n\x14KinematicsFileFormat\x12&\n"KINEMATICS_FILE_FORMAT_UNSPECIFIED\x10\x00\x12\x1e\n\x1aKINEMATICS_FILE_FORMAT_SVA\x10\x01\x12\x1f\n\x1bKINEMATICS_FILE_FORMAT_URDF\x10\x02:a\n\x1asafety_heartbeat_monitored\x12\x1e.google.protobuf.MethodOptions\x18\xa4\x92\x05 \x01(\x08R\x18safetyHeartbeatMonitored\x88\x01\x01B/\n\x12com.viam.common.v1Z\x19go.viam.com/api/common/v1b\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'common.v1.common_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: _globals['DESCRIPTOR']._loaded_options = None _globals['DESCRIPTOR']._serialized_options = b'\n\x12com.viam.common.v1Z\x19go.viam.com/api/common/v1' + _globals['_GET3DMODELSRESPONSE_MODELSENTRY']._loaded_options = None + _globals['_GET3DMODELSRESPONSE_MODELSENTRY']._serialized_options = b'8\x01' _globals['_GETREADINGSRESPONSE_READINGSENTRY']._loaded_options = None _globals['_GETREADINGSRESPONSE_READINGSENTRY']._serialized_options = b'8\x01' - _globals['_KINEMATICSFILEFORMAT']._serialized_start = 3761 - _globals['_KINEMATICSFILEFORMAT']._serialized_end = 3888 + _globals['_KINEMATICSFILEFORMAT']._serialized_start = 4028 + _globals['_KINEMATICSFILEFORMAT']._serialized_end = 4155 _globals['_RESOURCENAME']._serialized_start = 139 _globals['_RESOURCENAME']._serialized_end = 249 _globals['_POSE']._serialized_start = 251 @@ -70,17 +72,23 @@ _globals['_GETGEOMETRIESREQUEST']._serialized_end = 2776 _globals['_GETGEOMETRIESRESPONSE']._serialized_start = 2778 _globals['_GETGEOMETRIESRESPONSE']._serialized_end = 2859 - _globals['_GETREADINGSREQUEST']._serialized_start = 2861 - _globals['_GETREADINGSREQUEST']._serialized_end = 2948 - _globals['_GETREADINGSRESPONSE']._serialized_start = 2951 - _globals['_GETREADINGSRESPONSE']._serialized_end = 3136 - _globals['_GETREADINGSRESPONSE_READINGSENTRY']._serialized_start = 3053 - _globals['_GETREADINGSRESPONSE_READINGSENTRY']._serialized_end = 3136 - _globals['_LOGENTRY']._serialized_start = 3139 - _globals['_LOGENTRY']._serialized_end = 3418 - _globals['_AUDIOINFO']._serialized_start = 3420 - _globals['_AUDIOINFO']._serialized_end = 3526 - _globals['_GETPROPERTIESREQUEST']._serialized_start = 3528 - _globals['_GETPROPERTIESREQUEST']._serialized_end = 3617 - _globals['_GETPROPERTIESRESPONSE']._serialized_start = 3620 - _globals['_GETPROPERTIESRESPONSE']._serialized_end = 3759 \ No newline at end of file + _globals['_GET3DMODELSREQUEST']._serialized_start = 2861 + _globals['_GET3DMODELSREQUEST']._serialized_end = 2948 + _globals['_GET3DMODELSRESPONSE']._serialized_start = 2951 + _globals['_GET3DMODELSRESPONSE']._serialized_end = 3126 + _globals['_GET3DMODELSRESPONSE_MODELSENTRY']._serialized_start = 3047 + _globals['_GET3DMODELSRESPONSE_MODELSENTRY']._serialized_end = 3126 + _globals['_GETREADINGSREQUEST']._serialized_start = 3128 + _globals['_GETREADINGSREQUEST']._serialized_end = 3215 + _globals['_GETREADINGSRESPONSE']._serialized_start = 3218 + _globals['_GETREADINGSRESPONSE']._serialized_end = 3403 + _globals['_GETREADINGSRESPONSE_READINGSENTRY']._serialized_start = 3320 + _globals['_GETREADINGSRESPONSE_READINGSENTRY']._serialized_end = 3403 + _globals['_LOGENTRY']._serialized_start = 3406 + _globals['_LOGENTRY']._serialized_end = 3685 + _globals['_AUDIOINFO']._serialized_start = 3687 + _globals['_AUDIOINFO']._serialized_end = 3793 + _globals['_GETPROPERTIESREQUEST']._serialized_start = 3795 + _globals['_GETPROPERTIESREQUEST']._serialized_end = 3884 + _globals['_GETPROPERTIESRESPONSE']._serialized_start = 3887 + _globals['_GETPROPERTIESRESPONSE']._serialized_end = 4026 \ No newline at end of file diff --git a/src/viam/gen/common/v1/common_pb2.pyi b/src/viam/gen/common/v1/common_pb2.pyi index b499e9c3a..46ce3f36b 100644 --- a/src/viam/gen/common/v1/common_pb2.pyi +++ b/src/viam/gen/common/v1/common_pb2.pyi @@ -610,6 +610,64 @@ class GetGeometriesResponse(google.protobuf.message.Message): ... global___GetGeometriesResponse = GetGeometriesResponse +@typing.final +class Get3DModelsRequest(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + NAME_FIELD_NUMBER: builtins.int + EXTRA_FIELD_NUMBER: builtins.int + name: builtins.str + 'The component name' + + @property + def extra(self) -> google.protobuf.struct_pb2.Struct: + """Additional arguments to the method""" + + def __init__(self, *, name: builtins.str=..., extra: google.protobuf.struct_pb2.Struct | None=...) -> None: + ... + + def HasField(self, field_name: typing.Literal['extra', b'extra']) -> builtins.bool: + ... + + def ClearField(self, field_name: typing.Literal['extra', b'extra', 'name', b'name']) -> None: + ... +global___Get3DModelsRequest = Get3DModelsRequest + +@typing.final +class Get3DModelsResponse(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing.final + class ModelsEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str + + @property + def value(self) -> global___Mesh: + ... + + def __init__(self, *, key: builtins.str=..., value: global___Mesh | None=...) -> None: + ... + + def HasField(self, field_name: typing.Literal['value', b'value']) -> builtins.bool: + ... + + def ClearField(self, field_name: typing.Literal['key', b'key', 'value', b'value']) -> None: + ... + MODELS_FIELD_NUMBER: builtins.int + + @property + def models(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___Mesh]: + """the 3D models associated with the component""" + + def __init__(self, *, models: collections.abc.Mapping[builtins.str, global___Mesh] | None=...) -> None: + ... + + def ClearField(self, field_name: typing.Literal['models', b'models']) -> None: + ... +global___Get3DModelsResponse = Get3DModelsResponse + @typing.final class GetReadingsRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/src/viam/gen/component/arm/v1/arm_grpc.py b/src/viam/gen/component/arm/v1/arm_grpc.py index 643de47c5..45bac9ed7 100644 --- a/src/viam/gen/component/arm/v1/arm_grpc.py +++ b/src/viam/gen/component/arm/v1/arm_grpc.py @@ -52,8 +52,12 @@ async def GetKinematics(self, stream: 'grpclib.server.Stream[common.v1.common_pb async def GetGeometries(self, stream: 'grpclib.server.Stream[common.v1.common_pb2.GetGeometriesRequest, common.v1.common_pb2.GetGeometriesResponse]') -> None: pass + @abc.abstractmethod + async def Get3DModels(self, stream: 'grpclib.server.Stream[common.v1.common_pb2.Get3DModelsRequest, common.v1.common_pb2.Get3DModelsResponse]') -> None: + pass + def __mapping__(self) -> typing.Dict[str, grpclib.const.Handler]: - return {'/viam.component.arm.v1.ArmService/GetEndPosition': grpclib.const.Handler(self.GetEndPosition, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.GetEndPositionRequest, component.arm.v1.arm_pb2.GetEndPositionResponse), '/viam.component.arm.v1.ArmService/MoveToPosition': grpclib.const.Handler(self.MoveToPosition, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.MoveToPositionRequest, component.arm.v1.arm_pb2.MoveToPositionResponse), '/viam.component.arm.v1.ArmService/GetJointPositions': grpclib.const.Handler(self.GetJointPositions, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.GetJointPositionsRequest, component.arm.v1.arm_pb2.GetJointPositionsResponse), '/viam.component.arm.v1.ArmService/MoveToJointPositions': grpclib.const.Handler(self.MoveToJointPositions, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.MoveToJointPositionsRequest, component.arm.v1.arm_pb2.MoveToJointPositionsResponse), '/viam.component.arm.v1.ArmService/MoveThroughJointPositions': grpclib.const.Handler(self.MoveThroughJointPositions, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.MoveThroughJointPositionsRequest, component.arm.v1.arm_pb2.MoveThroughJointPositionsResponse), '/viam.component.arm.v1.ArmService/Stop': grpclib.const.Handler(self.Stop, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.StopRequest, component.arm.v1.arm_pb2.StopResponse), '/viam.component.arm.v1.ArmService/IsMoving': grpclib.const.Handler(self.IsMoving, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.IsMovingRequest, component.arm.v1.arm_pb2.IsMovingResponse), '/viam.component.arm.v1.ArmService/DoCommand': grpclib.const.Handler(self.DoCommand, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.DoCommandRequest, common.v1.common_pb2.DoCommandResponse), '/viam.component.arm.v1.ArmService/GetKinematics': grpclib.const.Handler(self.GetKinematics, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.GetKinematicsRequest, common.v1.common_pb2.GetKinematicsResponse), '/viam.component.arm.v1.ArmService/GetGeometries': grpclib.const.Handler(self.GetGeometries, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.GetGeometriesRequest, common.v1.common_pb2.GetGeometriesResponse)} + return {'/viam.component.arm.v1.ArmService/GetEndPosition': grpclib.const.Handler(self.GetEndPosition, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.GetEndPositionRequest, component.arm.v1.arm_pb2.GetEndPositionResponse), '/viam.component.arm.v1.ArmService/MoveToPosition': grpclib.const.Handler(self.MoveToPosition, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.MoveToPositionRequest, component.arm.v1.arm_pb2.MoveToPositionResponse), '/viam.component.arm.v1.ArmService/GetJointPositions': grpclib.const.Handler(self.GetJointPositions, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.GetJointPositionsRequest, component.arm.v1.arm_pb2.GetJointPositionsResponse), '/viam.component.arm.v1.ArmService/MoveToJointPositions': grpclib.const.Handler(self.MoveToJointPositions, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.MoveToJointPositionsRequest, component.arm.v1.arm_pb2.MoveToJointPositionsResponse), '/viam.component.arm.v1.ArmService/MoveThroughJointPositions': grpclib.const.Handler(self.MoveThroughJointPositions, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.MoveThroughJointPositionsRequest, component.arm.v1.arm_pb2.MoveThroughJointPositionsResponse), '/viam.component.arm.v1.ArmService/Stop': grpclib.const.Handler(self.Stop, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.StopRequest, component.arm.v1.arm_pb2.StopResponse), '/viam.component.arm.v1.ArmService/IsMoving': grpclib.const.Handler(self.IsMoving, grpclib.const.Cardinality.UNARY_UNARY, component.arm.v1.arm_pb2.IsMovingRequest, component.arm.v1.arm_pb2.IsMovingResponse), '/viam.component.arm.v1.ArmService/DoCommand': grpclib.const.Handler(self.DoCommand, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.DoCommandRequest, common.v1.common_pb2.DoCommandResponse), '/viam.component.arm.v1.ArmService/GetKinematics': grpclib.const.Handler(self.GetKinematics, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.GetKinematicsRequest, common.v1.common_pb2.GetKinematicsResponse), '/viam.component.arm.v1.ArmService/GetGeometries': grpclib.const.Handler(self.GetGeometries, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.GetGeometriesRequest, common.v1.common_pb2.GetGeometriesResponse), '/viam.component.arm.v1.ArmService/Get3DModels': grpclib.const.Handler(self.Get3DModels, grpclib.const.Cardinality.UNARY_UNARY, common.v1.common_pb2.Get3DModelsRequest, common.v1.common_pb2.Get3DModelsResponse)} class UnimplementedArmServiceBase(ArmServiceBase): @@ -87,6 +91,9 @@ async def GetKinematics(self, stream: 'grpclib.server.Stream[common.v1.common_pb async def GetGeometries(self, stream: 'grpclib.server.Stream[common.v1.common_pb2.GetGeometriesRequest, common.v1.common_pb2.GetGeometriesResponse]') -> None: raise grpclib.exceptions.GRPCError(grpclib.const.Status.UNIMPLEMENTED) + async def Get3DModels(self, stream: 'grpclib.server.Stream[common.v1.common_pb2.Get3DModelsRequest, common.v1.common_pb2.Get3DModelsResponse]') -> None: + raise grpclib.exceptions.GRPCError(grpclib.const.Status.UNIMPLEMENTED) + class ArmServiceStub: def __init__(self, channel: grpclib.client.Channel) -> None: @@ -99,4 +106,5 @@ def __init__(self, channel: grpclib.client.Channel) -> None: self.IsMoving = grpclib.client.UnaryUnaryMethod(channel, '/viam.component.arm.v1.ArmService/IsMoving', component.arm.v1.arm_pb2.IsMovingRequest, component.arm.v1.arm_pb2.IsMovingResponse) self.DoCommand = grpclib.client.UnaryUnaryMethod(channel, '/viam.component.arm.v1.ArmService/DoCommand', common.v1.common_pb2.DoCommandRequest, common.v1.common_pb2.DoCommandResponse) self.GetKinematics = grpclib.client.UnaryUnaryMethod(channel, '/viam.component.arm.v1.ArmService/GetKinematics', common.v1.common_pb2.GetKinematicsRequest, common.v1.common_pb2.GetKinematicsResponse) - self.GetGeometries = grpclib.client.UnaryUnaryMethod(channel, '/viam.component.arm.v1.ArmService/GetGeometries', common.v1.common_pb2.GetGeometriesRequest, common.v1.common_pb2.GetGeometriesResponse) \ No newline at end of file + self.GetGeometries = grpclib.client.UnaryUnaryMethod(channel, '/viam.component.arm.v1.ArmService/GetGeometries', common.v1.common_pb2.GetGeometriesRequest, common.v1.common_pb2.GetGeometriesResponse) + self.Get3DModels = grpclib.client.UnaryUnaryMethod(channel, '/viam.component.arm.v1.ArmService/Get3DModels', common.v1.common_pb2.Get3DModelsRequest, common.v1.common_pb2.Get3DModelsResponse) \ No newline at end of file diff --git a/src/viam/gen/component/arm/v1/arm_pb2.py b/src/viam/gen/component/arm/v1/arm_pb2.py index 4c3a92368..11ca46465 100644 --- a/src/viam/gen/component/arm/v1/arm_pb2.py +++ b/src/viam/gen/component/arm/v1/arm_pb2.py @@ -9,7 +9,7 @@ from ....common.v1 import common_pb2 as common_dot_v1_dot_common__pb2 from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1acomponent/arm/v1/arm.proto\x12\x15viam.component.arm.v1\x1a\x16common/v1/common.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto"Z\n\x15GetEndPositionRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"B\n\x16GetEndPositionResponse\x12(\n\x04pose\x18\x01 \x01(\x0b2\x14.viam.common.v1.PoseR\x04pose"(\n\x0eJointPositions\x12\x16\n\x06values\x18\x01 \x03(\x01R\x06values"]\n\x18GetJointPositionsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"`\n\x19GetJointPositionsResponse\x12C\n\tpositions\x18\x01 \x01(\x0b2%.viam.component.arm.v1.JointPositionsR\tpositions"\x80\x01\n\x15MoveToPositionRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12$\n\x02to\x18\x02 \x01(\x0b2\x14.viam.common.v1.PoseR\x02to\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x18\n\x16MoveToPositionResponse"\xa5\x01\n\x1bMoveToJointPositionsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12C\n\tpositions\x18\x02 \x01(\x0b2%.viam.component.arm.v1.JointPositionsR\tpositions\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x1e\n\x1cMoveToJointPositionsResponse"\xf9\x01\n MoveThroughJointPositionsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12C\n\tpositions\x18\x02 \x03(\x0b2%.viam.component.arm.v1.JointPositionsR\tpositions\x12A\n\x07options\x18\x03 \x01(\x0b2".viam.component.arm.v1.MoveOptionsH\x00R\x07options\x88\x01\x01\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extraB\n\n\x08_options"#\n!MoveThroughJointPositionsResponse"P\n\x0bStopRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x0e\n\x0cStopResponse"\xae\x01\n\x06Status\x127\n\x0cend_position\x18\x01 \x01(\x0b2\x14.viam.common.v1.PoseR\x0bendPosition\x12N\n\x0fjoint_positions\x18\x02 \x01(\x0b2%.viam.component.arm.v1.JointPositionsR\x0ejointPositions\x12\x1b\n\tis_moving\x18\x03 \x01(\x08R\x08isMoving"%\n\x0fIsMovingRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name"/\n\x10IsMovingResponse\x12\x1b\n\tis_moving\x18\x01 \x01(\x08R\x08isMoving"\xac\x01\n\x0bMoveOptions\x123\n\x14max_vel_degs_per_sec\x18\x01 \x01(\x01H\x00R\x10maxVelDegsPerSec\x88\x01\x01\x125\n\x15max_acc_degs_per_sec2\x18\x02 \x01(\x01H\x01R\x11maxAccDegsPerSec2\x88\x01\x01B\x17\n\x15_max_vel_degs_per_secB\x18\n\x16_max_acc_degs_per_sec22\xf1\x0c\n\nArmService\x12\xa1\x01\n\x0eGetEndPosition\x12,.viam.component.arm.v1.GetEndPositionRequest\x1a-.viam.component.arm.v1.GetEndPositionResponse"2\x82\xd3\xe4\x93\x02,\x12*/viam/api/v1/component/arm/{name}/position\x12\xa5\x01\n\x0eMoveToPosition\x12,.viam.component.arm.v1.MoveToPositionRequest\x1a-.viam.component.arm.v1.MoveToPositionResponse"6\xa0\x92)\x01\x82\xd3\xe4\x93\x02,\x1a*/viam/api/v1/component/arm/{name}/position\x12\xb1\x01\n\x11GetJointPositions\x12/.viam.component.arm.v1.GetJointPositionsRequest\x1a0.viam.component.arm.v1.GetJointPositionsResponse"9\x82\xd3\xe4\x93\x023\x121/viam/api/v1/component/arm/{name}/joint_positions\x12\xbe\x01\n\x14MoveToJointPositions\x122.viam.component.arm.v1.MoveToJointPositionsRequest\x1a3.viam.component.arm.v1.MoveToJointPositionsResponse"=\xa0\x92)\x01\x82\xd3\xe4\x93\x023\x1a1/viam/api/v1/component/arm/{name}/joint_positions\x12\xda\x01\n\x19MoveThroughJointPositions\x127.viam.component.arm.v1.MoveThroughJointPositionsRequest\x1a8.viam.component.arm.v1.MoveThroughJointPositionsResponse"J\xa0\x92)\x01\x82\xd3\xe4\x93\x02@">/viam/api/v1/component/arm/{name}/move_through_joint_positions\x12\x7f\n\x04Stop\x12".viam.component.arm.v1.StopRequest\x1a#.viam.component.arm.v1.StopResponse".\x82\xd3\xe4\x93\x02("&/viam/api/v1/component/arm/{name}/stop\x12\x90\x01\n\x08IsMoving\x12&.viam.component.arm.v1.IsMovingRequest\x1a\'.viam.component.arm.v1.IsMovingResponse"3\x82\xd3\xe4\x93\x02-\x12+/viam/api/v1/component/arm/{name}/is_moving\x12\x86\x01\n\tDoCommand\x12 .viam.common.v1.DoCommandRequest\x1a!.viam.common.v1.DoCommandResponse"4\x82\xd3\xe4\x93\x02.",/viam/api/v1/component/arm/{name}/do_command\x12\x92\x01\n\rGetKinematics\x12$.viam.common.v1.GetKinematicsRequest\x1a%.viam.common.v1.GetKinematicsResponse"4\x82\xd3\xe4\x93\x02.\x12,/viam/api/v1/component/arm/{name}/kinematics\x12\x92\x01\n\rGetGeometries\x12$.viam.common.v1.GetGeometriesRequest\x1a%.viam.common.v1.GetGeometriesResponse"4\x82\xd3\xe4\x93\x02.\x12,/viam/api/v1/component/arm/{name}/geometriesB=\n\x19com.viam.component.arm.v1Z go.viam.com/api/component/arm/v1b\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1acomponent/arm/v1/arm.proto\x12\x15viam.component.arm.v1\x1a\x16common/v1/common.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto"Z\n\x15GetEndPositionRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"B\n\x16GetEndPositionResponse\x12(\n\x04pose\x18\x01 \x01(\x0b2\x14.viam.common.v1.PoseR\x04pose"(\n\x0eJointPositions\x12\x16\n\x06values\x18\x01 \x03(\x01R\x06values"]\n\x18GetJointPositionsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"`\n\x19GetJointPositionsResponse\x12C\n\tpositions\x18\x01 \x01(\x0b2%.viam.component.arm.v1.JointPositionsR\tpositions"\x80\x01\n\x15MoveToPositionRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12$\n\x02to\x18\x02 \x01(\x0b2\x14.viam.common.v1.PoseR\x02to\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x18\n\x16MoveToPositionResponse"\xa5\x01\n\x1bMoveToJointPositionsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12C\n\tpositions\x18\x02 \x01(\x0b2%.viam.component.arm.v1.JointPositionsR\tpositions\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x1e\n\x1cMoveToJointPositionsResponse"\xf9\x01\n MoveThroughJointPositionsRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12C\n\tpositions\x18\x02 \x03(\x0b2%.viam.component.arm.v1.JointPositionsR\tpositions\x12A\n\x07options\x18\x03 \x01(\x0b2".viam.component.arm.v1.MoveOptionsH\x00R\x07options\x88\x01\x01\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extraB\n\n\x08_options"#\n!MoveThroughJointPositionsResponse"P\n\x0bStopRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12-\n\x05extra\x18c \x01(\x0b2\x17.google.protobuf.StructR\x05extra"\x0e\n\x0cStopResponse"\xae\x01\n\x06Status\x127\n\x0cend_position\x18\x01 \x01(\x0b2\x14.viam.common.v1.PoseR\x0bendPosition\x12N\n\x0fjoint_positions\x18\x02 \x01(\x0b2%.viam.component.arm.v1.JointPositionsR\x0ejointPositions\x12\x1b\n\tis_moving\x18\x03 \x01(\x08R\x08isMoving"%\n\x0fIsMovingRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name"/\n\x10IsMovingResponse\x12\x1b\n\tis_moving\x18\x01 \x01(\x08R\x08isMoving"\xac\x01\n\x0bMoveOptions\x123\n\x14max_vel_degs_per_sec\x18\x01 \x01(\x01H\x00R\x10maxVelDegsPerSec\x88\x01\x01\x125\n\x15max_acc_degs_per_sec2\x18\x02 \x01(\x01H\x01R\x11maxAccDegsPerSec2\x88\x01\x01B\x17\n\x15_max_vel_degs_per_secB\x18\n\x16_max_acc_degs_per_sec22\xff\r\n\nArmService\x12\xa1\x01\n\x0eGetEndPosition\x12,.viam.component.arm.v1.GetEndPositionRequest\x1a-.viam.component.arm.v1.GetEndPositionResponse"2\x82\xd3\xe4\x93\x02,\x12*/viam/api/v1/component/arm/{name}/position\x12\xa5\x01\n\x0eMoveToPosition\x12,.viam.component.arm.v1.MoveToPositionRequest\x1a-.viam.component.arm.v1.MoveToPositionResponse"6\xa0\x92)\x01\x82\xd3\xe4\x93\x02,\x1a*/viam/api/v1/component/arm/{name}/position\x12\xb1\x01\n\x11GetJointPositions\x12/.viam.component.arm.v1.GetJointPositionsRequest\x1a0.viam.component.arm.v1.GetJointPositionsResponse"9\x82\xd3\xe4\x93\x023\x121/viam/api/v1/component/arm/{name}/joint_positions\x12\xbe\x01\n\x14MoveToJointPositions\x122.viam.component.arm.v1.MoveToJointPositionsRequest\x1a3.viam.component.arm.v1.MoveToJointPositionsResponse"=\xa0\x92)\x01\x82\xd3\xe4\x93\x023\x1a1/viam/api/v1/component/arm/{name}/joint_positions\x12\xda\x01\n\x19MoveThroughJointPositions\x127.viam.component.arm.v1.MoveThroughJointPositionsRequest\x1a8.viam.component.arm.v1.MoveThroughJointPositionsResponse"J\xa0\x92)\x01\x82\xd3\xe4\x93\x02@">/viam/api/v1/component/arm/{name}/move_through_joint_positions\x12\x7f\n\x04Stop\x12".viam.component.arm.v1.StopRequest\x1a#.viam.component.arm.v1.StopResponse".\x82\xd3\xe4\x93\x02("&/viam/api/v1/component/arm/{name}/stop\x12\x90\x01\n\x08IsMoving\x12&.viam.component.arm.v1.IsMovingRequest\x1a\'.viam.component.arm.v1.IsMovingResponse"3\x82\xd3\xe4\x93\x02-\x12+/viam/api/v1/component/arm/{name}/is_moving\x12\x86\x01\n\tDoCommand\x12 .viam.common.v1.DoCommandRequest\x1a!.viam.common.v1.DoCommandResponse"4\x82\xd3\xe4\x93\x02.",/viam/api/v1/component/arm/{name}/do_command\x12\x92\x01\n\rGetKinematics\x12$.viam.common.v1.GetKinematicsRequest\x1a%.viam.common.v1.GetKinematicsResponse"4\x82\xd3\xe4\x93\x02.\x12,/viam/api/v1/component/arm/{name}/kinematics\x12\x92\x01\n\rGetGeometries\x12$.viam.common.v1.GetGeometriesRequest\x1a%.viam.common.v1.GetGeometriesResponse"4\x82\xd3\xe4\x93\x02.\x12,/viam/api/v1/component/arm/{name}/geometries\x12\x8b\x01\n\x0bGet3DModels\x12".viam.common.v1.Get3DModelsRequest\x1a#.viam.common.v1.Get3DModelsResponse"3\x82\xd3\xe4\x93\x02-\x12+/viam/api/v1/component/arm/{name}/3d_modelsB=\n\x19com.viam.component.arm.v1Z go.viam.com/api/component/arm/v1b\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'component.arm.v1.arm_pb2', _globals) @@ -36,6 +36,8 @@ _globals['_ARMSERVICE'].methods_by_name['GetKinematics']._serialized_options = b'\x82\xd3\xe4\x93\x02.\x12,/viam/api/v1/component/arm/{name}/kinematics' _globals['_ARMSERVICE'].methods_by_name['GetGeometries']._loaded_options = None _globals['_ARMSERVICE'].methods_by_name['GetGeometries']._serialized_options = b'\x82\xd3\xe4\x93\x02.\x12,/viam/api/v1/component/arm/{name}/geometries' + _globals['_ARMSERVICE'].methods_by_name['Get3DModels']._loaded_options = None + _globals['_ARMSERVICE'].methods_by_name['Get3DModels']._serialized_options = b'\x82\xd3\xe4\x93\x02-\x12+/viam/api/v1/component/arm/{name}/3d_models' _globals['_GETENDPOSITIONREQUEST']._serialized_start = 137 _globals['_GETENDPOSITIONREQUEST']._serialized_end = 227 _globals['_GETENDPOSITIONRESPONSE']._serialized_start = 229 @@ -71,4 +73,4 @@ _globals['_MOVEOPTIONS']._serialized_start = 1542 _globals['_MOVEOPTIONS']._serialized_end = 1714 _globals['_ARMSERVICE']._serialized_start = 1717 - _globals['_ARMSERVICE']._serialized_end = 3366 \ No newline at end of file + _globals['_ARMSERVICE']._serialized_end = 3508 \ No newline at end of file diff --git a/src/viam/media/audio.py b/src/viam/media/audio.py index 7dbf4846c..5b0ee19ba 100644 --- a/src/viam/media/audio.py +++ b/src/viam/media/audio.py @@ -16,6 +16,7 @@ class Audio: AudioReader = StreamReader[Audio] AudioStream = Stream[Audio] + class AudioCodec(str, Enum): """Common audio codec identifiers. diff --git a/src/viam/proto/common/__init__.py b/src/viam/proto/common/__init__.py index 6680cd448..f6f72fc58 100644 --- a/src/viam/proto/common/__init__.py +++ b/src/viam/proto/common/__init__.py @@ -13,6 +13,8 @@ GeometriesInFrame, Geometry, GeoPoint, + Get3DModelsRequest, + Get3DModelsResponse, GetGeometriesRequest, GetGeometriesResponse, GetKinematicsRequest, @@ -48,6 +50,8 @@ "GeoPoint", "GeometriesInFrame", "Geometry", + "Get3DModelsRequest", + "Get3DModelsResponse", "GetGeometriesRequest", "GetGeometriesResponse", "GetKinematicsRequest", diff --git a/src/viam/version_metadata.py b/src/viam/version_metadata.py index 5f577156a..e1e1c553d 100644 --- a/src/viam/version_metadata.py +++ b/src/viam/version_metadata.py @@ -1,4 +1,4 @@ __version__ = "0.58.0" -API_VERSION = "v0.1.484" +API_VERSION = "v0.1.485" SDK_VERSION = __version__ diff --git a/tests/mocks/components.py b/tests/mocks/components.py index 1e3f471ba..1fbae9b16 100644 --- a/tests/mocks/components.py +++ b/tests/mocks/components.py @@ -13,8 +13,8 @@ from google.protobuf.timestamp_pb2 import Timestamp from viam.components.arm import Arm, JointPositions, KinematicsFileFormat -from viam.components.audio_input import AudioInput from viam.components.audio_in import AudioIn, AudioResponse +from viam.components.audio_input import AudioInput from viam.components.audio_out import AudioOut from viam.components.base import Base from viam.components.board import Board, Tick @@ -35,15 +35,13 @@ from viam.errors import ResourceNotFoundError from viam.media.audio import Audio, AudioStream from viam.media.video import CameraMimeType, NamedImage, ViamImage -from viam.proto.common import Capsule, Geometry, GeoPoint, Orientation, Pose, PoseInFrame, ResponseMetadata, Sphere, Vector3 +from viam.proto.common import AudioInfo, Capsule, Geometry, GeoPoint, Orientation, Pose, PoseInFrame, ResponseMetadata, Sphere, Vector3 +from viam.proto.component.audioin import AudioChunk as Chunk from viam.proto.component.audioinput import AudioChunk, AudioChunkInfo, SampleFormat from viam.proto.component.board import PowerMode from viam.proto.component.encoder import PositionType from viam.streams import StreamWithIterator from viam.utils import SensorReading, ValueTypes -from viam.proto.common import AudioInfo -from viam.proto.component.audioin import AudioChunk as Chunk - GEOMETRIES = [ Geometry(center=Pose(x=1, y=2, z=3, o_x=2, o_y=3, o_z=4, theta=20), sphere=Sphere(radius_mm=2)), @@ -127,8 +125,16 @@ def __init__(self, name: str, properties: AudioIn.Properties): self.timeout: Optional[float] = None self.extra: Optional[Dict[str, Any]] = None - async def get_audio(self, codec: str, duration_seconds: float, previous_timestamp_ns: int, - *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs): + async def get_audio( + self, + codec: str, + duration_seconds: float, + previous_timestamp_ns: int, + *, + extra: Optional[Dict[str, Any]] = None, + timeout: Optional[float] = None, + **kwargs, + ): async def read() -> AsyncIterator[AudioResponse]: # Generate mock audio chunks for i in range(2): @@ -139,26 +145,23 @@ async def read() -> AsyncIterator[AudioResponse]: audio_chunk = Chunk( audio_data=chunk_data, audio_info=AudioInfo( - codec=codec, - sample_rate_hz=self.properties.sample_rate_hz, - num_channels=self.properties.num_channels + codec=codec, sample_rate_hz=self.properties.sample_rate_hz, num_channels=self.properties.num_channels ), sequence=i, start_timestamp_nanoseconds=timestamp_start, - end_timestamp_nanoseconds=timestamp_end + end_timestamp_nanoseconds=timestamp_end, ) - audio_response = AudioResponse( - audio=audio_chunk, - request_id="mock_request" - ) + audio_response = AudioResponse(audio=audio_chunk, request_id="mock_request") yield audio_response self.extra = extra self.timeout = timeout return StreamWithIterator(read()) - async def get_properties(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> AudioIn.Properties: + async def get_properties( + self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs + ) -> AudioIn.Properties: self.extra = extra self.timeout = timeout return self.properties @@ -171,6 +174,7 @@ async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeou async def do_command(self, command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **kwargs) -> Mapping[str, ValueTypes]: return {"command": command} + class MockAudioInput(AudioInput): def __init__(self, name: str, properties: AudioInput.Properties): super().__init__(name) @@ -205,6 +209,7 @@ async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeou async def do_command(self, command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **kwargs) -> Mapping[str, ValueTypes]: return {"command": command} + class MockAudioOut(AudioOut): def __init__(self, name: str, properties: AudioOut.Properties): super().__init__(name) @@ -216,7 +221,15 @@ def __init__(self, name: str, properties: AudioOut.Properties): self.timeout: Optional[float] = None self.extra: Optional[Dict[str, Any]] = None - async def play(self, data: bytes, info: Optional[AudioInfo] = None, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> None: + async def play( + self, + data: bytes, + info: Optional[AudioInfo] = None, + *, + extra: Optional[Dict[str, Any]] = None, + timeout: Optional[float] = None, + **kwargs, + ) -> None: self.play_called = True self.last_audio_data = data self.last_audio_info = info @@ -233,6 +246,7 @@ async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeou self.timeout = timeout return self.geometries + class MockBase(Base): def __init__(self, name: str): self.position = 0 @@ -1161,4 +1175,3 @@ async def push(self, *, extra: Optional[Mapping[str, Any]] = None, timeout: Opti async def do_command(self, command: Mapping[str, ValueTypes], *, timeout: Optional[float] = None, **kwargs) -> Mapping[str, ValueTypes]: return {"command": command} - diff --git a/tests/test_audio_in.py b/tests/test_audio_in.py index 6182b829b..af9684e6b 100644 --- a/tests/test_audio_in.py +++ b/tests/test_audio_in.py @@ -11,10 +11,7 @@ GetPropertiesRequest, GetPropertiesResponse, ) -from viam.proto.component.audioin import ( - AudioInServiceStub, - GetAudioRequest -) +from viam.proto.component.audioin import AudioInServiceStub, GetAudioRequest from viam.resource.manager import ResourceManager from viam.utils import dict_to_struct, struct_to_dict @@ -83,6 +80,7 @@ async def test_get_geometries(self, audio_in: AudioIn): geometries = await audio_in.get_geometries() assert geometries == GEOMETRIES + class TestService: async def test_get_audio(self, audio_in: AudioIn, service: AudioInRPCService): async with ChannelFor([service]) as channel: @@ -92,10 +90,7 @@ async def test_get_audio(self, audio_in: AudioIn, service: AudioInRPCService): duration_seconds = 2.0 request = GetAudioRequest( - name=audio_in.name, - codec=codec, - duration_seconds=duration_seconds, - previous_timestamp_nanoseconds=previous_timestamp + name=audio_in.name, codec=codec, duration_seconds=duration_seconds, previous_timestamp_nanoseconds=previous_timestamp ) async with client.GetAudio.open() as stream: @@ -117,9 +112,7 @@ async def test_get_properties(self, audio_in: MockAudioIn, service: AudioInRPCSe assert audio_in.timeout is None async with ChannelFor([service]) as channel: client = AudioInServiceStub(channel) - response: GetPropertiesResponse = await client.GetProperties( - GetPropertiesRequest(name=audio_in.name), timeout=1.82 - ) + response: GetPropertiesResponse = await client.GetProperties(GetPropertiesRequest(name=audio_in.name), timeout=1.82) assert response.supported_codecs == PROPERTIES.supported_codecs assert response.sample_rate_hz == PROPERTIES.sample_rate_hz assert response.num_channels == PROPERTIES.num_channels diff --git a/tests/test_audio_out.py b/tests/test_audio_out.py index a43800854..201972e4e 100644 --- a/tests/test_audio_out.py +++ b/tests/test_audio_out.py @@ -1,21 +1,20 @@ import pytest from grpclib.testing import ChannelFor -from viam.components.audio_out import AudioOutClient, AudioOutRPCService, AudioOut +from viam.components.audio_out import AudioOut, AudioOutClient, AudioOutRPCService from viam.proto.common import ( + AudioInfo, + DoCommandRequest, GetGeometriesResponse, - AudioInfo, - GetPropertiesRequest, - GetPropertiesResponse, - DoCommandRequest, + GetPropertiesRequest, + GetPropertiesResponse, ) +from viam.proto.component.audioout import AudioOutServiceStub, PlayRequest from viam.resource.manager import ResourceManager from viam.utils import dict_to_struct, struct_to_dict -from viam.proto.component.audioout import PlayRequest, AudioOutServiceStub -from . import loose_approx - -from .mocks.components import MockAudioOut, GEOMETRIES +from . import loose_approx +from .mocks.components import GEOMETRIES, MockAudioOut # Test properties for the mock AudioIn PROPERTIES = AudioOut.Properties( @@ -24,6 +23,7 @@ num_channels=2, ) + @pytest.fixture(scope="function") def audio_out() -> MockAudioOut: return MockAudioOut(name="audio_out", properties=PROPERTIES) @@ -72,10 +72,10 @@ async def test_get_geometries(self, audio_out: MockAudioOut): geometries = await audio_out.get_geometries() assert geometries == GEOMETRIES + class TestService: @pytest.mark.asyncio async def test_play(self, audio_out: MockAudioOut, service: AudioOutRPCService): - audio_data = b"test_audio_data" audio_info = AudioInfo(codec="pcm16", sample_rate_hz=44100, num_channels=2) @@ -117,9 +117,7 @@ async def test_play_without_audio_info(self, audio_out: MockAudioOut, service: A async def test_get_properties(self, audio_out: MockAudioOut, service: AudioOutRPCService): async with ChannelFor([service]) as channel: client = AudioOutServiceStub(channel) - response: GetPropertiesResponse = await client.GetProperties( - GetPropertiesRequest(name=audio_out.name), timeout=1.82 - ) + response: GetPropertiesResponse = await client.GetProperties(GetPropertiesRequest(name=audio_out.name), timeout=1.82) assert response.supported_codecs == PROPERTIES.supported_codecs assert response.sample_rate_hz == PROPERTIES.sample_rate_hz assert response.num_channels == PROPERTIES.num_channels @@ -127,7 +125,6 @@ async def test_get_properties(self, audio_out: MockAudioOut, service: AudioOutRP @pytest.mark.asyncio async def test_do_command(self, audio_out: MockAudioOut, service: AudioOutRPCService): - command = {"test": "command"} async with ChannelFor([service]) as channel: @@ -178,7 +175,7 @@ async def test_play_without_audio_info(self, audio_out: MockAudioOut, service: A assert audio_out.last_audio_info is None @pytest.mark.asyncio - async def test_get_properties(self, audio_out: MockAudioOut,service: AudioOutRPCService): + async def test_get_properties(self, audio_out: MockAudioOut, service: AudioOutRPCService): async with ChannelFor([service]) as channel: client = AudioOutClient(audio_out.name, channel) properties = await client.get_properties(timeout=4.4) @@ -190,7 +187,7 @@ async def test_get_properties(self, audio_out: MockAudioOut,service: AudioOutRPC @pytest.mark.asyncio async def test_do_command(self, audio_out: MockAudioOut, service: AudioOutRPCService): - async with ChannelFor([service]) as channel: + async with ChannelFor([service]) as channel: client = AudioOutClient(audio_out.name, channel) command = {"command": "args"} resp = await client.do_command(command)