Skip to content

Commit 501ff92

Browse files
authored
RSDK-9890 - support extra in camera apis (#460)
1 parent eeb79be commit 501ff92

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/components/camera/camera.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Struct } from '@bufbuild/protobuf';
12
import type {
23
DistortionParameters,
34
IntrinsicParameters,
@@ -31,18 +32,18 @@ export interface Camera extends Resource {
3132
* @param mimeType - A specific MIME type to request. This is not necessarily
3233
* the same type that will be returned.
3334
*/
34-
getImage: (mimeType?: MimeType) => Promise<Uint8Array>;
35+
getImage: (mimeType?: MimeType, extra?: Struct) => Promise<Uint8Array>;
3536

3637
/**
3738
* Render a frame from a camera to an HTTP response.
3839
*
3940
* @param mimeType - A specific MIME type to request. This is not necessarily
4041
* the same type that will be returned.
4142
*/
42-
renderFrame: (mimeType?: MimeType) => Promise<Blob>;
43+
renderFrame: (mimeType?: MimeType, extra?: Struct) => Promise<Blob>;
4344

4445
/** Return a point cloud from a camera. */
45-
getPointCloud: () => Promise<Uint8Array>;
46+
getPointCloud: (extra?: Struct) => Promise<Uint8Array>;
4647

4748
/** Return the camera properties. */
4849
getProperties: () => Promise<Properties>;

src/components/camera/client.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { JsonValue, Struct } from '@bufbuild/protobuf';
1+
import { type JsonValue, Struct } from '@bufbuild/protobuf';
22
import type { CallOptions, PromiseClient } from '@connectrpc/connect';
33
import { GetPropertiesRequest } from '../../gen/component/base/v1/base_pb';
44
import { CameraService } from '../../gen/component/camera/v1/camera_connect';
@@ -31,10 +31,15 @@ export class CameraClient implements Camera {
3131
this.options = options;
3232
}
3333

34-
async getImage(mimeType: MimeType = '', callOptions = this.callOptions) {
34+
async getImage(
35+
mimeType: MimeType = '',
36+
extra = {},
37+
callOptions = this.callOptions
38+
) {
3539
const request = new GetImageRequest({
3640
name: this.name,
3741
mimeType,
42+
extra: Struct.fromJson(extra),
3843
});
3944

4045
this.options.requestLogger?.(request);
@@ -43,10 +48,15 @@ export class CameraClient implements Camera {
4348
return resp.image;
4449
}
4550

46-
async renderFrame(mimeType: MimeType = '', callOptions = this.callOptions) {
51+
async renderFrame(
52+
mimeType: MimeType = '',
53+
extra = {},
54+
callOptions = this.callOptions
55+
) {
4756
const request = new RenderFrameRequest({
4857
name: this.name,
4958
mimeType,
59+
extra: Struct.fromJson(extra),
5060
});
5161

5262
this.options.requestLogger?.(request);
@@ -55,10 +65,11 @@ export class CameraClient implements Camera {
5565
return new Blob([resp.data], { type: mimeType });
5666
}
5767

58-
async getPointCloud(callOptions = this.callOptions) {
68+
async getPointCloud(extra = {}, callOptions = this.callOptions) {
5969
const request = new GetPointCloudRequest({
6070
name: this.name,
6171
mimeType: PointCloudPCD,
72+
extra: Struct.fromJson(extra),
6273
});
6374

6475
this.options.requestLogger?.(request);

0 commit comments

Comments
 (0)