Skip to content

Commit 0a377b5

Browse files
authored
feat: add get3DModels api for arm client (#670)
1 parent d3cd908 commit 0a377b5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/components/arm/arm.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { PlainMessage, Struct } from '@bufbuild/protobuf';
22
import type { Pose, Resource, Vector3 } from '../../types';
33

44
import * as armApi from '../../gen/component/arm/v1/arm_pb';
5-
import type { Geometry } from '../../gen/common/v1/common_pb';
5+
import type { Geometry, Mesh } from '../../gen/common/v1/common_pb';
66
import type { Frame } from '../../gen/app/v1/robot_pb';
77

88
export type ArmJointPositions = PlainMessage<armApi.JointPositions>;
@@ -42,6 +42,19 @@ export interface Arm extends Resource {
4242
*/
4343
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
4444

45+
/**
46+
* Get the 3D models of the component
47+
*
48+
* @example
49+
*
50+
* ```ts
51+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
52+
* const models = await arm.get3DModels();
53+
* console.log(models);
54+
* ```
55+
*/
56+
get3DModels: (extra?: Struct) => Promise<Record<string, Mesh>>;
57+
4558
/**
4659
* Get the kinematics information associated with the arm.
4760
*

src/components/arm/client.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import type { Arm } from './arm';
1717
import {
1818
GetGeometriesRequest,
1919
GetKinematicsRequest,
20+
Get3DModelsRequest,
21+
Mesh,
2022
} from '../../gen/common/v1/common_pb';
2123

2224
/**
@@ -62,6 +64,19 @@ export class ArmClient implements Arm {
6264
return response.geometries;
6365
}
6466

67+
async get3DModels(
68+
extra = {},
69+
callOptions = this.callOptions
70+
): Promise<Record<string, Mesh>> {
71+
const request = new Get3DModelsRequest({
72+
name: this.name,
73+
extra: Struct.fromJson(extra),
74+
});
75+
76+
const response = await this.client.get3DModels(request, callOptions);
77+
return response.models;
78+
}
79+
6580
async getKinematics(extra = {}, callOptions = this.callOptions) {
6681
const request = new GetKinematicsRequest({
6782
name: this.name,

0 commit comments

Comments
 (0)