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
3 changes: 2 additions & 1 deletion src/viam/components/arm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from viam.proto.component.arm import JointPositions, MoveOptions
from viam.resource.registry import Registry, ResourceRegistration

from .arm import Arm
from .arm import Arm, ArmProperties
from .client import ArmClient
from .service import ArmRPCService

__all__ = [
"Arm",
"ArmProperties",
"JointPositions",
"KinematicsFileFormat",
"KinematicsReturn",
Expand Down
96 changes: 96 additions & 0 deletions src/viam/components/arm/arm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import abc
from dataclasses import dataclass
from typing import Any, Dict, Final, List, Mapping, Optional

from viam.components import KinematicsReturn
Expand All @@ -8,6 +9,17 @@
from . import JointPositions, Mesh, MoveOptions, Pose


@dataclass
class ArmProperties:
"""Properties of an arm component."""

support_manual_mode: bool
"""True if the arm supports software-enabled manual mode."""

support_cartesian_commands: bool
"""True if the arm supports direct cartesian commands (MoveToPosition is implemented)."""


class Arm(ComponentBase):
"""
Arm represents a physical robot arm that exists in three-dimensional space.
Expand Down Expand Up @@ -315,3 +327,87 @@ async def get_3d_models(
For more information, see `Arm component <https://docs.viam.com/dev/reference/apis/components/arm/#get3dmodels>`_.
"""
...

@abc.abstractmethod
async def set_manual_mode(
self,
manual_mode: bool,
enabled_for: int = 0,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
):
"""
Enable or disable manual mode on the arm.

::

my_arm = Arm.from_robot(robot=machine, name="my_arm")

# Enter manual mode for 60 seconds.
await my_arm.set_manual_mode(True, enabled_for=60)

# Exit manual mode.
await my_arm.set_manual_mode(False)

Args:
manual_mode (bool): True to enter manual mode, False to exit it.
enabled_for (int): How long to stay in manual mode, in seconds. 0 means no time limit.

For more information, see `Arm component <https://docs.viam.com/dev/reference/apis/components/arm/#setmanualmode>`_.
"""
...

@abc.abstractmethod
async def get_manual_mode(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
) -> bool:
"""
Get whether the arm is currently in manual mode.

::

my_arm = Arm.from_robot(robot=machine, name="my_arm")

# Check if the arm is in manual mode.
is_manual = await my_arm.get_manual_mode()

Returns:
bool: True if the arm is in manual mode.

For more information, see `Arm component <https://docs.viam.com/dev/reference/apis/components/arm/#getmanualmode>`_.
"""
...

@abc.abstractmethod
async def get_properties(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
) -> "ArmProperties":
"""
Get the properties of the arm.

::

my_arm = Arm.from_robot(robot=machine, name="my_arm")

# Get the arm's properties.
properties = await my_arm.get_properties()
print(f"Supports manual mode: {properties.support_manual_mode}")
print(f"Supports cartesian commands: {properties.support_cartesian_commands}")

Returns:
ArmProperties: The arm's properties, including whether it supports manual mode
and cartesian commands.

For more information, see `Arm component <https://docs.viam.com/dev/reference/apis/components/arm/#getproperties>`_.
"""
...
46 changes: 46 additions & 0 deletions src/viam/components/arm/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@
GetEndPositionResponse,
GetJointPositionsRequest,
GetJointPositionsResponse,
GetManualModeRequest,
GetManualModeResponse,
GetPropertiesRequest,
GetPropertiesResponse,
IsMovingRequest,
IsMovingResponse,
JointPositions,
MoveOptions,
MoveThroughJointPositionsRequest,
MoveToJointPositionsRequest,
MoveToPositionRequest,
SetManualModeRequest,
StopRequest,
)
from viam.resource.rpc_client_base import ReconfigurableResourceRPCClientBase
from viam.utils import ValueTypes, dict_to_struct, get_geometries, struct_to_dict

from . import Arm, Pose
from .arm import ArmProperties


