7
7
else :
8
8
from typing_extensions import TypeAlias
9
9
10
- from viam .proto .common import GeoGeometry , Geometry , GeoPoint , Pose , PoseInFrame , ResourceName , Transform , WorldState
10
+ from viam .proto .common import GeoGeometry , Geometry , GeoPoint , Pose , PoseInFrame , Transform , WorldState
11
11
from viam .proto .service .motion import Constraints , GetPlanResponse , MotionConfiguration , PlanStatusWithID
12
12
from viam .resource .types import API , RESOURCE_NAMESPACE_RDK , RESOURCE_TYPE_SERVICE
13
13
from viam .utils import ValueTypes
@@ -33,7 +33,7 @@ class Motion(ServiceBase):
33
33
@abc .abstractmethod
34
34
async def move (
35
35
self ,
36
- component_name : ResourceName ,
36
+ component_name : str ,
37
37
destination : PoseInFrame ,
38
38
world_state : Optional [WorldState ] = None ,
39
39
constraints : Optional [Constraints ] = None ,
@@ -44,18 +44,17 @@ async def move(
44
44
"""Plan and execute a movement to move the component specified to its goal destination.
45
45
46
46
Note: Frames designated with respect to components can also be used as the ``component_name`` when calling for a move. This
47
- technique allows for planning and moving the frame itself to the ``destination``. To do so, simply create a resource name with
48
- originating ReferenceFrame's name. Then pass in the resource name into ``component_name``. Ex::
47
+ technique allows for planning and moving the frame itself to the ``destination``.
48
+ To do so, simply pass in a string into ``component_name``. Ex::
49
49
50
- resource_name = Gripper.get_resource_name("externalFrame")
51
- success = await MotionServiceClient.move(resource_name, ...)
50
+ success = await MotionServiceClient.move("externalFrame", ...)
52
51
53
52
::
54
53
55
54
motion = MotionClient.from_robot(robot=machine, name="builtin")
56
55
57
- # Assumes a gripper configured with name "my_gripper" on the machine
58
- gripper_name = Gripper.get_resource_name( "my_gripper")
56
+ # Assumes "my_gripper" on the machine
57
+ gripper_name = "my_gripper"
59
58
my_frame = "my_gripper_offset"
60
59
61
60
goal_pose = Pose(x=0, y=0, z=300, o_x=0, o_y=0, o_z=1, theta=0)
@@ -69,7 +68,7 @@ async def move(
69
68
extra={})
70
69
71
70
Args:
72
- component_name (viam.proto.common.ResourceName ): Name of a component on a given robot.
71
+ component_name (str ): Name of a component on a given robot.
73
72
destination (viam.proto.common.PoseInFrame): The destination to move to, expressed as a ``Pose`` and the frame in which it was
74
73
observed.
75
74
world_state (viam.proto.common.WorldState): When supplied, the motion service will create a plan that obeys any constraints
@@ -95,9 +94,9 @@ async def move(
95
94
@abc .abstractmethod
96
95
async def move_on_globe (
97
96
self ,
98
- component_name : ResourceName ,
97
+ component_name : str ,
99
98
destination : GeoPoint ,
100
- movement_sensor_name : ResourceName ,
99
+ movement_sensor_name : str ,
101
100
obstacles : Optional [Sequence [GeoGeometry ]] = None ,
102
101
heading : Optional [float ] = None ,
103
102
configuration : Optional [MotionConfiguration ] = None ,
@@ -120,24 +119,23 @@ async def move_on_globe(
120
119
121
120
motion = MotionClient.from_robot(robot=machine, name="builtin")
122
121
123
- # Get the ResourceNames of the base and movement sensor
124
- my_base_resource_name = Base.get_resource_name("my_base")
125
- mvmnt_sensor_resource_name = MovementSensor.get_resource_name(
126
- "my_movement_sensor")
122
+ # Get the names of the base and movement sensor
123
+ my_base_name = "my_base"
124
+ mvmnt_sensor_name = "my_movement_sensor"
127
125
# Define a destination GeoPoint at the GPS coordinates [0, 0]
128
126
my_destination = movement_sensor.GeoPoint(latitude=0, longitude=0)
129
127
130
128
# Move the base component to the designated geographic location, as reported by the movement sensor
131
129
execution_id = await motion.move_on_globe(
132
- component_name=my_base_resource_name ,
130
+ component_name=my_base_name ,
133
131
destination=my_destination,
134
- movement_sensor_name=mvmnt_sensor_resource_name )
132
+ movement_sensor_name=mvmnt_sensor_name )
135
133
136
134
Args:
137
- component_name (ResourceName ): The ResourceName of the base to move.
135
+ component_name (str ): The name of the base to move.
138
136
destination (GeoPoint): The location of the component's destination, represented in geographic notation as a
139
137
GeoPoint (lat, lng).
140
- movement_sensor_name (ResourceName ): The ResourceName of the movement sensor that you want to use to check
138
+ movement_sensor_name (str ): The name of the movement sensor that you want to use to check
141
139
the machine's location.
142
140
obstacles (Optional[Sequence[GeoGeometry]]): Obstacles to consider when planning the motion of the component,
143
141
with each represented as a GeoGeometry. Default: None
@@ -170,9 +168,9 @@ async def move_on_globe(
170
168
@abc .abstractmethod
171
169
async def move_on_map (
172
170
self ,
173
- component_name : ResourceName ,
171
+ component_name : str ,
174
172
destination : Pose ,
175
- slam_service_name : ResourceName ,
173
+ slam_service_name : str ,
176
174
configuration : Optional [MotionConfiguration ] = None ,
177
175
obstacles : Optional [Sequence [Geometry ]] = None ,
178
176
* ,
@@ -194,23 +192,23 @@ async def move_on_map(
194
192
195
193
motion = MotionClient.from_robot(robot=machine, name="builtin")
196
194
197
- # Get the ResourceNames of the base component and SLAM service
198
- my_base_resource_name = Base.get_resource_name( "my_base")
199
- my_slam_service_name = SLAMClient.get_resource_name( "my_slam_service")
195
+ # Get the names of the base component and SLAM service
196
+ my_base_name = "my_base"
197
+ my_slam_service_name = "my_slam_service"
200
198
201
199
# Define a destination pose with respect to the origin of the map from the SLAM service "my_slam_service"
202
200
my_pose = Pose(y=10)
203
201
204
202
# Move the base component to the destination pose of Y=10, a location of
205
203
# (0, 10, 0) in respect to the origin of the map
206
- execution_id = await motion.move_on_map(component_name=my_base_resource_name ,
204
+ execution_id = await motion.move_on_map(component_name=my_base_name ,
207
205
destination=my_pose,
208
206
slam_service_name=my_slam_service_name)
209
207
210
208
Args:
211
- component_name (ResourceName ): The ResourceName of the base to move.
209
+ component_name (str ): The name of the base to move.
212
210
destination (Pose): The destination, which can be any Pose with respect to the SLAM map's origin.
213
- slam_service_name (ResourceName ): The ResourceName of the SLAM service from which the SLAM map is requested.
211
+ slam_service_name (str ): The name of the SLAM service from which the SLAM map is requested.
214
212
configuration (Optional[MotionConfiguration]): The configuration you want to set across this machine for this motion service.
215
213
This parameter and each of its fields are optional.
216
214
@@ -237,7 +235,7 @@ async def move_on_map(
237
235
@abc .abstractmethod
238
236
async def stop_plan (
239
237
self ,
240
- component_name : ResourceName ,
238
+ component_name : str ,
241
239
* ,
242
240
extra : Optional [Mapping [str , ValueTypes ]] = None ,
243
241
timeout : Optional [float ] = None ,
@@ -251,11 +249,11 @@ async def stop_plan(
251
249
# Assuming a `move_on_globe()` started the execution
252
250
# Stop the base component which was instructed to move by `move_on_globe()`
253
251
# or `move_on_map()`
254
- my_base_resource_name = Base.get_resource_name( "my_base")
252
+ my_base_name = "my_base"
255
253
await motion.stop_plan(component_name=mvmnt_sensor)
256
254
257
255
Args:
258
- component_name (ResourceName ): The component to stop
256
+ component_name (str ): The component to stop
259
257
260
258
For more information, see `Motion service <https://docs.viam.com/dev/reference/apis/services/motion/#stopplan>`_.
261
259
"""
@@ -264,7 +262,7 @@ async def stop_plan(
264
262
@abc .abstractmethod
265
263
async def get_plan (
266
264
self ,
267
- component_name : ResourceName ,
265
+ component_name : str ,
268
266
last_plan_only : bool = False ,
269
267
execution_id : Optional [str ] = None ,
270
268
* ,
@@ -291,12 +289,12 @@ async def get_plan(
291
289
::
292
290
293
291
motion = MotionClient.from_robot(robot=machine, name="builtin")
294
- my_base_resource_name = Base.get_resource_name( "my_base")
292
+ my_base_name = "my_base"
295
293
# Get the plan(s) of the base component which was instructed to move by `MoveOnGlobe()` or `MoveOnMap()`
296
- resp = await motion.get_plan(component_name=my_base_resource_name )
294
+ resp = await motion.get_plan(component_name=my_base_name )
297
295
298
296
Args:
299
- component_name (ResourceName ): The component to stop
297
+ component_name (str ): The component to stop
300
298
last_plan_only (Optional[bool]): If supplied, the response will only return the last plan for the component / execution.
301
299
execution_id (Optional[str]): If supplied, the response will only return plans with the provided execution_id.
302
300
@@ -343,7 +341,7 @@ async def list_plan_statuses(
343
341
@abc .abstractmethod
344
342
async def get_pose (
345
343
self ,
346
- component_name : ResourceName ,
344
+ component_name : str ,
347
345
destination_frame : str ,
348
346
supplemental_transforms : Optional [Sequence [Transform ]] = None ,
349
347
* ,
@@ -359,7 +357,7 @@ async def get_pose(
359
357
# (``Arm``, ``Base``, etc).
360
358
361
359
# Create a `component_name`:
362
- component_name = Gripper.get_resource_name( "my_gripper")
360
+ component_name = "my_gripper"
363
361
364
362
from viam.components.gripper import Gripper
365
363
from viam.services.motion import MotionClient
@@ -368,12 +366,12 @@ async def get_pose(
368
366
robot = await connect()
369
367
370
368
motion = MotionClient.from_robot(robot=machine, name="builtin")
371
- gripperName = Gripper.get_resource_name( "my_gripper")
369
+ gripperName = "my_gripper"
372
370
gripperPoseInWorld = await motion.get_pose(component_name=gripperName,
373
371
destination_frame="world")
374
372
375
373
Args:
376
- component_name (viam.proto.common.ResourceName ): Name of a component on a robot.
374
+ component_name (str ): Name of a component on a robot.
377
375
destination_frame (str): Name of the desired reference frame.
378
376
supplemental_transforms (Optional[List[viam.proto.common.Transform]]): Transforms used to augment the robot's frame while
379
377
calculating pose.
0 commit comments