Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/viam/app/app_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
)
from viam.proto.app import Fragment as FragmentPB
from viam.proto.app import FragmentHistoryEntry as FragmentHistoryEntryPB
from viam.proto.app import FragmentImportList
from viam.proto.app import FragmentVisibility as FragmentVisibilityPB
from viam.proto.app import RobotPart as RobotPartPB
from viam.proto.app import RobotPartHistoryEntry as RobotPartHistoryEntryPB
Expand Down Expand Up @@ -736,6 +737,7 @@ async def update_organization(
public_namespace: Optional[str] = None,
region: Optional[str] = None,
cid: Optional[str] = None,
default_fragments: Optional[FragmentImportList] = None,
) -> Organization:
"""Updates organization details.

Expand All @@ -753,6 +755,7 @@ async def update_organization(
public_namespace (Optional[str]): If provided, sets the org's namespace if it hasn't already been set.
region (Optional[str]): If provided, updates the org's region.
cid (Optional[str]): If provided, update's the org's CRM ID.
default_fragments (Optional[FragmentImportList]): If provided, updates the org's default fragments.

Raises:
GRPCError: If the org's namespace has already been set, or if the provided namespace is already taken.
Expand All @@ -768,6 +771,7 @@ async def update_organization(
region=region,
cid=cid,
name=name,
default_fragments=default_fragments,
)
response: UpdateOrganizationResponse = await self._app_client.UpdateOrganization(request, metadata=self._metadata)
return response.organization
Expand Down
39 changes: 39 additions & 0 deletions src/viam/app/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ async def tabular_data_by_filter(
count_only: bool = False,
include_internal_data: bool = False,
dest: Optional[str] = None,
mime_type: Optional[List[str]] = None,
) -> Tuple[List[TabularData], int, str]:
"""Filter and download tabular data. The data will be paginated into pages of ``limit`` items; the returned tuple will include
the pagination ID. If a destination is provided, this method saves returned data to that file, overwriting any existing file content.
Expand Down Expand Up @@ -434,6 +435,7 @@ async def tabular_data_by_filter(
include_internal_data (bool): Whether to return the internal data. Internal data is used for Viam-specific data ingestion,
like cloud SLAM. Defaults to ``False``.
dest (str): Optional filepath for writing retrieved data.
mime_type (Optional[List[str]]): Optional mime types of data to filter on (for example, ["image/png"]).

Returns:
Tuple[List[TabularData], int, str]: A tuple containing the following:
Expand All @@ -445,6 +447,23 @@ async def tabular_data_by_filter(
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#tabulardatabyfilter>`_.
"""
filter = filter if filter else Filter()
if mime_type:
filter = Filter(
component_name=filter.component_name,
component_type=filter.component_type,
method=filter.method,
robot_name=filter.robot_name,
robot_id=filter.robot_id,
part_name=filter.part_name,
part_id=filter.part_id,
location_ids=filter.location_ids,
organization_ids=filter.organization_ids,
mime_type=mime_type,
interval=filter.interval,
tags_filter=filter.tags_filter,
bbox_labels=filter.bbox_labels,
dataset_id=filter.dataset_id,
)

data_request = DataRequest(filter=filter)
if limit:
Expand Down Expand Up @@ -697,6 +716,7 @@ async def binary_data_by_filter(
count_only: bool = False,
include_internal_data: bool = False,
dest: Optional[str] = None,
mime_type: Optional[List[str]] = None,
) -> Tuple[List[BinaryData], int, str]:
"""Filter and download binary data. The data will be paginated into pages of ``limit`` items, and the pagination ID will be included
in the returned tuple as ``last``. If a destination is provided, this method saves returned data to that file,
Expand Down Expand Up @@ -751,6 +771,7 @@ async def binary_data_by_filter(
include_internal_data (bool): Whether to return the internal data. Internal data is used for Viam-specific data ingestion,
like cloud SLAM. Defaults to ``False``.
dest (str): Optional filepath for writing retrieved data.
mime_type (Optional[List[str]]): Optional mime types of data to filter on (for example, ["image/png"]).

Returns:
Tuple[List[~viam.proto.app.data.BinaryData], int, str]: A tuple containing the following:
Expand All @@ -761,6 +782,24 @@ async def binary_data_by_filter(

For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#binarydatabyfilter>`_.
"""
filter = filter if filter else Filter()
if mime_type:
filter = Filter(
component_name=filter.component_name,
component_type=filter.component_type,
method=filter.method,
robot_name=filter.robot_name,
robot_id=filter.robot_id,
part_name=filter.part_name,
part_id=filter.part_id,
location_ids=filter.location_ids,
organization_ids=filter.organization_ids,
mime_type=mime_type,
interval=filter.interval,
tags_filter=filter.tags_filter,
bbox_labels=filter.bbox_labels,
dataset_id=filter.dataset_id,
)

data_request = DataRequest(filter=filter)
if limit:
Expand Down
3 changes: 2 additions & 1 deletion src/viam/components/arm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from viam.proto.common import KinematicsFileFormat, Pose
from viam.proto.common import KinematicsFileFormat, Mesh, Pose
from viam.proto.component.arm import JointPositions
from viam.resource.registry import Registry, ResourceRegistration

Expand All @@ -10,6 +10,7 @@
"Arm",
"JointPositions",
"KinematicsFileFormat",
"Mesh",
"Pose",
]

Expand Down
16 changes: 10 additions & 6 deletions src/viam/components/arm/arm.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import abc
from typing import Any, Dict, Final, Optional, Tuple
from typing import Any, Dict, Final, Mapping, Optional, Tuple

from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_COMPONENT

from ..component_base import ComponentBase
from . import JointPositions, KinematicsFileFormat, Pose
from . import JointPositions, KinematicsFileFormat, Mesh, Pose


class Arm(ComponentBase):
Expand Down Expand Up @@ -195,7 +195,7 @@ async def is_moving(self) -> bool:
@abc.abstractmethod
async def get_kinematics(
self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs
) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
) -> Tuple[KinematicsFileFormat.ValueType, bytes, Mapping[str, Mesh]]:
"""
Get the kinematics information associated with the arm.

Expand All @@ -212,11 +212,15 @@ async def get_kinematics(
# Get the byte contents of the file.
k_bytes = kinematics[1]

# Get the meshes by URDF filepath.
meshes = kinematics[2]

Returns:
Tuple[KinematicsFileFormat.ValueType, bytes]: A tuple containing two values; the first [0] value represents the format of the
file, either in URDF format (``KinematicsFileFormat.KINEMATICS_FILE_FORMAT_URDF``) or
Tuple[KinematicsFileFormat.ValueType, bytes, Mapping[str, Mesh]]: A tuple containing three values; the first [0] value
represents the format of the file, either in URDF format (``KinematicsFileFormat.KINEMATICS_FILE_FORMAT_URDF``) or
Viam's kinematic parameter format (spatial vector algebra) (``KinematicsFileFormat.KINEMATICS_FILE_FORMAT_SVA``),
and the second [1] value represents the byte contents of the file.
the second [1] value represents the byte contents of the file, and the third [2] value is a mapping of URDF filepaths
to their corresponding meshes.

For more information, see `Arm component <https://docs.viam.com/dev/reference/apis/components/arm/#getkinematics>`_.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/viam/components/arm/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase
from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict

from . import Arm, KinematicsFileFormat, Pose
from . import Arm, KinematicsFileFormat, Mesh, Pose


class ArmClient(Arm, ReconfigurableResourceRPCClientBase):
Expand Down Expand Up @@ -113,11 +113,11 @@ async def do_command(

async def get_kinematics(
self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs
) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
) -> Tuple[KinematicsFileFormat.ValueType, bytes, Mapping[str, Mesh]]:
md = kwargs.get("metadata", self.Metadata()).proto
request = GetKinematicsRequest(name=self.name, extra=dict_to_struct(extra))
response: GetKinematicsResponse = await self.client.GetKinematics(request, timeout=timeout, metadata=md)
return (response.format, response.kinematics_data)
return (response.format, response.kinematics_data, dict(response.meshes_by_urdf_filepath))

async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> List[Geometry]:
md = kwargs.get("metadata", self.Metadata())
Expand Down
6 changes: 4 additions & 2 deletions src/viam/components/arm/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ async def GetKinematics(self, stream: Stream[GetKinematicsRequest, GetKinematics
assert request is not None
arm = self.get_resource(request.name)
timeout = stream.deadline.time_remaining() if stream.deadline else None
format, kinematics_data = await arm.get_kinematics(extra=struct_to_dict(request.extra), timeout=timeout, metadata=stream.metadata)
response = GetKinematicsResponse(format=format, kinematics_data=kinematics_data)
format, kinematics_data, meshes_by_urdf_filepath = await arm.get_kinematics(
extra=struct_to_dict(request.extra), timeout=timeout, metadata=stream.metadata
)
response = GetKinematicsResponse(format=format, kinematics_data=kinematics_data, meshes_by_urdf_filepath=meshes_by_urdf_filepath)
await stream.send_message(response)

async def GetGeometries(self, stream: Stream[GetGeometriesRequest, GetGeometriesResponse]) -> None:
Expand Down
74 changes: 0 additions & 74 deletions src/viam/components/audio_in/audio_in.py

This file was deleted.

76 changes: 0 additions & 76 deletions src/viam/components/audio_in/client.py

This file was deleted.

Loading
Loading