Skip to content

Commit 4331646

Browse files
viambotgithub-actions[bot]
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit d138e3d
1 parent 369de2e commit 4331646

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/components/gantry/client.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +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';
16+
import { GetGeometriesRequest, GetKinematicsRequest } from '../../gen/common/v1/common_pb';
1717

1818
/**
1919
* A gRPC-web client for the Gantry component.
@@ -118,6 +118,20 @@ export class GantryClient implements Gantry {
118118
return resp.isMoving;
119119
}
120120

121+
async getKinematics(extra = {}, callOptions = this.callOptions) {
122+
const request = new GetKinematicsRequest({
123+
name: this.name,
124+
extra: Struct.fromJson(extra)
125+
});
126+
127+
const response = await this.client.getKinematics(callOptions);
128+
129+
const decoder = new TextDecoder('utf8');
130+
const jsonString = decoder.decode(response.kinematicsData);
131+
132+
return JSON.parse(jsonString) as ReturnType<Gantry['getKinematics']>;
133+
}
134+
121135
async doCommand(
122136
command: Struct,
123137
callOptions = this.callOptions
@@ -130,4 +144,4 @@ export class GantryClient implements Gantry {
130144
callOptions
131145
);
132146
}
133-
}
147+
}

src/components/gantry/gantry.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Struct } from '@bufbuild/protobuf';
22
import type { Resource } from '../../types';
33
import type { Geometry } from '../../gen/common/v1/common_pb';
4+
import type { JsonValue } from 'type-fest';
45

56
/** Represents a physical gantry that exists in three-dimensional space. */
67
export interface Gantry extends Resource {
@@ -144,4 +145,24 @@ export interface Gantry extends Resource {
144145
* API](https://docs.viam.com/dev/reference/apis/components/gantry/#ismoving).
145146
*/
146147
isMoving: () => Promise<boolean>;
147-
}
148+
149+
/**
150+
* Get the kinematics of the gantry. This will return the URDF for the gantry.
151+
*
152+
* @example
153+
*
154+
* ```ts
155+
* const gantry = new VIAM.GantryClient(machine, 'my_gantry');
156+
*
157+
* // Get the kinematics of the gantry
158+
* const kinematics = await gantry.getKinematics();
159+
* console.log(kinematics);
160+
* ```
161+
*
162+
* For more information, see [Gantry
163+
* API](https://docs.viam.com/dev/reference/apis/components/gantry/#getkinematics).
164+
*
165+
* @returns The kinematics of the gantry as a JSON object.
166+
*/
167+
getKinematics: (extra?: Struct) => Promise<JsonValue>;
168+
}

0 commit comments

Comments
 (0)