class ArmClient(Arm, ReconfigurableResourceRPCClientBase):
Expand Down Expand Up @@ -173,3 +179,43 @@ async def get_3d_models(
async def get_geometries(self, *, extra: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, **kwargs) -> List[Geometry]:
md = kwargs.get("metadata", self.Metadata())
return await get_geometries(self.client, self.name, extra, timeout, md)

async def set_manual_mode(
self,
manual_mode: bool,
enabled_for: int = 0,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
):
md = kwargs.get("metadata", self.Metadata()).proto
request = SetManualModeRequest(name=self.name, manual_mode=manual_mode, enabled_for=enabled_for, extra=dict_to_struct(extra))
await self.client.SetManualMode(request, timeout=timeout, metadata=md)

async def get_manual_mode(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
) -> bool:
md = kwargs.get("metadata", self.Metadata()).proto
request = GetManualModeRequest(name=self.name, extra=dict_to_struct(extra))
response: GetManualModeResponse = await self.client.GetManualMode(request, timeout=timeout, metadata=md)
return response.manual_mode

async def get_properties(
self,
*,
extra: Optional[Dict[str, Any]] = None,
timeout: Optional[float] = None,
**kwargs,
) -> ArmProperties:
md = kwargs.get("metadata", self.Metadata()).proto
request = GetPropertiesRequest(name=self.name, extra=dict_to_struct(extra))
response: GetPropertiesResponse = await self.client.GetProperties(request, timeout=timeout, metadata=md)
return ArmProperties(
support_manual_mode=response.support_manual_mode,
support_cartesian_commands=response.support_cartesian_commands,
)
42 changes: 42 additions & 0 deletions src/viam/components/arm/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
GetEndPositionResponse,
GetJointPositionsRequest,
GetJointPositionsResponse,
GetManualModeRequest,
GetManualModeResponse,
GetPropertiesRequest,
GetPropertiesResponse,
IsMovingRequest,
IsMovingResponse,
MoveThroughJointPositionsRequest,
Expand All @@ -25,6 +29,8 @@
MoveToJointPositionsResponse,
MoveToPositionRequest,
MoveToPositionResponse,
SetManualModeRequest,
SetManualModeResponse,
StopRequest,
StopResponse,
UnimplementedArmServiceBase,
Expand Down Expand Up @@ -169,3 +175,39 @@ async def GetGeometries(self, stream: Stream[GetGeometriesRequest, GetGeometries
geometries = await arm.get_geometries(extra=struct_to_dict(request.extra), timeout=timeout)
response = GetGeometriesResponse(geometries=geometries)
await stream.send_message(response)

async def SetManualMode(self, stream: Stream[SetManualModeRequest, SetManualModeResponse]) -> None:
request = await stream.recv_message()
assert request is not None
arm = self.get_resource(request.name)
timeout = stream.deadline.time_remaining() if stream.deadline else None
await arm.set_manual_mode(
request.manual_mode,
request.enabled_for,
extra=struct_to_dict(request.extra),
timeout=timeout,
metadata=stream.metadata,
)
response = SetManualModeResponse()
await stream.send_message(response)

async def GetManualMode(self, stream: Stream[GetManualModeRequest, GetManualModeResponse]) -> None:
request = await stream.recv_message()
assert request is not None
arm = self.get_resource(request.name)
timeout = stream.deadline.time_remaining() if stream.deadline else None
manual_mode = await arm.get_manual_mode(extra=struct_to_dict(request.extra), timeout=timeout, metadata=stream.metadata)
response = GetManualModeResponse(manual_mode=manual_mode)
await stream.send_message(response)

async def GetProperties(self, stream: Stream[GetPropertiesRequest, GetPropertiesResponse]) -> None:
request = await stream.recv_message()
assert request is not None
arm = self.get_resource(request.name)
timeout = stream.deadline.time_remaining() if stream.deadline else None
properties = await arm.get_properties(extra=struct_to_dict(request.extra), timeout=timeout, metadata=stream.metadata)
response = GetPropertiesResponse(
support_manual_mode=properties.support_manual_mode,
support_cartesian_commands=properties.support_cartesian_commands,
)
await stream.send_message(response)
34 changes: 18 additions & 16 deletions src/viam/gen/app/mltraining/v1/ml_training_pb2.py

Large diffs are not rendered by default.

52 changes: 48 additions & 4 deletions src/viam/gen/app/mltraining/v1/ml_training_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ TRAINING_STATUS_CANCELED: TrainingStatus.ValueType
TRAINING_STATUS_CANCELING: TrainingStatus.ValueType
Global___TrainingStatus: _TypeAlias = TrainingStatus

class _Visibility:
ValueType = _typing.NewType('ValueType', _builtins.int)
V: _TypeAlias = ValueType

class _VisibilityEnumTypeWrapper(_enum_type_wrapper._EnumTypeWrapper[_Visibility.ValueType], _builtins.type):
DESCRIPTOR: _descriptor.EnumDescriptor
VISIBILITY_UNSPECIFIED: _Visibility.ValueType
VISIBILITY_PRIVATE: _Visibility.ValueType
VISIBILITY_PUBLIC: _Visibility.ValueType

class Visibility(_Visibility, metaclass=_VisibilityEnumTypeWrapper):
...
VISIBILITY_UNSPECIFIED: Visibility.ValueType
VISIBILITY_PRIVATE: Visibility.ValueType
VISIBILITY_PUBLIC: Visibility.ValueType
Global___Visibility: _TypeAlias = Visibility

@_typing.final
class SubmitTrainingJobRequest(_message.Message):
DESCRIPTOR: _descriptor.Descriptor
Expand Down Expand Up @@ -462,8 +479,15 @@ Global___GetTrainingJobLogsResponse: _TypeAlias = GetTrainingJobLogsResponse
@_typing.final
class ListSupportedContainersRequest(_message.Message):
DESCRIPTOR: _descriptor.Descriptor
ORGANIZATION_ID_FIELD_NUMBER: _builtins.int
organization_id: _builtins.str
"Optional. Scopes the response to the containers available to this\n organization: the Viam-managed catalog plus the org's registered\n custom training containers. If unset, only the Viam-managed catalog\n is returned.\n "

def __init__(self) -> None:
def __init__(self, *, organization_id: _builtins.str=...) -> None:
...
_ClearFieldArgType: _TypeAlias = _typing.Literal['organization_id', b'organization_id']

def ClearField(self, field_name: _ClearFieldArgType) -> None:
...
Global___ListSupportedContainersRequest: _TypeAlias = ListSupportedContainersRequest

Expand Down Expand Up @@ -501,8 +525,12 @@ class ListSupportedContainersResponse(_message.Message):
"tf:2.15": Container {
key: "tf:2.15"
uri: "us-docker.pkg.dev/vertex-ai/training/tf-gpu.2-15.py310:latest"
framework: Tensorflow
description: "Tensorflow 2.15"
eol: { seconds: 1772630400, nanos: 0 } // 2026-03-03T00:00:00Z
created_on: 2026-01-15T01:30:15.01Z
organization_id: "xyz"
visibility: VISIBILITY_PUBLIC
}
}
"""
Expand All @@ -523,22 +551,38 @@ class Container(_message.Message):
FRAMEWORK_FIELD_NUMBER: _builtins.int
DESCRIPTION_FIELD_NUMBER: _builtins.int
EOL_FIELD_NUMBER: _builtins.int
ORGANIZATION_ID_FIELD_NUMBER: _builtins.int
CREATED_ON_FIELD_NUMBER: _builtins.int
ID_FIELD_NUMBER: _builtins.int
VISIBILITY_FIELD_NUMBER: _builtins.int
key: _builtins.str
'custom container keys are derived from the Docker URI (image:tag)'
uri: _builtins.str
framework: _builtins.str
'unset for custom containers'
description: _builtins.str
'will serve as display name'
organization_id: _builtins.str
id: _builtins.str
'unique id of the container'
visibility: Global___Visibility.ValueType
'public or private'

@_builtins.property
def eol(self) -> _timestamp_pb2.Timestamp:
"""unset for custom containers"""

@_builtins.property
def created_on(self) -> _timestamp_pb2.Timestamp:
...

def __init__(self, *, key: _builtins.str=..., uri: _builtins.str=..., framework: _builtins.str=..., description: _builtins.str=..., eol: _timestamp_pb2.Timestamp | None=...) -> None:
def __init__(self, *, key: _builtins.str=..., uri: _builtins.str=..., framework: _builtins.str=..., description: _builtins.str=..., eol: _timestamp_pb2.Timestamp | None=..., organization_id: _builtins.str=..., created_on: _timestamp_pb2.Timestamp | None=..., id: _builtins.str=..., visibility: Global___Visibility.ValueType=...) -> None:
...
_HasFieldArgType: _TypeAlias = _typing.Literal['eol', b'eol']
_HasFieldArgType: _TypeAlias = _typing.Literal['created_on', b'created_on', 'eol', b'eol']

def HasField(self, field_name: _HasFieldArgType) -> _builtins.bool:
...
_ClearFieldArgType: _TypeAlias = _typing.Literal['description', b'description', 'eol', b'eol', 'framework', b'framework', 'key', b'key', 'uri', b'uri']
_ClearFieldArgType: _TypeAlias = _typing.Literal['created_on', b'created_on', 'description', b'description', 'eol', b'eol', 'framework', b'framework', 'id', b'id', 'key', b'key', 'organization_id', b'organization_id', 'uri', b'uri', 'visibility', b'visibility']

def ClearField(self, field_name: _ClearFieldArgType) -> None:
...
Expand Down
Loading
Loading