Skip to content

Commit 9e2c5cd

Browse files
Add getGeometries calls to components (#471)
Co-authored-by: Zack Porter <[email protected]>
1 parent fa1ed60 commit 9e2c5cd

File tree

13 files changed

+95
-4
lines changed

13 files changed

+95
-4
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/arm/arm.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { PlainMessage, Struct } from '@bufbuild/protobuf';
22
import type { Pose, Resource } from '../../types';
33

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

67
export type ArmJointPositions = PlainMessage<armApi.JointPositions>;
78

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

16+
/** Get the geometries of the component in their current configuration */
17+
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
18+
1519
/**
1620
* Move the end of the arm to the pose.
1721
*

src/components/arm/client.ts

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { RobotClient } from '../../robot';
1414
import type { Options, Pose } from '../../types';
1515
import { doCommandFromClient } from '../../utils';
1616
import type { Arm } from './arm';
17+
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
1718

1819
/**
1920
* A gRPC-web client for the Arm component.
@@ -48,6 +49,16 @@ export class ArmClient implements Arm {
4849
return result;
4950
}
5051

52+
async getGeometries(extra = {}, callOptions = this.callOptions) {
53+
const request = new GetGeometriesRequest({
54+
name: this.name,
55+
extra: Struct.fromJson(extra),
56+
});
57+
58+
const response = await this.client.getGeometries(request, callOptions);
59+
return response.geometries;
60+
}
61+
5162
async moveToPosition(pose: Pose, extra = {}, callOptions = this.callOptions) {
5263
const request = new MoveToPositionRequest({
5364
name: this.name,

src/components/base/base.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import type { Resource, Struct, Vector3 } from '../../types';
22

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

56
export type BaseProperties = baseApi.GetPropertiesResponse;
67

78
export const { GetPropertiesResponse: BaseProperties } = baseApi;
89

910
/** Represents a physical base of a robot. */
11+
1012
export interface Base extends Resource {
13+
/** Get the geometries of the component in their current configuration */
14+
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
15+
1116
/**
1217
* Move a base in a straight line by a given distance at a given speed. This
1318
* method blocks until completed or cancelled.

src/components/base/client.ts

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { RobotClient } from '../../robot';
1414
import type { Options, Vector3 } from '../../types';
1515
import { doCommandFromClient } from '../../utils';
1616
import type { Base } from './base';
17+
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
1718

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

36+
async getGeometries(extra = {}, callOptions = this.callOptions) {
37+
const request = new GetGeometriesRequest({
38+
name: this.name,
39+
extra: Struct.fromJson(extra),
40+
});
41+
42+
const response = await this.client.getGeometries(request, callOptions);
43+
return response.geometries;
44+
}
45+
3546
async moveStraight(
3647
distanceMm: number,
3748
mmPerSec: number,

src/components/camera/camera.ts

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
IntrinsicParameters,
55
} from '../../gen/component/camera/v1/camera_pb';
66
import type { Resource } from '../../types';
7+
import type { Geometry } from '../../gen/common/v1/common_pb';
78

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

2728
/** Represents any physical hardware that can capture frames. */
2829
export interface Camera extends Resource {
30+
/** Get the geometries of the component in their current configuration */
31+
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
32+
2933
/**
3034
* Return a frame from a camera.
3135
*

src/components/camera/client.ts

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { RobotClient } from '../../robot';
1111
import type { Options } from '../../types';
1212
import { doCommandFromClient } from '../../utils';
1313
import type { Camera, MimeType } from './camera';
14+
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
1415

1516
const PointCloudPCD: MimeType = 'pointcloud/pcd';
1617

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

35+
async getGeometries(extra = {}, callOptions = this.callOptions) {
36+
const request = new GetGeometriesRequest({
37+
name: this.name,
38+
extra: Struct.fromJson(extra),
39+
});
40+
41+
const response = await this.client.getGeometries(request, callOptions);
42+
return response.geometries;
43+
}
44+
3445
async getImage(
3546
mimeType: MimeType = '',
3647
extra = {},

src/components/gantry/client.ts

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { RobotClient } from '../../robot';
1313
import type { Options } from '../../types';
1414
import { doCommandFromClient } from '../../utils';
1515
import type { Gantry } from './gantry';
16+
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
1617

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

35+
async getGeometries(extra = {}, callOptions = this.callOptions) {
36+
const request = new GetGeometriesRequest({
37+
name: this.name,
38+
extra: Struct.fromJson(extra),
39+
});
40+
41+
const response = await this.client.getGeometries(request, callOptions);
42+
return response.geometries;
43+
}
44+
3445
async getPosition(extra = {}, callOptions = this.callOptions) {
3546
const request = new GetPositionRequest({
3647
name: this.name,

src/components/gantry/gantry.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import type { Struct } from '@bufbuild/protobuf';
22
import type { Resource } from '../../types';
3+
import type { Geometry } from '../../gen/common/v1/common_pb';
34

45
/** Represents a physical gantry that exists in three-dimensional space. */
56
export interface Gantry extends Resource {
7+
/** Get the geometries of the component in their current configuration */
8+
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
9+
610
/**
711
* Move each axis of the gantry to the positionsMm at the speeds in
812
* speedsMmPerSec

src/components/generic/client.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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 { GenericService } from '../../gen/component/generic/v1/generic_connect';
44
import type { RobotClient } from '../../robot';
55
import type { Options } from '../../types';
66
import { doCommandFromClient } from '../../utils';
77
import type { Generic } from './generic';
8+
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
89

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

27+
async getGeometries(extra = {}, callOptions = this.callOptions) {
28+
const request = new GetGeometriesRequest({
29+
name: this.name,
30+
extra: Struct.fromJson(extra),
31+
});
32+
33+
const response = await this.client.getGeometries(request, callOptions);
34+
return response.geometries;
35+
}
36+
2637
async doCommand(
2738
command: Struct,
2839
callOptions = this.callOptions

src/components/generic/generic.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { Resource } from '../../types';
1+
import type { Geometry } from '../../gen/common/v1/common_pb';
2+
import type { Struct, Resource } from '../../types';
23

34
/** Represents a generic component. */
4-
export interface Generic extends Resource {} // eslint-disable-line @typescript-eslint/no-empty-interface
5+
export interface Generic extends Resource {
6+
/** Get the geometries of the component in their current configuration */
7+
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
8+
}

src/components/gripper/client.ts

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { RobotClient } from '../../robot';
1111
import type { Options } from '../../types';
1212
import { doCommandFromClient } from '../../utils';
1313
import type { Gripper } from './gripper';
14+
import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
1415

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

33+
async getGeometries(extra = {}, callOptions = this.callOptions) {
34+
const request = new GetGeometriesRequest({
35+
name: this.name,
36+
extra: Struct.fromJson(extra),
37+
});
38+
39+
const response = await this.client.getGeometries(request, callOptions);
40+
return response.geometries;
41+
}
42+
3243
async open(extra = {}, callOptions = this.callOptions) {
3344
const request = new OpenRequest({
3445
name: this.name,

src/components/gripper/gripper.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import type { Struct } from '@bufbuild/protobuf';
22
import type { Resource } from '../../types';
3+
import type { Geometry } from '../../gen/common/v1/common_pb';
34

45
/** Represents a physical robotic gripper. */
56
export interface Gripper extends Resource {
7+
/** Get the geometries of the component in their current configuration */
8+
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
9+
610
/** Open a gripper of the underlying robot. */
711
open: (extra?: Struct) => Promise<void>;
812

0 commit comments

Comments
 (0)