Skip to content
Draft
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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ update-buf: $(node_modules)
.PHONY: build-buf
build-buf: $(node_modules) clean-buf
$(buf) generate buf.build/googleapis/googleapis
$(buf) generate buf.build/viamrobotics/api:$$(cat api_version.lock) --path common,component,robot,service,app,provisioning,tagger,stream
@if [ -z "$(LOCAL_API_PATH)" ]; then \
echo "using production API"; \
$(buf) generate buf.build/viamrobotics/api:$$(cat api_version.lock) --path common,component,robot,service,app,provisioning,tagger,stream; \
else \
echo "using local API from $(LOCAL_API_PATH)"; \
$(buf) generate $(LOCAL_API_PATH); \
fi
$(buf) generate buf.build/viamrobotics/goutils
$(buf) generate buf.build/grpc/grpc --path grpc/reflection/v1/reflection.proto

Expand Down
16 changes: 15 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 } 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';

export type ArmJointPositions = PlainMessage<armApi.JointPositions>;

Expand Down Expand Up @@ -41,6 +41,20 @@ 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>>;

/**
* Move the end of the arm to the pose.
*
Expand Down
15 changes: 14 additions & 1 deletion src/components/arm/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +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';
import { Get3DModelsRequest, GetGeometriesRequest, type Mesh } from '../../gen/common/v1/common_pb';

/**
* A gRPC-web client for the Arm component.
Expand Down Expand Up @@ -59,6 +59,19 @@ export class ArmClient implements Arm {
return response.geometries;
}

async get3DModels(extra = {}, callOptions = this.callOptions): Promise<Record<string, Mesh>> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const request = new Get3DModelsRequest({
name: this.name,
extra: Struct.fromJson(extra),
});

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const response = await this.client.get3DModels(request, callOptions);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
return response.models;
}

async moveToPosition(pose: Pose, extra = {}, callOptions = this.callOptions) {
const request = new MoveToPositionRequest({
name: this.name,
Expand Down
Loading