File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import type { RobotClient } from '../../robot';
1313import type { Options } from '../../types' ;
1414import { doCommandFromClient } from '../../utils' ;
1515import 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+ }
Original file line number Diff line number Diff line change 11import type { Struct } from '@bufbuild/protobuf' ;
22import type { Resource } from '../../types' ;
33import 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. */
67export 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+ }
You can’t perform that action at this time.
0 commit comments