Skip to content

Commit 2d262e7

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit da6c67a
1 parent 64b9308 commit 2d262e7

File tree

7 files changed

+126
-6
lines changed

7 files changed

+126
-6
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: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Struct, type JsonValue } from '@bufbuild/protobuf';
22
import type { CallOptions, PromiseClient } from '@connectrpc/connect';
33
import { DataManagerService } from '../../gen/service/datamanager/v1/data_manager_connect.js';
4-
import { SyncRequest } from '../../gen/service/datamanager/v1/data_manager_pb.js';
4+
import { SyncRequest, UploadBinaryDataToDatasetsRequest, UploadBinaryDataToDatasetsResponse } from '../../gen/service/datamanager/v1/data_manager_pb.js';
5+
import { MimeType } from '../../gen/app/datasync/v1/data_sync_pb.js';
56
import type { RobotClient } from '../../robot';
67
import type { Options } from '../../types';
78
import { doCommandFromClient } from '../../utils';
@@ -80,4 +81,49 @@ export class DataManagerClient implements DataManager {
8081
callOptions
8182
);
8283
}
84+
85+
/**
86+
* Uploads binary data to specified datasets.
87+
*
88+
* @example
89+
*
90+
* ```ts
91+
* const dataManager = new VIAM.DataManagerClient(
92+
* machine,
93+
* 'my_data_manager'
94+
* );
95+
* await dataManager.uploadBinaryDataToDatasets(
96+
* new Uint8Array([1, 2, 3]),
97+
* ['tag1', 'tag2'],
98+
* ['datasetId1', 'datasetId2'],
99+
* MimeType.MIME_TYPE_JPEG
100+
* );
101+
* ```
102+
*
103+
* @param binaryData - The binary data to upload.
104+
* @param tags - Tags to associate with the binary data.
105+
* @param datasetIds - IDs of the datasets to associate the binary data with.
106+
* @param mimeType - The MIME type of the binary data.
107+
* @param extra - Extra arguments to pass to the upload request.
108+
* @param callOptions - Call options for the upload request.
109+
*/
110+
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+
}
83129
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import type { Struct } from '@bufbuild/protobuf';
22
import type { Resource } from '../../types';
3+
import type { MimeType } from '../../app/datasync/v1/data_sync_pb.js';
34

45
export interface DataManager extends Resource {
56
sync: (extra?: Struct) => Promise<void>;
6-
}
7+
uploadBinaryDataToDatasets: (
8+
binaryData: Uint8Array,
9+
tags: string[],
10+
datasetIds: string[],
11+
mimeType: MimeType,
12+
extra?: Struct
13+
) => Promise<void>;
14+
}

src/services/motion/client.spec.ts

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import {
1818
ListPlanStatusesRequest,
1919
MoveOnGlobeRequest,
2020
MoveOnGlobeResponse,
21+
MoveRequest,
2122
StopPlanRequest,
2223
} from '../../gen/service/motion/v1/motion_pb';
23-
import { GeoGeometry, GeoPoint, ResourceName } from '../../types';
24+
import { GeoGeometry, GeoPoint, Pose, PoseInFrame, ResourceName } from '../../types';
2425
import { MotionClient } from './client';
2526
import {
2627
GetPlanResponse,
@@ -29,6 +30,7 @@ import {
2930
ObstacleDetector,
3031
PlanState,
3132
} from './types';
33+
import { Constraints, PseudolinearConstraint } from './types';
3234

3335
const motionClientName = 'test-motion';
3436
const date = new Date(1970, 1, 1, 1, 1, 1);
@@ -263,6 +265,66 @@ describe('moveOnGlobe', () => {
263265
});
264266
});
265267

268+
describe('move', () => {
269+
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+
});
276+
const expectedDestination: PoseInFrame = {
277+
referenceFrame: 'world',
278+
pose: {
279+
x: 1,
280+
y: 2,
281+
z: 3,
282+
oX: 0,
283+
oY: 0,
284+
oZ: 1,
285+
theta: 90,
286+
},
287+
};
288+
const expectedPseudolinearConstraint = new PseudolinearConstraint({
289+
lineToleranceFactor: 0.5,
290+
orientationToleranceFactor: 0.1,
291+
});
292+
const expectedConstraints: Constraints = {
293+
pseudolinearConstraint: [expectedPseudolinearConstraint],
294+
};
295+
const expectedExtra = { some: 'extra' };
296+
let capturedReq: MoveRequest | undefined;
297+
const mockTransport = createRouterTransport(({ service }) => {
298+
service(MotionService, {
299+
move: (req) => {
300+
capturedReq = req;
301+
return { success: true };
302+
},
303+
});
304+
});
305+
RobotClient.prototype.createServiceClient = vi
306+
.fn()
307+
.mockImplementation(() =>
308+
createPromiseClient(MotionService, mockTransport)
309+
);
310+
motion = new MotionClient(new RobotClient('host'), motionClientName);
311+
await expect(
312+
motion.move(
313+
expectedDestination,
314+
expectedComponentName,
315+
undefined, // worldState
316+
expectedConstraints,
317+
expectedExtra
318+
)
319+
).resolves.toStrictEqual(true);
320+
expect(capturedReq?.name).toStrictEqual(motionClientName);
321+
expect(capturedReq?.destination).toStrictEqual(expectedDestination);
322+
expect(capturedReq?.componentName).toStrictEqual(expectedComponentName);
323+
expect(capturedReq?.constraints).toStrictEqual(expectedConstraints);
324+
expect(capturedReq?.extra).toStrictEqual(Struct.fromJson(expectedExtra));
325+
});
326+
});
327+
266328
describe('stopPlan', () => {
267329
it('return null', async () => {
268330
const expectedComponentName = new ResourceName({
@@ -525,4 +587,4 @@ describe('listPlanStatuses', () => {
525587
expect(capturedReq?.onlyActivePlans).toStrictEqual(expectedOnlyActivePlans);
526588
expect(capturedReq?.extra).toStrictEqual(Struct.fromJson(expectedExtra));
527589
});
528-
});
590+
});

src/services/motion/client.ts

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

src/services/motion/motion.ts

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

2021
/**

src/services/motion/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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>;
910
export type ListPlanStatusesResponse = motionApi.ListPlanStatusesResponse;
1011
export type MotionConfiguration = PlainMessage<motionApi.MotionConfiguration>;
1112
export type ObstacleDetector = PlainMessage<motionApi.ObstacleDetector>;
@@ -18,9 +19,10 @@ export const {
1819
Constraints,
1920
GetPlanResponse,
2021
LinearConstraint,
22+
PseudolinearConstraint,
2123
ListPlanStatusesResponse,
2224
MotionConfiguration,
2325
ObstacleDetector,
2426
OrientationConstraint,
2527
PlanState,
26-
} = motionApi;
28+
} = motionApi;

0 commit comments

Comments
 (0)