From 6a7f66b57cd524eaa881e3eda2e976101ce1ab48 Mon Sep 17 00:00:00 2001 From: viambot <79611529+viambot@users.noreply.github.com> Date: Tue, 26 Aug 2025 21:57:17 +0000 Subject: [PATCH 1/3] [WORKFLOW] AI update based on proto changes from commit db4294199adfeb2144d952b597121aa94ae1bcf1 --- src/viam/services/motion/client.py | 1 + src/viam/services/motion/motion.py | 12 ++++++++++-- src/viam/services/motion/service.py | 1 + tests/mocks/services.py | 1 + tests/test_motion_service.py | 4 ++-- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/viam/services/motion/client.py b/src/viam/services/motion/client.py index 8ed4ce6ad..22a15eac9 100644 --- a/src/viam/services/motion/client.py +++ b/src/viam/services/motion/client.py @@ -31,6 +31,7 @@ MoveRequest, MoveResponse, PlanStatusWithID, + PseudolinearConstraint, StopPlanRequest, StopPlanResponse, ) diff --git a/src/viam/services/motion/motion.py b/src/viam/services/motion/motion.py index c6b6138c4..c82d74696 100644 --- a/src/viam/services/motion/motion.py +++ b/src/viam/services/motion/motion.py @@ -8,7 +8,7 @@ from typing_extensions import TypeAlias from viam.proto.common import GeoGeometry, Geometry, GeoPoint, Pose, PoseInFrame, ResourceName, Transform, WorldState -from viam.proto.service.motion import Constraints, GetPlanResponse, MotionConfiguration, PlanStatusWithID +from viam.proto.service.motion import Constraints, GetPlanResponse, MotionConfiguration, PlanStatusWithID, PseudolinearConstraint from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE from viam.utils import ValueTypes @@ -75,7 +75,15 @@ async def move( world_state (viam.proto.common.WorldState): When supplied, the motion service will create a plan that obeys any constraints expressed in the WorldState message. constraints (viam.proto.service.motion.Constraints): When supplied, the motion service will create a plan that obeys any - specified constraints. + specified constraints. These can include: + - LinearConstraint: Specifies that the component being moved should move linearly relative to its goal. + - OrientationConstraint: Specifies that the component being moved will not deviate its orientation beyond some threshold + relative to the goal. + - CollisionSpecification: Used to selectively apply obstacle avoidance to specific parts of the robot. + - PseudolinearConstraint: Specifies that the component being moved should not deviate from the straight-line path to their + goal by more than a factor proportional to the distance from start to goal. For example, if a component is moving 100mm, + then a LineToleranceFactor of 1.0 means that the component will remain within a 100mm radius of the straight-line + start-goal path. Returns: bool: Whether the move was successful. diff --git a/src/viam/services/motion/service.py b/src/viam/services/motion/service.py index bcc71d19c..91f6bf5d3 100644 --- a/src/viam/services/motion/service.py +++ b/src/viam/services/motion/service.py @@ -14,6 +14,7 @@ MoveOnMapResponse, MoveRequest, MoveResponse, + PseudolinearConstraint, StopPlanRequest, StopPlanResponse, UnimplementedMotionServiceBase, diff --git a/tests/mocks/services.py b/tests/mocks/services.py index 8950077d4..7072a1060 100644 --- a/tests/mocks/services.py +++ b/tests/mocks/services.py @@ -359,6 +359,7 @@ MoveOnMapResponse, MoveRequest, MoveResponse, + PseudolinearConstraint, StopPlanRequest, StopPlanResponse, ) diff --git a/tests/test_motion_service.py b/tests/test_motion_service.py index 4808ea601..446c7b2a4 100644 --- a/tests/test_motion_service.py +++ b/tests/test_motion_service.py @@ -21,7 +21,7 @@ PlanWithStatus, ) from viam.proto.common import GeoGeometry, Geometry, GeoPoint, Pose, PoseInFrame, ResourceName, Transform, WorldState -from viam.proto.service.motion import Constraints, LinearConstraint, MotionConfiguration +from viam.proto.service.motion import Constraints, LinearConstraint, MotionConfiguration, PseudolinearConstraint from viam.resource.manager import ResourceManager from viam.services.motion import MotionClient from viam.services.motion.motion import Motion @@ -125,7 +125,7 @@ async def test_move(self, motion: Motion, service: MotionRPCService): resource_name = Arm.get_resource_name("arm") destination = PoseInFrame(reference_frame="refframe") world_state = WorldState(transforms=[Transform(reference_frame="ws_tfrm_rf")]) - constraints = Constraints(linear_constraint=[LinearConstraint(), LinearConstraint(line_tolerance_mm=2)]) + constraints = Constraints(linear_constraint=[LinearConstraint(), LinearConstraint(line_tolerance_mm=2)], pseudolinear_constraint=[PseudolinearConstraint(line_tolerance_factor=1.0, orientation_tolerance_factor=0.5)]) extra = {"foo": "bar"} timeout = 2 success = await client.move( From 6ceb8a9683d341946d11f6507c7e151072613318 Mon Sep 17 00:00:00 2001 From: Naveed Jooma Date: Wed, 27 Aug 2025 11:51:50 -0400 Subject: [PATCH 2/3] Fix unused imports --- Makefile | 2 +- src/viam/services/motion/client.py | 1 - src/viam/services/motion/motion.py | 2 +- src/viam/services/motion/service.py | 1 - tests/mocks/services.py | 1 - tests/test_motion_service.py | 5 ++++- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ac73a6232..180b96d0c 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ lint: .PHONY: format format: ruff format ./src ./tests - ruff check --select I --fix ./src ./tests + ruff check --extend-select I --fix ./src ./tests .PHONY: buf buf: clean diff --git a/src/viam/services/motion/client.py b/src/viam/services/motion/client.py index 22a15eac9..8ed4ce6ad 100644 --- a/src/viam/services/motion/client.py +++ b/src/viam/services/motion/client.py @@ -31,7 +31,6 @@ MoveRequest, MoveResponse, PlanStatusWithID, - PseudolinearConstraint, StopPlanRequest, StopPlanResponse, ) diff --git a/src/viam/services/motion/motion.py b/src/viam/services/motion/motion.py index c82d74696..694e03ea8 100644 --- a/src/viam/services/motion/motion.py +++ b/src/viam/services/motion/motion.py @@ -8,7 +8,7 @@ from typing_extensions import TypeAlias from viam.proto.common import GeoGeometry, Geometry, GeoPoint, Pose, PoseInFrame, ResourceName, Transform, WorldState -from viam.proto.service.motion import Constraints, GetPlanResponse, MotionConfiguration, PlanStatusWithID, PseudolinearConstraint +from viam.proto.service.motion import Constraints, GetPlanResponse, MotionConfiguration, PlanStatusWithID from viam.resource.types import API, RESOURCE_NAMESPACE_RDK, RESOURCE_TYPE_SERVICE from viam.utils import ValueTypes diff --git a/src/viam/services/motion/service.py b/src/viam/services/motion/service.py index 91f6bf5d3..bcc71d19c 100644 --- a/src/viam/services/motion/service.py +++ b/src/viam/services/motion/service.py @@ -14,7 +14,6 @@ MoveOnMapResponse, MoveRequest, MoveResponse, - PseudolinearConstraint, StopPlanRequest, StopPlanResponse, UnimplementedMotionServiceBase, diff --git a/tests/mocks/services.py b/tests/mocks/services.py index 7072a1060..8950077d4 100644 --- a/tests/mocks/services.py +++ b/tests/mocks/services.py @@ -359,7 +359,6 @@ MoveOnMapResponse, MoveRequest, MoveResponse, - PseudolinearConstraint, StopPlanRequest, StopPlanResponse, ) diff --git a/tests/test_motion_service.py b/tests/test_motion_service.py index 446c7b2a4..67616fd86 100644 --- a/tests/test_motion_service.py +++ b/tests/test_motion_service.py @@ -125,7 +125,10 @@ async def test_move(self, motion: Motion, service: MotionRPCService): resource_name = Arm.get_resource_name("arm") destination = PoseInFrame(reference_frame="refframe") world_state = WorldState(transforms=[Transform(reference_frame="ws_tfrm_rf")]) - constraints = Constraints(linear_constraint=[LinearConstraint(), LinearConstraint(line_tolerance_mm=2)], pseudolinear_constraint=[PseudolinearConstraint(line_tolerance_factor=1.0, orientation_tolerance_factor=0.5)]) + constraints = Constraints( + linear_constraint=[LinearConstraint(), LinearConstraint(line_tolerance_mm=2)], + pseudolinear_constraint=[PseudolinearConstraint(line_tolerance_factor=1.0, orientation_tolerance_factor=0.5)], + ) extra = {"foo": "bar"} timeout = 2 success = await client.move( From ce56a8f6cfddc05b964c8663c7ded380aea38146 Mon Sep 17 00:00:00 2001 From: Naveed Jooma Date: Wed, 27 Aug 2025 11:53:15 -0400 Subject: [PATCH 3/3] Fix test --- tests/test_motion_service.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test_motion_service.py b/tests/test_motion_service.py index 67616fd86..4808ea601 100644 --- a/tests/test_motion_service.py +++ b/tests/test_motion_service.py @@ -21,7 +21,7 @@ PlanWithStatus, ) from viam.proto.common import GeoGeometry, Geometry, GeoPoint, Pose, PoseInFrame, ResourceName, Transform, WorldState -from viam.proto.service.motion import Constraints, LinearConstraint, MotionConfiguration, PseudolinearConstraint +from viam.proto.service.motion import Constraints, LinearConstraint, MotionConfiguration from viam.resource.manager import ResourceManager from viam.services.motion import MotionClient from viam.services.motion.motion import Motion @@ -125,10 +125,7 @@ async def test_move(self, motion: Motion, service: MotionRPCService): resource_name = Arm.get_resource_name("arm") destination = PoseInFrame(reference_frame="refframe") world_state = WorldState(transforms=[Transform(reference_frame="ws_tfrm_rf")]) - constraints = Constraints( - linear_constraint=[LinearConstraint(), LinearConstraint(line_tolerance_mm=2)], - pseudolinear_constraint=[PseudolinearConstraint(line_tolerance_factor=1.0, orientation_tolerance_factor=0.5)], - ) + constraints = Constraints(linear_constraint=[LinearConstraint(), LinearConstraint(line_tolerance_mm=2)]) extra = {"foo": "bar"} timeout = 2 success = await client.move(