diff --git a/src/services/motion/client.spec.ts b/src/services/motion/client.spec.ts index 1bd7d7517..9b1608475 100644 --- a/src/services/motion/client.spec.ts +++ b/src/services/motion/client.spec.ts @@ -18,13 +18,7 @@ import { MoveRequest, StopPlanRequest, } from '../../gen/service/motion/v1/motion_pb'; -import { - GeoGeometry, - GeoPoint, - Pose, - PoseInFrame, - ResourceName, -} from '../../types'; +import { GeoGeometry, GeoPoint, Pose, PoseInFrame } from '../../types'; import { MotionClient } from './client'; import { Constraints, @@ -53,18 +47,8 @@ describe('moveOnGlobe', () => { const expectedDestination = new GeoPoint({ latitude: 1, longitude: 2 }); const expectedObstaclesList: ObstacleDetector[] = []; const expectedHeading = undefined; - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); - const expectedMovementSensorName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'movementsensor', - name: 'myMovementsensor', - }); + const expectedComponentName = 'myBase'; + const expectedMovementSensorName = 'myMovementsensor'; const expectedMotionConfiguration = undefined; const expectedExtra = {}; @@ -89,22 +73,8 @@ describe('moveOnGlobe', () => { await expect( motion.moveOnGlobe( { latitude: 1, longitude: 2 }, - { - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - remotePath: [], - localName: '', - }, - { - namespace: 'viam', - type: 'component', - subtype: 'movementsensor', - name: 'myMovementsensor', - remotePath: [], - localName: '', - } + 'myBase', + 'myMovementsensor' ) ).resolves.toStrictEqual(testExecutionId); @@ -179,33 +149,13 @@ describe('moveOnGlobe', () => { }), ]; const expectedHeading = 60; - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); - const expectedMovementSensorName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'movementsensor', - name: 'myMovementsensor', - }); + const expectedComponentName = 'myBase'; + const expectedMovementSensorName = 'myMovementsensor'; const expectedMotionConfiguration = new MotionConfiguration({ obstacleDetectors: [ { - visionService: { - namespace: 'viam', - type: 'service', - subtype: 'vision', - name: 'myVisionService', - }, - camera: { - namespace: 'viam', - type: 'component', - subtype: 'camera', - name: 'myCamera', - }, + visionService: 'myVisionService', + camera: 'myCamera', }, ], positionPollingFrequencyHz: 20, @@ -267,12 +217,7 @@ describe('moveOnGlobe', () => { describe('move', () => { it('sends a move request with pseudolinear constraints', async () => { - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); + const expectedComponentName = 'myBase'; const expectedDestination = new PoseInFrame({ referenceFrame: 'world', pose: new Pose({ @@ -325,12 +270,7 @@ describe('move', () => { describe('stopPlan', () => { it('return null', async () => { - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); + const expectedComponentName = 'myBase'; const expectedExtra = {}; let capturedReq: StopPlanRequest | undefined; @@ -357,12 +297,7 @@ describe('stopPlan', () => { }); it('allows optionally specifying extra', async () => { - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); + const expectedComponentName = 'myBase'; const expectedExtra = { some: 'extra' }; let capturedReq: StopPlanRequest | undefined; const mockTransport = createRouterTransport(({ service }) => { @@ -393,12 +328,7 @@ describe('getPlan', () => { currentPlanWithStatus: { plan: { id: 'planId', - componentName: { - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }, + componentName: 'myBase', executionId: 'executionId', steps: [ { @@ -428,12 +358,7 @@ describe('getPlan', () => { }); it('return GetPlanResponse', async () => { - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); + const expectedComponentName = 'myBase'; const expectedLastPlanOnly = false; const expectedExecutionID = undefined; const expectedExtra = {}; @@ -463,12 +388,7 @@ describe('getPlan', () => { }); it('allows optionally specifying lastPlanOnly, executionID, and extra', async () => { - const expectedComponentName = new ResourceName({ - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }); + const expectedComponentName = 'myBase'; const expectedLastPlanOnly = true; const expectedExecutionID = 'some specific executionID'; const expectedExtra = { some: 'extra' }; @@ -508,12 +428,7 @@ describe('listPlanStatuses', () => { planStatusesWithIds: [ { planId: 'some plan id', - componentName: { - namespace: 'viam', - type: 'component', - subtype: 'base', - name: 'myBase', - }, + componentName: 'myBase', executionId: 'some execution id', status: { state: PlanState.STOPPED, diff --git a/src/services/motion/client.ts b/src/services/motion/client.ts index c12ee3d81..0f17b2d8c 100644 --- a/src/services/motion/client.ts +++ b/src/services/motion/client.ts @@ -18,7 +18,6 @@ import type { Options, Pose, PoseInFrame, - ResourceName, Transform, WorldState, } from '../../types'; @@ -45,7 +44,7 @@ export class MotionClient implements Motion { async move( destination: PoseInFrame, - componentName: ResourceName, + componentName: string, worldState?: WorldState, constraints?: Constraints, extra = {}, @@ -68,8 +67,8 @@ export class MotionClient implements Motion { async moveOnMap( destination: Pose, - componentName: ResourceName, - slamServiceName: ResourceName, + componentName: string, + slamServiceName: string, motionConfig?: MotionConfiguration, obstacles?: Geometry[], extra = {}, @@ -93,8 +92,8 @@ export class MotionClient implements Motion { async moveOnGlobe( destination: GeoPoint, - componentName: ResourceName, - movementSensorName: ResourceName, + componentName: string, + movementSensorName: string, heading?: number, obstaclesList?: GeoGeometry[], motionConfig?: MotionConfiguration, @@ -121,7 +120,7 @@ export class MotionClient implements Motion { } async stopPlan( - componentName: ResourceName, + componentName: string, extra = {}, callOptions = this.callOptions ) { @@ -138,7 +137,7 @@ export class MotionClient implements Motion { } async getPlan( - componentName: ResourceName, + componentName: string, lastPlanOnly?: boolean, executionId?: string, extra = {}, @@ -174,7 +173,7 @@ export class MotionClient implements Motion { } async getPose( - componentName: ResourceName, + componentName: string, destinationFrame: string, supplementalTransforms: Transform[], extra = {}, diff --git a/src/services/motion/motion.ts b/src/services/motion/motion.ts index b072f8381..a4768684b 100644 --- a/src/services/motion/motion.ts +++ b/src/services/motion/motion.ts @@ -6,7 +6,6 @@ import type { Pose, PoseInFrame, Resource, - ResourceName, Transform, WorldState, } from '../../types'; @@ -32,12 +31,7 @@ export interface Motion extends Resource { * const motion = new VIAM.MotionClient(machine, 'builtin'); * * // Assumes a gripper configured with name "my_gripper" - * const gripperName = new VIAM.ResourceName({ - * name: 'my_gripper', - * namespace: 'rdk', - * type: 'component', - * subtype: 'gripper', - * }); + * cconst gripperName = "my_gripper"; * * const goalPose: VIAM.Pose = { * x: -817, @@ -71,7 +65,7 @@ export interface Motion extends Resource { */ move: ( destination: PoseInFrame, - componentName: ResourceName, + componentName: string, worldState?: WorldState, constraints?: Constraints, extra?: Struct @@ -102,18 +96,8 @@ export interface Motion extends Resource { * theta: 0, * }; * - * const baseName = new VIAM.ResourceName({ - * name: 'my_base', - * namespace: 'rdk', - * type: 'component', - * subtype: 'base', - * }); - * const slamServiceName = new VIAM.ResourceName({ - * name: 'my_slam_service', - * namespace: 'rdk', - * type: 'service', - * subtype: 'slam', - * }); + * const baseName = 'my_base'; + * const slamServiceName = 'my_slam_service'; * * // Move the base to Y=10 (location of 0,10,0) relative to map origin * const executionId = await motion.moveOnMap( @@ -137,8 +121,8 @@ export interface Motion extends Resource { */ moveOnMap: ( destination: Pose, - componentName: ResourceName, - slamServiceName: ResourceName, + componentName: string, + slamServiceName: string, motionConfiguration?: MotionConfiguration, obstacles?: Geometry[], extra?: Struct @@ -164,18 +148,8 @@ export interface Motion extends Resource { * longitude: -73.98, * }; * - * const baseName = new VIAM.ResourceName({ - * name: 'my_base', - * namespace: 'rdk', - * type: 'component', - * subtype: 'base', - * }); - * const movementSensorName = new VIAM.ResourceName({ - * name: 'my_movement_sensor', - * namespace: 'rdk', - * type: 'component', - * subtype: 'movement_sensor', - * }); + * const baseName = 'my_base'; + * const movementSensorName = 'my_movement_sensor'; * * // Move the base to the geographic location * const globeExecutionId = await motion.moveOnGlobe( @@ -202,8 +176,8 @@ export interface Motion extends Resource { */ moveOnGlobe: ( destination: GeoPoint, - componentName: ResourceName, - movementSensorName: ResourceName, + componentName: string, + movementSensorName: string, heading?: number, obstaclesList?: GeoGeometry[], motionConfiguration?: MotionConfiguration, @@ -219,12 +193,7 @@ export interface Motion extends Resource { * * ```ts * const motion = new VIAM.MotionClient(machine, 'builtin'); - * const baseName = new VIAM.ResourceName({ - * name: 'my_base', - * namespace: 'rdk', - * type: 'component', - * subtype: 'base', - * }); + * const baseName = 'my_base'; * * // Stop the base component which was instructed to move * await motion.stopPlan(baseName); @@ -235,7 +204,7 @@ export interface Motion extends Resource { * * @param componentName - The component to stop */ - stopPlan: (componentName: ResourceName, extra?: Struct) => Promise; + stopPlan: (componentName: string, extra?: Struct) => Promise; /** * By default: returns the plan history of the most recent `moveOnGlobe()` or @@ -255,12 +224,7 @@ export interface Motion extends Resource { * * ```ts * const motion = new VIAM.MotionClient(machine, 'builtin'); - * const baseName = new VIAM.ResourceName({ - * name: 'my_base', - * namespace: 'rdk', - * type: 'component', - * subtype: 'base', - * }); + * const baseName = 'my_base'; * * // Get the plan(s) of the base component * const response = await motion.getPlan(baseName); @@ -277,7 +241,7 @@ export interface Motion extends Resource { * reference frames that are needed to compute the component's `Pose`. */ getPlan: ( - componentName: ResourceName, + componentName: string, lastPlanOnly?: boolean, executionId?: string, extra?: Struct @@ -321,12 +285,7 @@ export interface Motion extends Resource { * ```ts * const motion = new VIAM.MotionClient(machine, 'builtin'); * - * const gripperName = new VIAM.ResourceName({ - * name: 'my_gripper', - * namespace: 'rdk', - * type: 'component', - * subtype: 'gripper', - * }); + * const gripperName = 'my_gripper'; * * // Get the gripper's pose in world coordinates * const gripperPoseInWorld = await motion.getPose( @@ -347,7 +306,7 @@ export interface Motion extends Resource { * reference frames that are needed to compute the component's `Pose`. */ getPose: ( - componentName: ResourceName, + componentName: string, destinationFrame: string, supplementalTransforms: Transform[], extra?: Struct