Skip to content

Commit

Permalink
Add getGeometries calls to components (#471)
Browse files Browse the repository at this point in the history
Co-authored-by: Zack Porter <[email protected]>
  • Loading branch information
micheal-parks and zaporter-work authored Feb 18, 2025
1 parent fa1ed60 commit 9e2c5cd
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/components/arm/arm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { PlainMessage, Struct } from '@bufbuild/protobuf';
import type { Pose, Resource } from '../../types';

import * as armApi from '../../gen/component/arm/v1/arm_pb';
import type { Geometry } from '../../gen/common/v1/common_pb';

export type ArmJointPositions = PlainMessage<armApi.JointPositions>;

Expand All @@ -12,6 +13,9 @@ export interface Arm extends Resource {
/** Get the position of the end of the arm expressed as a pose */
getEndPosition: (extra?: Struct) => Promise<Pose>;

/** Get the geometries of the component in their current configuration */
getGeometries: (extra?: Struct) => Promise<Geometry[]>;

/**
* Move the end of the arm to the pose.
*
Expand Down
11 changes: 11 additions & 0 deletions src/components/arm/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { RobotClient } from '../../robot';
import type { Options, Pose } from '../../types';
import { doCommandFromClient } from '../../utils';
import type { Arm } from './arm';
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';

/**
* A gRPC-web client for the Arm component.
Expand Down Expand Up @@ -48,6 +49,16 @@ export class ArmClient implements Arm {
return result;
}

async getGeometries(extra = {}, callOptions = this.callOptions) {
const request = new GetGeometriesRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.getGeometries(request, callOptions);
return response.geometries;
}

async moveToPosition(pose: Pose, extra = {}, callOptions = this.callOptions) {
const request = new MoveToPositionRequest({
name: this.name,
Expand Down
5 changes: 5 additions & 0 deletions src/components/base/base.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import type { Resource, Struct, Vector3 } from '../../types';

import * as baseApi from '../../gen/component/base/v1/base_pb';
import type { Geometry } from '../../gen/common/v1/common_pb';

export type BaseProperties = baseApi.GetPropertiesResponse;

export const { GetPropertiesResponse: BaseProperties } = baseApi;

/** Represents a physical base of a robot. */

export interface Base extends Resource {
/** Get the geometries of the component in their current configuration */
getGeometries: (extra?: Struct) => Promise<Geometry[]>;

/**
* Move a base in a straight line by a given distance at a given speed. This
* method blocks until completed or cancelled.
Expand Down
11 changes: 11 additions & 0 deletions src/components/base/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { RobotClient } from '../../robot';
import type { Options, Vector3 } from '../../types';
import { doCommandFromClient } from '../../utils';
import type { Base } from './base';
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';

/**
* A gRPC-web client for the Base component.
Expand All @@ -32,6 +33,16 @@ export class BaseClient implements Base {
this.options = options;
}

async getGeometries(extra = {}, callOptions = this.callOptions) {
const request = new GetGeometriesRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.getGeometries(request, callOptions);
return response.geometries;
}

async moveStraight(
distanceMm: number,
mmPerSec: number,
Expand Down
4 changes: 4 additions & 0 deletions src/components/camera/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
IntrinsicParameters,
} from '../../gen/component/camera/v1/camera_pb';
import type { Resource } from '../../types';
import type { Geometry } from '../../gen/common/v1/common_pb';

export interface Properties {
/** Whether the camera supports the return of point cloud data. */
Expand All @@ -26,6 +27,9 @@ export type MimeType =

/** Represents any physical hardware that can capture frames. */
export interface Camera extends Resource {
/** Get the geometries of the component in their current configuration */
getGeometries: (extra?: Struct) => Promise<Geometry[]>;

/**
* Return a frame from a camera.
*
Expand Down
11 changes: 11 additions & 0 deletions src/components/camera/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { RobotClient } from '../../robot';
import type { Options } from '../../types';
import { doCommandFromClient } from '../../utils';
import type { Camera, MimeType } from './camera';
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';

const PointCloudPCD: MimeType = 'pointcloud/pcd';

Expand All @@ -31,6 +32,16 @@ export class CameraClient implements Camera {
this.options = options;
}

async getGeometries(extra = {}, callOptions = this.callOptions) {
const request = new GetGeometriesRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.getGeometries(request, callOptions);
return response.geometries;
}

async getImage(
mimeType: MimeType = '',
extra = {},
Expand Down
11 changes: 11 additions & 0 deletions src/components/gantry/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { RobotClient } from '../../robot';
import type { Options } from '../../types';
import { doCommandFromClient } from '../../utils';
import type { Gantry } from './gantry';
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';

/**
* A gRPC-web client for the Gantry component.
Expand All @@ -31,6 +32,16 @@ export class GantryClient implements Gantry {
this.options = options;
}

async getGeometries(extra = {}, callOptions = this.callOptions) {
const request = new GetGeometriesRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.getGeometries(request, callOptions);
return response.geometries;
}

async getPosition(extra = {}, callOptions = this.callOptions) {
const request = new GetPositionRequest({
name: this.name,
Expand Down
4 changes: 4 additions & 0 deletions src/components/gantry/gantry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type { Struct } from '@bufbuild/protobuf';
import type { Resource } from '../../types';
import type { Geometry } from '../../gen/common/v1/common_pb';

/** Represents a physical gantry that exists in three-dimensional space. */
export interface Gantry extends Resource {
/** Get the geometries of the component in their current configuration */
getGeometries: (extra?: Struct) => Promise<Geometry[]>;

/**
* Move each axis of the gantry to the positionsMm at the speeds in
* speedsMmPerSec
Expand Down
13 changes: 12 additions & 1 deletion src/components/generic/client.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { JsonValue, Struct } from '@bufbuild/protobuf';
import { type JsonValue, Struct } from '@bufbuild/protobuf';
import type { CallOptions, PromiseClient } from '@connectrpc/connect';
import { GenericService } from '../../gen/component/generic/v1/generic_connect';
import type { RobotClient } from '../../robot';
import type { Options } from '../../types';
import { doCommandFromClient } from '../../utils';
import type { Generic } from './generic';
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';

/**
* A gRPC-web client for the Generic component.
Expand All @@ -23,6 +24,16 @@ export class GenericClient implements Generic {
this.options = options;
}

async getGeometries(extra = {}, callOptions = this.callOptions) {
const request = new GetGeometriesRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.getGeometries(request, callOptions);
return response.geometries;
}

async doCommand(
command: Struct,
callOptions = this.callOptions
Expand Down
8 changes: 6 additions & 2 deletions src/components/generic/generic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { Resource } from '../../types';
import type { Geometry } from '../../gen/common/v1/common_pb';
import type { Struct, Resource } from '../../types';

/** Represents a generic component. */
export interface Generic extends Resource {} // eslint-disable-line @typescript-eslint/no-empty-interface
export interface Generic extends Resource {
/** Get the geometries of the component in their current configuration */
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
}
11 changes: 11 additions & 0 deletions src/components/gripper/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { RobotClient } from '../../robot';
import type { Options } from '../../types';
import { doCommandFromClient } from '../../utils';
import type { Gripper } from './gripper';
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';

/**
* A gRPC-web client for the Gripper component.
Expand All @@ -29,6 +30,16 @@ export class GripperClient implements Gripper {
this.options = options;
}

async getGeometries(extra = {}, callOptions = this.callOptions) {
const request = new GetGeometriesRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.getGeometries(request, callOptions);
return response.geometries;
}

async open(extra = {}, callOptions = this.callOptions) {
const request = new OpenRequest({
name: this.name,
Expand Down
4 changes: 4 additions & 0 deletions src/components/gripper/gripper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type { Struct } from '@bufbuild/protobuf';
import type { Resource } from '../../types';
import type { Geometry } from '../../gen/common/v1/common_pb';

/** Represents a physical robotic gripper. */
export interface Gripper extends Resource {
/** Get the geometries of the component in their current configuration */
getGeometries: (extra?: Struct) => Promise<Geometry[]>;

/** Open a gripper of the underlying robot. */
open: (extra?: Struct) => Promise<void>;

Expand Down

0 comments on commit 9e2c5cd

Please sign in to comment.