Skip to content

Commit 0ded13c

Browse files
committed
Fix AI things
1 parent a15ee4e commit 0ded13c

File tree

7 files changed

+60
-72
lines changed

7 files changed

+60
-72
lines changed

src/app/data-client.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,4 +1715,4 @@ describe('DataPipelineClient tests', () => {
17151715
expect(nextPage.runs).toEqual([]);
17161716
});
17171717
});
1718-
});
1718+
});

src/services/data-manager/client.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { Struct, type JsonValue } from '@bufbuild/protobuf';
2-
import type { CallOptions, PromiseClient } from '@connectrpc/connect';
3-
import { DataManagerService } from '../../gen/service/datamanager/v1/data_manager_connect.js';
4-
import { SyncRequest, UploadBinaryDataToDatasetsRequest, UploadBinaryDataToDatasetsResponse } from '../../gen/service/datamanager/v1/data_manager_pb.js';
2+
import type { CallOptions, Client } from '@connectrpc/connect';
53
import { MimeType } from '../../gen/app/datasync/v1/data_sync_pb.js';
4+
import { DataManagerService } from '../../gen/service/datamanager/v1/data_manager_connect.js';
5+
import {
6+
SyncRequest,
7+
UploadBinaryDataToDatasetsRequest,
8+
} from '../../gen/service/datamanager/v1/data_manager_pb.js';
69
import type { RobotClient } from '../../robot';
710
import type { Options } from '../../types';
811
import { doCommandFromClient } from '../../utils';
912
import type { DataManager } from './data-manager';
1013

1114
export class DataManagerClient implements DataManager {
12-
private client: PromiseClient<typeof DataManagerService>;
15+
private client: Client<typeof DataManagerService>;
1316
public readonly name: string;
1417
private readonly options: Options;
1518
public callOptions: CallOptions = { headers: {} as Record<string, string> };
@@ -108,22 +111,22 @@ export class DataManagerClient implements DataManager {
108111
* @param callOptions - Call options for the upload request.
109112
*/
110113
async uploadBinaryDataToDatasets(
111-
binaryData: Uint8Array,
112-
tags: string[],
113-
datasetIds: string[],
114-
mimeType: MimeType,
115-
extra = {},
116-
callOptions = this.callOptions
117-
) {
118-
const request = new UploadBinaryDataToDatasetsRequest({
119-
name: this.name,
120-
binaryData,
121-
tags,
122-
datasetIds,
123-
mimeType,
124-
extra: Struct.fromJson(extra),
125-
});
126-
this.options.requestLogger?.(request);
127-
await this.client.uploadBinaryDataToDatasets(request, callOptions);
128-
}
114+
binaryData: Uint8Array,
115+
tags: string[],
116+
datasetIds: string[],
117+
mimeType: MimeType,
118+
extra = {},
119+
callOptions = this.callOptions
120+
) {
121+
const request = new UploadBinaryDataToDatasetsRequest({
122+
name: this.name,
123+
binaryData,
124+
tags,
125+
datasetIds,
126+
mimeType,
127+
extra: Struct.fromJson(extra),
128+
});
129+
this.options.requestLogger?.(request);
130+
await this.client.uploadBinaryDataToDatasets(request, callOptions);
131+
}
129132
}

src/services/data-manager/data-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Struct } from '@bufbuild/protobuf';
2+
import { MimeType } from '../../gen/app/datasync/v1/data_sync_pb.js';
23
import type { Resource } from '../../types';
3-
import type { MimeType } from '../../app/datasync/v1/data_sync_pb.js';
44

55
export interface DataManager extends Resource {
66
sync: (extra?: Struct) => Promise<void>;
@@ -11,4 +11,4 @@ export interface DataManager extends Resource {
1111
mimeType: MimeType,
1212
extra?: Struct
1313
) => Promise<void>;
14-
}
14+
}

src/services/motion/client.spec.ts

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ vi.mock('../../gen/service/motion/v1/motion_pb_service');
88
vi.mock('../../robot');
99

