Skip to content

Commit 2d4ebc9

Browse files
RSDK-10062: Modify TS motion wrappers to send strings (#634)
Co-authored-by: Benjamin Rewis <[email protected]>
1 parent 5ffb6c7 commit 2d4ebc9

File tree

3 files changed

+40
-167
lines changed

3 files changed

+40
-167
lines changed

src/services/motion/client.spec.ts

Lines changed: 16 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ import {
1818
MoveRequest,
1919
StopPlanRequest,
2020
} from '../../gen/service/motion/v1/motion_pb';
21-
import {
22-
GeoGeometry,
23-
GeoPoint,
24-
Pose,
25-
PoseInFrame,
26-
ResourceName,
27-
} from '../../types';
21+
import { GeoGeometry, GeoPoint, Pose, PoseInFrame } from '../../types';
2822
import { MotionClient } from './client';
2923
import {
3024
Constraints,
@@ -53,18 +47,8 @@ describe('moveOnGlobe', () => {
5347
const expectedDestination = new GeoPoint({ latitude: 1, longitude: 2 });
5448
const expectedObstaclesList: ObstacleDetector[] = [];
5549
const expectedHeading = undefined;
56-
const expectedComponentName = new ResourceName({
57-
namespace: 'viam',
58-
type: 'component',
59-
subtype: 'base',
60-
name: 'myBase',
61-
});
62-
const expectedMovementSensorName = new ResourceName({
63-
namespace: 'viam',
64-
type: 'component',
65-
subtype: 'movementsensor',
66-
name: 'myMovementsensor',
67-
});
50+
const expectedComponentName = 'myBase';
51+
const expectedMovementSensorName = 'myMovementsensor';
6852
const expectedMotionConfiguration = undefined;
6953
const expectedExtra = {};
7054

@@ -89,22 +73,8 @@ describe('moveOnGlobe', () => {
8973
await expect(
9074
motion.moveOnGlobe(
9175
{ latitude: 1, longitude: 2 },
92-
{
93-
namespace: 'viam',
94-
type: 'component',
95-
subtype: 'base',
96-
name: 'myBase',
97-
remotePath: [],
98-
localName: '',
99-
},
100-
{
101-
namespace: 'viam',
102-
type: 'component',
103-
subtype: 'movementsensor',
104-
name: 'myMovementsensor',
105-
remotePath: [],
106-
localName: '',
107-
}
76+
'myBase',
77+
'myMovementsensor'
10878
)
10979
).resolves.toStrictEqual(testExecutionId);
11080

@@ -179,33 +149,13 @@ describe('moveOnGlobe', () => {
179149
}),
180150
];
181151
const expectedHeading = 60;
182-
const expectedComponentName = new ResourceName({
183-
namespace: 'viam',
184-
type: 'component',
185-
subtype: 'base',
186-
name: 'myBase',
187-
});
188-
const expectedMovementSensorName = new ResourceName({
189-
namespace: 'viam',
190-
type: 'component',
191-
subtype: 'movementsensor',
192-
name: 'myMovementsensor',
193-
});
152+
const expectedComponentName = 'myBase';
153+
const expectedMovementSensorName = 'myMovementsensor';
194154
const expectedMotionConfiguration = new MotionConfiguration({
195155
obstacleDetectors: [
196156
{
197-
visionService: {
198-
namespace: 'viam',
199-
type: 'service',
200-
subtype: 'vision',
201-
name: 'myVisionService',
202-
},
203-
camera: {
204-
namespace: 'viam',
205-
type: 'component',
206-
subtype: 'camera',
207-
name: 'myCamera',
208-
},
157+
visionService: 'myVisionService',
158+
camera: 'myCamera',
209159
},
210160
],
211161
positionPollingFrequencyHz: 20,
@@ -267,12 +217,7 @@ describe('moveOnGlobe', () => {
267217

268218
describe('move', () => {
269219
it('sends a move request with pseudolinear constraints', async () => {
270-
const expectedComponentName = new ResourceName({
271-
namespace: 'viam',
272-
type: 'component',
273-
subtype: 'base',
274-
name: 'myBase',
275-
});
220+
const expectedComponentName = 'myBase';
276221
const expectedDestination = new PoseInFrame({
277222
referenceFrame: 'world',
278223
pose: new Pose({
@@ -325,12 +270,7 @@ describe('move', () => {
325270

326271
describe('stopPlan', () => {
327272
it('return null', async () => {
328-
const expectedComponentName = new ResourceName({
329-
namespace: 'viam',
330-
type: 'component',
331-
subtype: 'base',
332-
name: 'myBase',
333-
});
273+
const expectedComponentName = 'myBase';
334274
const expectedExtra = {};
335275

336276
let capturedReq: StopPlanRequest | undefined;
@@ -357,12 +297,7 @@ describe('stopPlan', () => {
357297
});
358298

359299
it('allows optionally specifying extra', async () => {
360-
const expectedComponentName = new ResourceName({
361-
namespace: 'viam',
362-
type: 'component',
363-
subtype: 'base',
364-
name: 'myBase',
365-
});
300+
const expectedComponentName = 'myBase';
366301
const expectedExtra = { some: 'extra' };
367302
let capturedReq: StopPlanRequest | undefined;
368303
const mockTransport = createRouterTransport(({ service }) => {
@@ -393,12 +328,7 @@ describe('getPlan', () => {
393328
currentPlanWithStatus: {
394329
plan: {
395330
id: 'planId',
396-
componentName: {
397-
namespace: 'viam',
398-
type: 'component',
399-
subtype: 'base',
400-
name: 'myBase',
401-
},
331+
componentName: 'myBase',
402332
executionId: 'executionId',
403333
steps: [
404334
{
@@ -428,12 +358,7 @@ describe('getPlan', () => {
428358
});
429359

430360
it('return GetPlanResponse', async () => {
431-
const expectedComponentName = new ResourceName({
432-
namespace: 'viam',
433-
type: 'component',
434-
subtype: 'base',
435-
name: 'myBase',
436-
});
361+
const expectedComponentName = 'myBase';
437362
const expectedLastPlanOnly = false;
438363
const expectedExecutionID = undefined;
439364
const expectedExtra = {};
@@ -463,12 +388,7 @@ describe('getPlan', () => {
463388
});
464389

465390
it('allows optionally specifying lastPlanOnly, executionID, and extra', async () => {
466-
const expectedComponentName = new ResourceName({
467-
namespace: 'viam',
468-
type: 'component',
469-
subtype: 'base',
470-
name: 'myBase',
471-
});
391+
const expectedComponentName = 'myBase';
472392
const expectedLastPlanOnly = true;
473393
const expectedExecutionID = 'some specific executionID';
474394
const expectedExtra = { some: 'extra' };
@@ -508,12 +428,7 @@ describe('listPlanStatuses', () => {
508428
planStatusesWithIds: [
509429
{
510430
planId: 'some plan id',
511-
componentName: {
512-
namespace: 'viam',
513-
type: 'component',
514-
subtype: 'base',
515-
name: 'myBase',
516-
},
431+
componentName: 'myBase',
517432
executionId: 'some execution id',
518433
status: {
519434
state: PlanState.STOPPED,

src/services/motion/client.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type {
1818
Options,
1919
Pose,
2020
PoseInFrame,
21-
ResourceName,
2221
Transform,
2322
WorldState,
2423
} from '../../types';
@@ -45,7 +44,7 @@ export class MotionClient implements Motion {
4544

4645
async move(
4746
destination: PoseInFrame,
48-
componentName: ResourceName,
47+
componentName: string,
4948
worldState?: WorldState,
5049
constraints?: Constraints,
5150
extra = {},
@@ -68,8 +67,8 @@ export class MotionClient implements Motion {
6867

6968
async moveOnMap(
7069
destination: Pose,
71-
componentName: ResourceName,
72-
slamServiceName: ResourceName,
70+
componentName: string,
71+
slamServiceName: string,
7372
motionConfig?: MotionConfiguration,
7473
obstacles?: Geometry[],
7574
extra = {},
@@ -93,8 +92,8 @@ export class MotionClient implements Motion {
9392

9493
async moveOnGlobe(
9594
destination: GeoPoint,
96-
componentName: ResourceName,
97-
movementSensorName: ResourceName,
95+
componentName: string,
96+
movementSensorName: string,
9897
heading?: number,
9998
obstaclesList?: GeoGeometry[],
10099
motionConfig?: MotionConfiguration,
@@ -121,7 +120,7 @@ export class MotionClient implements Motion {
121120
}
122121

123122
async stopPlan(
124-
componentName: ResourceName,
123+
componentName: string,
125124
extra = {},
126125
callOptions = this.callOptions
127126
) {
@@ -138,7 +137,7 @@ export class MotionClient implements Motion {
138137
}
139138

140139
async getPlan(
141-
componentName: ResourceName,
140+
componentName: string,
142141
lastPlanOnly?: boolean,
143142
executionId?: string,
144143
extra = {},
@@ -174,7 +173,7 @@ export class MotionClient implements Motion {
174173
}
175174

176175
async getPose(
177-
componentName: ResourceName,
176+
componentName: string,
178177
destinationFrame: string,
179178
supplementalTransforms: Transform[],
180179
extra = {},

0 commit comments

Comments
 (0)