Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-9890 - support extra in camera apis #460

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/camera/camera.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Struct } from '@bufbuild/protobuf';
import type {
DistortionParameters,
IntrinsicParameters,
Expand Down Expand Up @@ -31,18 +32,18 @@ export interface Camera extends Resource {
* @param mimeType - A specific MIME type to request. This is not necessarily
* the same type that will be returned.
*/
getImage: (mimeType?: MimeType) => Promise<Uint8Array>;
getImage: (mimeType?: MimeType, extra?: Struct) => Promise<Uint8Array>;

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

/** Return a point cloud from a camera. */
getPointCloud: () => Promise<Uint8Array>;
getPointCloud: (extra?: Struct) => Promise<Uint8Array>;

/** Return the camera properties. */
getProperties: () => Promise<Properties>;
Expand Down
19 changes: 15 additions & 4 deletions src/components/camera/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { JsonValue, Struct } from '@bufbuild/protobuf';
import { type JsonValue, Struct } from '@bufbuild/protobuf';
import type { CallOptions, PromiseClient } from '@connectrpc/connect';
import { GetPropertiesRequest } from '../../gen/component/base/v1/base_pb';
import { CameraService } from '../../gen/component/camera/v1/camera_connect';
Expand Down Expand Up @@ -31,10 +31,15 @@ export class CameraClient implements Camera {
this.options = options;
}

async getImage(mimeType: MimeType = '', callOptions = this.callOptions) {
async getImage(
mimeType: MimeType = '',
extra = {},
callOptions = this.callOptions
) {
const request = new GetImageRequest({
name: this.name,
mimeType,
extra: Struct.fromJson(extra),
});

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

async renderFrame(mimeType: MimeType = '', callOptions = this.callOptions) {
async renderFrame(
mimeType: MimeType = '',
extra = {},
callOptions = this.callOptions
) {
const request = new RenderFrameRequest({
name: this.name,
mimeType,
extra: Struct.fromJson(extra),
});

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

async getPointCloud(callOptions = this.callOptions) {
async getPointCloud(extra = {}, callOptions = this.callOptions) {
const request = new GetPointCloudRequest({
name: this.name,
mimeType: PointCloudPCD,
extra: Struct.fromJson(extra),
});

this.options.requestLogger?.(request);
Expand Down