1010
import { Struct, Timestamp } from '@bufbuild/protobuf';
11-
import {
12-
createPromiseClient,
13-
createRouterTransport,
14-
} from '@connectrpc/connect';
11+
import { createClient, createRouterTransport } from '@connectrpc/connect';
1512
import { MotionService } from '../../gen/service/motion/v1/motion_connect';
1613
import {
1714
GetPlanRequest,
@@ -21,16 +18,23 @@ import {
2118
MoveRequest,
2219
StopPlanRequest,
2320
} from '../../gen/service/motion/v1/motion_pb';
24-
import { GeoGeometry, GeoPoint, Pose, PoseInFrame, ResourceName } from '../../types';
21+
import {
22+
GeoGeometry,
23+
GeoPoint,
24+
Pose,
25+
PoseInFrame,
26+
ResourceName,
27+
} from '../../types';
2528
import { MotionClient } from './client';
2629
import {
30+
Constraints,
2731
GetPlanResponse,
2832
ListPlanStatusesResponse,
2933
MotionConfiguration,
3034
ObstacleDetector,
3135
PlanState,
36+
PseudolinearConstraint,
3237
} from './types';
33-
import { Constraints, PseudolinearConstraint } from './types';
3438

3539
const motionClientName = 'test-motion';
3640
const date = new Date(1970, 1, 1, 1, 1, 1);
@@ -78,9 +82,7 @@ describe('moveOnGlobe', () => {
7882

7983
RobotClient.prototype.createServiceClient = vi
8084
.fn()
81-
.mockImplementation(() =>
82-
createPromiseClient(MotionService, mockTransport)
83-
);
85+
.mockImplementation(() => createClient(MotionService, mockTransport));
8486

8587
motion = new MotionClient(new RobotClient('host'), motionClientName);
8688

@@ -228,9 +230,7 @@ describe('moveOnGlobe', () => {
228230

229231
RobotClient.prototype.createServiceClient = vi
230232
.fn()
231-
.mockImplementation(() =>
232-
createPromiseClient(MotionService, mockTransport)
233-
);
233+
.mockImplementation(() => createClient(MotionService, mockTransport));
234234

235235
motion = new MotionClient(new RobotClient('host'), motionClientName);
236236

@@ -273,25 +273,25 @@ describe('move', () => {
273273
subtype: 'base',
274274
name: 'myBase',
275275
});
276-
const expectedDestination: PoseInFrame = {
276+
const expectedDestination = new PoseInFrame({
277277
referenceFrame: 'world',
278-
pose: {
278+
pose: new Pose({
279279
x: 1,
280280
y: 2,
281281
z: 3,
282282
oX: 0,
283283
oY: 0,
284284
oZ: 1,
285285
theta: 90,
286-
},
287-
};
286+
}),
287+
});
288288
const expectedPseudolinearConstraint = new PseudolinearConstraint({
289-
lineToleranceFactor: 0.5,
290-
orientationToleranceFactor: 0.1,
289+
lineToleranceFactor: 5,
290+
orientationToleranceFactor: 10,
291291
});
292-
const expectedConstraints: Constraints = {
292+
const expectedConstraints = new Constraints({
293293
pseudolinearConstraint: [expectedPseudolinearConstraint],
294-
};
294+
});
295295
const expectedExtra = { some: 'extra' };
296296
let capturedReq: MoveRequest | undefined;
297297
const mockTransport = createRouterTransport(({ service }) => {
@@ -304,15 +304,13 @@ describe('move', () => {
304304
});
305305
RobotClient.prototype.createServiceClient = vi
306306
.fn()
307-
.mockImplementation(() =>
308-
createPromiseClient(MotionService, mockTransport)
309-
);
307+
.mockImplementation(() => createClient(MotionService, mockTransport));
310308
motion = new MotionClient(new RobotClient('host'), motionClientName);
311309
await expect(
312310
motion.move(
313311
expectedDestination,
314312
expectedComponentName,
315-
undefined, // worldState
313+
undefined,
316314
expectedConstraints,
317315
expectedExtra
318316
)
@@ -347,9 +345,7 @@ describe('stopPlan', () => {
347345

348346
RobotClient.prototype.createServiceClient = vi
349347
.fn()
350-
.mockImplementation(() =>
351-
createPromiseClient(MotionService, mockTransport)
352-
);
348+
.mockImplementation(() => createClient(MotionService, mockTransport));
353349

354350
motion = new MotionClient(new RobotClient('host'), motionClientName);
355351

@@ -380,9 +376,7 @@ describe('stopPlan', () => {
380376

381377
RobotClient.prototype.createServiceClient = vi
382378
.fn()
383-
.mockImplementation(() =>
384-
createPromiseClient(MotionService, mockTransport)
385-
);
379+
.mockImplementation(() => createClient(MotionService, mockTransport));
386380

387381
motion = new MotionClient(new RobotClient('host'), motionClientName);
388382

@@ -455,9 +449,7 @@ describe('getPlan', () => {
455449

456450
RobotClient.prototype.createServiceClient = vi
457451
.fn()
458-
.mockImplementation(() =>
459-
createPromiseClient(MotionService, mockTransport)
460-
);
452+
.mockImplementation(() => createClient(MotionService, mockTransport));
461453

462454
motion = new MotionClient(new RobotClient('host'), motionClientName);
463455

@@ -492,9 +484,7 @@ describe('getPlan', () => {
492484

493485
RobotClient.prototype.createServiceClient = vi
494486
.fn()
495-
.mockImplementation(() =>
496-
createPromiseClient(MotionService, mockTransport)
497-
);
487+
.mockImplementation(() => createClient(MotionService, mockTransport));
498488

499489
motion = new MotionClient(new RobotClient('host'), motionClientName);
500490

@@ -547,9 +537,7 @@ describe('listPlanStatuses', () => {
547537

548538
RobotClient.prototype.createServiceClient = vi
549539
.fn()
550-
.mockImplementation(() =>
551-
createPromiseClient(MotionService, mockTransport)
552-
);
540+
.mockImplementation(() => createClient(MotionService, mockTransport));
553541

554542
motion = new MotionClient(new RobotClient('host'), motionClientName);
555543

@@ -575,9 +563,7 @@ describe('listPlanStatuses', () => {
575563

576564
RobotClient.prototype.createServiceClient = vi
577565
.fn()
578-
.mockImplementation(() =>
579-
createPromiseClient(MotionService, mockTransport)
580-
);
566+
.mockImplementation(() => createClient(MotionService, mockTransport));
581567

582568
motion = new MotionClient(new RobotClient('host'), motionClientName);
583569

@@ -587,4 +573,4 @@ describe('listPlanStatuses', () => {
587573
expect(capturedReq?.onlyActivePlans).toStrictEqual(expectedOnlyActivePlans);
588574
expect(capturedReq?.extra).toStrictEqual(Struct.fromJson(expectedExtra));
589575
});
590-
});
576+
});

src/services/motion/client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
MoveOnMapRequest,
1010
MoveRequest,
1111
StopPlanRequest,
12-
PseudolinearConstraint,
1312
} from '../../gen/service/motion/v1/motion_pb';
1413
import type { RobotClient } from '../../robot';
1514
import type {

src/services/motion/motion.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type {
1515
GetPlanResponse,
1616
ListPlanStatusesResponse,
1717
MotionConfiguration,
18-
PseudolinearConstraint,
1918
} from './types';
2019

2120
/**

src/services/motion/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export type CollisionSpecification =
66
export type Constraints = PlainMessage<motionApi.Constraints>;
77
export type GetPlanResponse = motionApi.GetPlanResponse;
88
export type LinearConstraint = PlainMessage<motionApi.LinearConstraint>;
9-
export type PseudolinearConstraint = PlainMessage<motionApi.PseudolinearConstraint>;
9+
export type PseudolinearConstraint =
10+
PlainMessage<motionApi.PseudolinearConstraint>;
1011
export type ListPlanStatusesResponse = motionApi.ListPlanStatusesResponse;
1112
export type MotionConfiguration = PlainMessage<motionApi.MotionConfiguration>;
1213
export type ObstacleDetector = PlainMessage<motionApi.ObstacleDetector>;
@@ -25,4 +26,4 @@ export const {
2526
ObstacleDetector,
2627
OrientationConstraint,
2728
PlanState,
28-
} = motionApi;
29+
} = motionApi;

0 commit comments

Comments
 (0)