Skip to content
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
15 changes: 14 additions & 1 deletion src/components/arm/arm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { PlainMessage, Struct } from '@bufbuild/protobuf';
import type { Pose, Resource, Vector3 } from '../../types';

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

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

/**
* Get the 3D models of the component
*
* @example
*
* ```ts
* const arm = new VIAM.ArmClient(machine, 'my_arm');
* const models = await arm.get3DModels();
* console.log(models);
* ```
*/
get3DModels: (extra?: Struct) => Promise<Record<string, Mesh>>;

/**
* Get the kinematics information associated with the arm.
*
Expand Down
15 changes: 15 additions & 0 deletions src/components/arm/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import type { Arm } from './arm';
import {
GetGeometriesRequest,
GetKinematicsRequest,
Get3DModelsRequest,
Mesh,
} from '../../gen/common/v1/common_pb';

/**
Expand Down Expand Up @@ -62,6 +64,19 @@ export class ArmClient implements Arm {
return response.geometries;
}

async get3DModels(
extra = {},
callOptions = this.callOptions
): Promise<Record<string, Mesh>> {
const request = new Get3DModelsRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

const response = await this.client.get3DModels(request, callOptions);
return response.models;
}

async getKinematics(extra = {}, callOptions = this.callOptions) {
const request = new GetKinematicsRequest({
name: this.name,
Expand Down