Skip to content

Commit bd26c09

Browse files
authored
Add missing arm get_geometries method in examples (#401)
1 parent f7904fb commit bd26c09

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

docs/examples/my_cool_arm.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import asyncio
44
import json
5-
from typing import Any, Dict, Optional, Tuple
5+
from typing import Any, Dict, List, Optional, Tuple
66

77
from viam.components.arm import Arm, JointPositions, KinematicsFileFormat, Pose
88
from viam.operations import run_with_operation
9+
from viam.proto.common import Capsule, Geometry, Sphere
910

1011

1112
class MyCoolArm(Arm):
@@ -26,6 +27,10 @@ def __init__(self, name: str):
2627
# Starting joint positions
2728
self.joint_positions = JointPositions(values=[0, 0, 0, 0, 0, 0])
2829
self.is_stopped = True
30+
self.geometries = [
31+
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)),
32+
Geometry(center=Pose(x=1, y=2, z=3, o_x=2, o_y=3, o_z=4, theta=20), capsule=Capsule(radius_mm=3, length_mm=8)),
33+
]
2934

3035
# Minimal working kinematics model
3136
self.kinematics = json.dumps(
@@ -92,5 +97,8 @@ async def stop(self, extra: Optional[Dict[str, Any]] = None, **kwargs):
9297
async def is_moving(self) -> bool:
9398
return not self.is_stopped
9499

100+
async def get_geometries(self) -> List[Geometry]:
101+
return self.geometries
102+
95103
async def get_kinematics(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
96104
return KinematicsFileFormat.KINEMATICS_FILE_FORMAT_SVA, self.kinematics

examples/complex_module/src/arm/my_arm.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import asyncio
22
import os
3-
from typing import Any, ClassVar, Dict, Mapping, Optional, Tuple
3+
from typing import Any, ClassVar, Dict, List, Mapping, Optional, Tuple
4+
45
from typing_extensions import Self
56

67
from viam.components.arm import Arm, JointPositions, KinematicsFileFormat, Pose
78
from viam.operations import run_with_operation
89
from viam.proto.app.robot import ComponentConfig
9-
from viam.proto.common import ResourceName
10+
from viam.proto.common import Capsule, Geometry, ResourceName, Sphere
1011
from viam.resource.base import ResourceBase
1112
from viam.resource.types import Model, ModelFamily
1213

@@ -30,6 +31,10 @@ def __init__(self, name: str):
3031
# Starting joint positions
3132
self.joint_positions = JointPositions(values=[0, 0, 0, 0, 0, 0])
3233
self.is_stopped = True
34+
self.geometries = [
35+
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)),
36+
Geometry(center=Pose(x=1, y=2, z=3, o_x=2, o_y=3, o_z=4, theta=20), capsule=Capsule(radius_mm=3, length_mm=8)),
37+
]
3338
super().__init__(name)
3439

3540
@classmethod
@@ -90,6 +95,9 @@ async def stop(self, extra: Optional[Dict[str, Any]] = None, **kwargs):
9095
async def is_moving(self) -> bool:
9196
return not self.is_stopped
9297

98+
async def get_geometries(self) -> List[Geometry]:
99+
return self.geometries
100+
93101
async def get_kinematics(self, extra: Optional[Dict[str, Any]] = None, **kwargs) -> Tuple[KinematicsFileFormat.ValueType, bytes]:
94102
dirname = os.path.dirname(__file__)
95103
filepath = os.path.join(dirname, "./my_arm_kinematics.json")

0 commit comments

Comments
 (0)