@viamrobotics/sdk 0.38.1 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-version.d.ts +1 -1
- package/dist/app/app-client.d.ts +651 -12
- package/dist/app/billing-client.d.ts +54 -0
- package/dist/app/data-client.d.ts +336 -10
- package/dist/app/ml-training-client.d.ts +94 -0
- package/dist/components/arm/arm.d.ts +82 -7
- package/dist/components/base/base.d.ts +106 -4
- package/dist/components/board/board.d.ts +119 -2
- package/dist/components/button/button.d.ts +12 -1
- package/dist/components/camera/camera.d.ts +51 -2
- package/dist/components/encoder/encoder.d.ts +36 -2
- package/dist/components/gantry/gantry.d.ts +84 -6
- package/dist/components/generic/generic.d.ts +16 -1
- package/dist/components/gripper/gripper.d.ts +62 -5
- package/dist/components/input-controller/input-controller.d.ts +36 -2
- package/dist/components/motor/motor.d.ts +108 -4
- package/dist/components/movement-sensor/movement-sensor.d.ts +114 -10
- package/dist/components/power-sensor/power-sensor.d.ts +54 -4
- package/dist/components/sensor/sensor.d.ts +12 -1
- package/dist/components/servo/servo.d.ts +54 -4
- package/dist/components/switch/switch.d.ts +49 -3
- package/dist/gen/app/data/v1/data_pb.d.ts +81 -0
- package/dist/gen/app/v1/app_pb.d.ts +45 -0
- package/dist/gen/app/v1/billing_connect.d.ts +23 -1
- package/dist/gen/app/v1/billing_pb.d.ts +91 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.es.js +5940 -4409
- package/dist/main.umd.js +7 -7
- package/dist/robot/client.d.ts +28 -2
- package/dist/robot/robot.d.ts +80 -8
- package/dist/services/data-manager/client.d.ts +32 -0
- package/dist/services/ml-model/client.d.ts +13 -0
- package/dist/services/ml-model/index.d.ts +2 -0
- package/dist/services/ml-model/ml-model.d.ts +7 -0
- package/dist/services/vision/vision.d.ts +77 -0
- package/dist/types.d.ts +9 -0
- package/package.json +1 -1
|
@@ -3,11 +3,105 @@ import { ModelType, TrainingStatus } from '../gen/app/mltraining/v1/ml_training_
|
|
|
3
3
|
export declare class MlTrainingClient {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(transport: Transport);
|
|
6
|
+
/**
|
|
7
|
+
* Submit a training job.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* await mlTrainingClient.submitTrainingJob(
|
|
13
|
+
* '<organization-id>',
|
|
14
|
+
* '<dataset-id>',
|
|
15
|
+
* '<your-model-name>',
|
|
16
|
+
* '1.0.0',
|
|
17
|
+
* ModelType.SINGLE_LABEL_CLASSIFICATION,
|
|
18
|
+
* ['tag1', 'tag2']
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param organizationId - The organization ID.
|
|
23
|
+
* @param datasetId - The dataset ID.
|
|
24
|
+
* @param modelName - The model name.
|
|
25
|
+
* @param modelVersion - The model version.
|
|
26
|
+
* @param modelType - The model type.
|
|
27
|
+
* @param tags - The tags.
|
|
28
|
+
*/
|
|
6
29
|
submitTrainingJob(organizationId: string, datasetId: string, modelName: string, modelVersion: string, modelType: ModelType, tags: string[]): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Submit a training job from a custom training script.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* await mlTrainingClient.submitCustomTrainingJob(
|
|
37
|
+
* '<organization-id>',
|
|
38
|
+
* '<dataset-id>',
|
|
39
|
+
* 'viam:classification-tflite',
|
|
40
|
+
* '1.0.0',
|
|
41
|
+
* '<your-model-name>',
|
|
42
|
+
* '1.0.0'
|
|
43
|
+
* );
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param organizationId - The organization ID.
|
|
47
|
+
* @param datasetId - The dataset ID.
|
|
48
|
+
* @param registryItemId - The registry item ID.
|
|
49
|
+
* @param registryItemVersion - The registry item version.
|
|
50
|
+
* @param modelName - The model name.
|
|
51
|
+
* @param modelVersion - The model version.
|
|
52
|
+
*/
|
|
7
53
|
submitCustomTrainingJob(organizationId: string, datasetId: string, registryItemId: string, registryItemVersion: string, modelName: string, modelVersion: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Get a training job metadata.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const job = await mlTrainingClient.getTrainingJob('<training-job-id>');
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param id - The training job ID.
|
|
64
|
+
*/
|
|
8
65
|
getTrainingJob(id: string): Promise<import("../gen/app/mltraining/v1/ml_training_pb").TrainingJobMetadata | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* List training jobs.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* const jobs = await mlTrainingClient.listTrainingJobs(
|
|
73
|
+
* '<organization-id>',
|
|
74
|
+
* TrainingStatus.RUNNING
|
|
75
|
+
* );
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @param organizationId - The organization ID.
|
|
79
|
+
* @param status - The training job status.
|
|
80
|
+
*/
|
|
9
81
|
listTrainingJobs(organizationId: string, status: TrainingStatus): Promise<import("../gen/app/mltraining/v1/ml_training_pb").TrainingJobMetadata[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Cancel a training job.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* await mlTrainingClient.cancelTrainingJob('<training-job-id>');
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param id - The training job ID.
|
|
92
|
+
*/
|
|
10
93
|
cancelTrainingJob(id: string): Promise<null>;
|
|
94
|
+
/**
|
|
95
|
+
* Delete a completed training job.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* await mlTrainingClient.deleteCompletedTrainingJob('<training-job-id>');
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param id - The training job ID.
|
|
104
|
+
*/
|
|
11
105
|
deleteCompletedTrainingJob(id: string): Promise<null>;
|
|
12
106
|
}
|
|
13
107
|
export { ModelType, TrainingStatus, } from '../gen/app/mltraining/v1/ml_training_pb';
|
|
@@ -6,27 +6,102 @@ export type ArmJointPositions = PlainMessage<armApi.JointPositions>;
|
|
|
6
6
|
export declare const ArmJointPositions: typeof armApi.JointPositions;
|
|
7
7
|
/** Represents a physical robot arm that exists in three-dimensional space. */
|
|
8
8
|
export interface Arm extends Resource {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Get the position of the end of the arm expressed as a pose
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
16
|
+
* const pose = await arm.getEndPosition();
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
10
19
|
getEndPosition: (extra?: Struct) => Promise<Pose>;
|
|
11
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Get the geometries of the component in their current configuration
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
27
|
+
* const geometries = await arm.getGeometries();
|
|
28
|
+
* console.log(geometries);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
12
31
|
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
|
|
13
32
|
/**
|
|
14
33
|
* Move the end of the arm to the pose.
|
|
15
34
|
*
|
|
35
|
+
* @example
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
39
|
+
*
|
|
40
|
+
* // Create a pose for the arm to move to
|
|
41
|
+
* const pose: Pose = {
|
|
42
|
+
* x: -500,
|
|
43
|
+
* y: -200,
|
|
44
|
+
* z: 62,
|
|
45
|
+
* oX: 1,
|
|
46
|
+
* oY: 0,
|
|
47
|
+
* oZ: 1,
|
|
48
|
+
* theta: 90,
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* // Move the arm to the pose
|
|
52
|
+
* await arm.moveToPosition(pose);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
16
55
|
* @param pose - The destination pose for the arm.
|
|
17
56
|
*/
|
|
18
57
|
moveToPosition: (pose: Pose, extra?: Struct) => Promise<void>;
|
|
19
58
|
/**
|
|
20
|
-
* Move each joint of the arm based on the angles on the joint
|
|
21
|
-
*
|
|
59
|
+
* Move each joint of the arm based on the angles on the joint positions.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
65
|
+
*
|
|
66
|
+
* // Move an arm with 6 joints (6 DoF)
|
|
67
|
+
* await arm.moveToJointPositions([90, 0, 0, 0, 15, 0]);
|
|
68
|
+
* ```
|
|
22
69
|
*
|
|
23
70
|
* @param jointPositionsList - List of angles (0-360) to move each joint to.
|
|
24
71
|
*/
|
|
25
72
|
moveToJointPositions: (jointPositionsList: number[], extra?: Struct) => Promise<void>;
|
|
26
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Gets the current position of each joint.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
80
|
+
* const jointPositions = await arm.getJointPositions();
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
27
83
|
getJointPositions: (extra?: Struct) => Promise<ArmJointPositions>;
|
|
28
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Stop the motion of the arm.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
91
|
+
* await arm.stop();
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
29
94
|
stop: (extra?: Struct) => Promise<void>;
|
|
30
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Get if the arm is currently moving.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
*
|
|
100
|
+
* ```ts
|
|
101
|
+
* const arm = new VIAM.ArmClient(machine, 'my_arm');
|
|
102
|
+
* const isMoving = await arm.isMoving();
|
|
103
|
+
* console.log(isMoving);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
31
106
|
isMoving: () => Promise<boolean>;
|
|
32
107
|
}
|
|
@@ -5,12 +5,33 @@ export type BaseProperties = baseApi.GetPropertiesResponse;
|
|
|
5
5
|
export declare const BaseProperties: typeof baseApi.GetPropertiesResponse;
|
|
6
6
|
/** Represents a physical base of a robot. */
|
|
7
7
|
export interface Base extends Resource {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Get the geometries of the component in their current configuration
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
15
|
+
* const geometries = await base.getGeometries();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
9
18
|
getGeometries: (extra?: Struct) => Promise<Geometry[]>;
|
|
10
19
|
/**
|
|
11
20
|
* Move a base in a straight line by a given distance at a given speed. This
|
|
12
21
|
* method blocks until completed or cancelled.
|
|
13
22
|
*
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
27
|
+
*
|
|
28
|
+
* // Move forward 40mm at 90mm/s
|
|
29
|
+
* await base.moveStraight(40, 90);
|
|
30
|
+
*
|
|
31
|
+
* // Move backward 40mm at -90mm/s (backwards)
|
|
32
|
+
* await base.moveStraight(40, -90);
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
14
35
|
* @param distanceMm - Distance to move, in millimeters.
|
|
15
36
|
* @param mmPerSec - Movement speed, in millimeters per second.
|
|
16
37
|
*/
|
|
@@ -19,6 +40,18 @@ export interface Base extends Resource {
|
|
|
19
40
|
* Spin a base by a given angle at a given angular speed. This method blocks
|
|
20
41
|
* until completed or cancelled.
|
|
21
42
|
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
47
|
+
*
|
|
48
|
+
* // Spin 10 degrees clockwise at 15 degrees per second
|
|
49
|
+
* await base.spin(10, 15);
|
|
50
|
+
*
|
|
51
|
+
* // Spin 180 degrees counter-clockwise at 20 degrees per second
|
|
52
|
+
* await base.spin(-180, 20);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
22
55
|
* @param angleDeg - Degrees to spin.
|
|
23
56
|
* @param degsPerSec - Angular speed, in degrees per second.
|
|
24
57
|
*/
|
|
@@ -27,6 +60,36 @@ export interface Base extends Resource {
|
|
|
27
60
|
* Set the linear and angular power of a base from -1 to 1 in terms of power
|
|
28
61
|
* for each direction.
|
|
29
62
|
*
|
|
63
|
+
* @example
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
67
|
+
*
|
|
68
|
+
* // Move forward at 75% power
|
|
69
|
+
* await base.setPower(
|
|
70
|
+
* { x: 0, y: 0.75, z: 0 }, // linear power
|
|
71
|
+
* { x: 0, y: 0, z: 0 } // no rotation
|
|
72
|
+
* );
|
|
73
|
+
*
|
|
74
|
+
* // Move straight back at 100% power
|
|
75
|
+
* await base.setPower(
|
|
76
|
+
* { x: 0, y: -1, z: 0 }, // linear power
|
|
77
|
+
* { x: 0, y: 0, z: 0 } // no rotation
|
|
78
|
+
* );
|
|
79
|
+
*
|
|
80
|
+
* // Turn counter-clockwise at 50% power
|
|
81
|
+
* await base.setPower(
|
|
82
|
+
* { x: 0, y: 0, z: 0 }, // no linear movement
|
|
83
|
+
* { x: 0, y: 0, z: 0.5 } // rotate around z-axis
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* // Turn clockwise at 60% power
|
|
87
|
+
* await base.setPower(
|
|
88
|
+
* { x: 0, y: 0, z: 0 }, // no linear movement
|
|
89
|
+
* { x: 0, y: 0, z: -0.6 } // rotate around z-axis
|
|
90
|
+
* );
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
30
93
|
* @param linear - Desired linear power percentage from -1 to 1.
|
|
31
94
|
* @param angular - Desired angular power percentage from -1 to 1.
|
|
32
95
|
*/
|
|
@@ -34,14 +97,53 @@ export interface Base extends Resource {
|
|
|
34
97
|
/**
|
|
35
98
|
* Set the linear and angular velocity of a base.
|
|
36
99
|
*
|
|
100
|
+
* @example
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
104
|
+
*
|
|
105
|
+
* // Move forward at 50mm/s while spinning 15 degrees per second to the left
|
|
106
|
+
* await base.setVelocity(
|
|
107
|
+
* { x: 0, y: 50, z: 0 }, // linear velocity in mm/s
|
|
108
|
+
* { x: 0, y: 0, z: 15 } // 15 degrees per second counter-clockwise
|
|
109
|
+
* );
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
37
112
|
* @param linear - Desired linear velocity in millimeters per second.
|
|
38
113
|
* @param angular - Desired angular velocity in degrees per second.
|
|
39
114
|
*/
|
|
40
115
|
setVelocity(linear: Vector3, angular: Vector3, extra?: Struct): Promise<void>;
|
|
41
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Stop a base
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
123
|
+
* await base.stop();
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
42
126
|
stop(extra?: Struct): Promise<void>;
|
|
43
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Return true if the base is in motion.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
*
|
|
132
|
+
* ```ts
|
|
133
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
134
|
+
* const moving = await base.isMoving();
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
44
137
|
isMoving(): Promise<boolean>;
|
|
45
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Return the base's properties.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* const base = new VIAM.BaseClient(machine, 'my_base');
|
|
145
|
+
* const properties = await base.getProperties();
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
46
148
|
getProperties(extra?: Struct): Promise<BaseProperties>;
|
|
47
149
|
}
|
|
@@ -14,11 +14,34 @@ export interface Tick {
|
|
|
14
14
|
* components such as analog readers, and digital interrupts.
|
|
15
15
|
*/
|
|
16
16
|
export interface Board extends Resource {
|
|
17
|
+
/**
|
|
18
|
+
* Get the high/low state of the given pin.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
24
|
+
*
|
|
25
|
+
* // Get if it is true or false that the state of the pin is high.
|
|
26
|
+
* const high = await board.getGPIO('15');
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param pin - The pin number.
|
|
30
|
+
*/
|
|
17
31
|
getGPIO(pin: string, extra?: Struct): Promise<boolean>;
|
|
18
32
|
/**
|
|
19
33
|
* Set the high/low state of the given pin of a board.
|
|
20
34
|
*
|
|
21
|
-
* @
|
|
35
|
+
* @example
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
39
|
+
*
|
|
40
|
+
* // Set the pin to high.
|
|
41
|
+
* await board.setGPIO('15', true);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param pin - The pin number.
|
|
22
45
|
* @param high - When true, set the given pin to high. When false, set the
|
|
23
46
|
* given pin to low.
|
|
24
47
|
*/
|
|
@@ -26,13 +49,32 @@ export interface Board extends Resource {
|
|
|
26
49
|
/**
|
|
27
50
|
* Get the duty cycle of the given pin of a board.
|
|
28
51
|
*
|
|
29
|
-
* @
|
|
52
|
+
* @example
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
56
|
+
*
|
|
57
|
+
* // Get the duty cycle of this pin.
|
|
58
|
+
* const dutyCycle = await board.getPWM('15');
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param pin - The pin number.
|
|
30
62
|
* @returns The duty cycle, which is a value from 0 to 1.
|
|
31
63
|
*/
|
|
32
64
|
getPWM(pin: string, extra?: Struct): Promise<number>;
|
|
33
65
|
/**
|
|
34
66
|
* Set the duty cycle of the given pin of a board.
|
|
35
67
|
*
|
|
68
|
+
* @example
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
72
|
+
*
|
|
73
|
+
* // Set the duty cycle to 0.6, meaning that this pin will be in the high state for
|
|
74
|
+
* // 60% of the duration of the PWM interval period.
|
|
75
|
+
* await board.setPWM('15', 0.6);
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
36
78
|
* @param pin - The pin.
|
|
37
79
|
* @param dutyCyclePct - A value from 0 to 1.
|
|
38
80
|
*/
|
|
@@ -40,12 +82,30 @@ export interface Board extends Resource {
|
|
|
40
82
|
/**
|
|
41
83
|
* Get the PWM frequency of the given pin of a board.
|
|
42
84
|
*
|
|
85
|
+
* @example
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
89
|
+
*
|
|
90
|
+
* // Get the PWM frequency of this pin.
|
|
91
|
+
* const freq = await board.getPWMFrequency('15');
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
43
94
|
* @param pin - The pin.
|
|
44
95
|
*/
|
|
45
96
|
getPWMFrequency(pin: string, extra?: Struct): Promise<number>;
|
|
46
97
|
/**
|
|
47
98
|
* Set the PWM frequency of the given pin of a board.
|
|
48
99
|
*
|
|
100
|
+
* @example
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
104
|
+
*
|
|
105
|
+
* // Set the PWM frequency of this pin to 1600 Hz.
|
|
106
|
+
* await board.setPWMFrequency('15', 1600);
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
49
109
|
* @param pin - The pin.
|
|
50
110
|
* @param frequencyHz - The PWM frequency, in hertz. 0 will use the board's
|
|
51
111
|
* default PWM frequency.
|
|
@@ -54,12 +114,33 @@ export interface Board extends Resource {
|
|
|
54
114
|
/**
|
|
55
115
|
* Read the current value of an analog reader of a board.
|
|
56
116
|
*
|
|
117
|
+
* @example
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
121
|
+
*
|
|
122
|
+
* // Get the value of the analog signal "my_example_analog_reader" has most
|
|
123
|
+
* // recently measured.
|
|
124
|
+
* const reading = await board.readAnalogReader(
|
|
125
|
+
* 'my_example_analog_reader'
|
|
126
|
+
* );
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
57
129
|
* @param analogReader - The name of the analog reader.
|
|
58
130
|
*/
|
|
59
131
|
readAnalogReader(analogReader: string, extra?: Struct): Promise<AnalogValue>;
|
|
60
132
|
/**
|
|
61
133
|
* Write an analog value to a pin on the board.
|
|
62
134
|
*
|
|
135
|
+
* @example
|
|
136
|
+
*
|
|
137
|
+
* ```ts
|
|
138
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
139
|
+
*
|
|
140
|
+
* // Write the value 42 to "my_example_analog_writer".
|
|
141
|
+
* await board.writeAnalog('my_example_analog_writer', 42);
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
63
144
|
* @param pin - The pin name.
|
|
64
145
|
* @param value - An integer value to write.
|
|
65
146
|
*/
|
|
@@ -68,12 +149,38 @@ export interface Board extends Resource {
|
|
|
68
149
|
* Return the current value of the interrupt which is based on the type of
|
|
69
150
|
* interrupt.
|
|
70
151
|
*
|
|
152
|
+
* @example
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
156
|
+
*
|
|
157
|
+
* // Get the number of times this DigitalInterrupt has been interrupted with a tick.
|
|
158
|
+
* const count = await board.getDigitalInterruptValue(
|
|
159
|
+
* 'my_example_digital_interrupt'
|
|
160
|
+
* );
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
71
163
|
* @param digitalInterruptName - The name of the digital interrupt.
|
|
72
164
|
*/
|
|
73
165
|
getDigitalInterruptValue(digitalInterruptName: string, extra?: Struct): Promise<number>;
|
|
74
166
|
/**
|
|
75
167
|
* Stream digital interrupt ticks on the board.
|
|
76
168
|
*
|
|
169
|
+
* @example
|
|
170
|
+
*
|
|
171
|
+
* ```ts
|
|
172
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
173
|
+
*
|
|
174
|
+
* // Stream ticks from pins 8 and 11.
|
|
175
|
+
* const ticks = await board.streamTicks(['8', '11']);
|
|
176
|
+
*
|
|
177
|
+
* for await (const tick of ticks) {
|
|
178
|
+
* console.log(
|
|
179
|
+
* `Pin ${tick.pinName} changed to ${tick.high ? 'high' : 'low'} at ${tick.time}`
|
|
180
|
+
* );
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
77
184
|
* @param interrupts - Names of the interrupts to stream.
|
|
78
185
|
* @param queue - Array to put the ticks in.
|
|
79
186
|
*/
|
|
@@ -81,6 +188,16 @@ export interface Board extends Resource {
|
|
|
81
188
|
/**
|
|
82
189
|
* Set power mode of the board.
|
|
83
190
|
*
|
|
191
|
+
* @example
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* const board = new VIAM.BoardClient(machine, 'my_board');
|
|
195
|
+
*
|
|
196
|
+
* // Set the power mode of the board to OFFLINE_DEEP.
|
|
197
|
+
* const duration = new VIAM.Duration({ seconds: 10n });
|
|
198
|
+
* await board.setPowerMode(VIAM.PowerMode.OFFLINE_DEEP, duration);
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
84
201
|
* @param powerMode - The requested power mode.
|
|
85
202
|
* @param duration - The requested duration to stay in power mode.
|
|
86
203
|
*/
|
|
@@ -2,6 +2,17 @@ import type { Struct } from '@bufbuild/protobuf';
|
|
|
2
2
|
import type { Resource } from '../../types';
|
|
3
3
|
/** Represents a physical button. */
|
|
4
4
|
export interface Button extends Resource {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Push the button.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const button = new VIAM.ButtonClient(machine, 'my_button');
|
|
12
|
+
*
|
|
13
|
+
* // Push the button
|
|
14
|
+
* await button.push();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
6
17
|
push: (extra?: Struct) => Promise<void>;
|
|
7
18
|
}
|
|
@@ -20,6 +20,29 @@ export interface Camera extends Resource {
|
|
|
20
20
|
/**
|
|
21
21
|
* Return a frame from a camera.
|
|
22
22
|
*
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const camera = new VIAM.CameraClient(machine, 'my_camera');
|
|
27
|
+
* const image = await camera.getImage();
|
|
28
|
+
*
|
|
29
|
+
* // Convert Uint8Array to base64
|
|
30
|
+
* const base64Image = btoa(
|
|
31
|
+
* Array.from(image)
|
|
32
|
+
* .map((byte) => String.fromCharCode(byte))
|
|
33
|
+
* .join('')
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* // Convert image to base64 and display it
|
|
37
|
+
* const imageElement = document.createElement('img');
|
|
38
|
+
* imageElement.src = `data:image/jpeg;base64,${base64Image}`;
|
|
39
|
+
* const imageContainer = document.getElementById('#imageContainer');
|
|
40
|
+
* if (imageContainer) {
|
|
41
|
+
* imageContainer.innerHTML = '';
|
|
42
|
+
* imageContainer.appendChild(imageElement);
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
23
46
|
* @param mimeType - A specific MIME type to request. This is not necessarily
|
|
24
47
|
* the same type that will be returned.
|
|
25
48
|
*/
|
|
@@ -27,12 +50,38 @@ export interface Camera extends Resource {
|
|
|
27
50
|
/**
|
|
28
51
|
* Render a frame from a camera to an HTTP response.
|
|
29
52
|
*
|
|
53
|
+
* @example
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* const camera = new VIAM.CameraClient(machine, 'my_camera');
|
|
57
|
+
* const mimeType = 'image/jpeg';
|
|
58
|
+
* const image = await camera.renderFrame(mimeType);
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
30
61
|
* @param mimeType - A specific MIME type to request. This is not necessarily
|
|
31
62
|
* the same type that will be returned.
|
|
32
63
|
*/
|
|
33
64
|
renderFrame: (mimeType?: MimeType, extra?: Struct) => Promise<Blob>;
|
|
34
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Return a point cloud from a camera.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const camera = new VIAM.CameraClient(machine, 'my_camera');
|
|
72
|
+
* const pointCloud = await camera.getPointCloud();
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
35
75
|
getPointCloud: (extra?: Struct) => Promise<Uint8Array>;
|
|
36
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Return the camera properties.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* const camera = new VIAM.CameraClient(machine, 'my_camera');
|
|
83
|
+
* const properties = await camera.getProperties();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
37
86
|
getProperties: () => Promise<Properties>;
|
|
38
87
|
}
|
|
@@ -6,14 +6,48 @@ export type EncoderPositionType = encoderApi.PositionType;
|
|
|
6
6
|
export declare const EncoderProperties: typeof encoderApi.GetPropertiesResponse, EncoderPositionType: typeof encoderApi.PositionType;
|
|
7
7
|
/** Represents a physical encoder. */
|
|
8
8
|
export interface Encoder extends Resource {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Set the current position of the encoder as the new zero position.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const encoder = new VIAM.EncoderClient(machine, 'my_encoder');
|
|
16
|
+
*
|
|
17
|
+
* // Reset the zero position of the encoder
|
|
18
|
+
* await encoder.resetPosition();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
10
21
|
resetPosition(extra?: Struct): Promise<void>;
|
|
11
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Return the encoder's properties.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const encoder = new VIAM.EncoderClient(machine, 'my_encoder');
|
|
29
|
+
*
|
|
30
|
+
* // Get whether the encoder returns position in ticks or degrees
|
|
31
|
+
* const properties = await encoder.getProperties();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
12
34
|
getProperties(extra?: Struct): Promise<EncoderProperties>;
|
|
13
35
|
/**
|
|
14
36
|
* Return the current position either in relative units (ticks away from a
|
|
15
37
|
* zero position) or absolute units (degrees along a circle).
|
|
16
38
|
*
|
|
39
|
+
* @example
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* const encoder = new VIAM.EncoderClient(machine, 'my_encoder');
|
|
43
|
+
*
|
|
44
|
+
* // Get the position of the encoder in ticks
|
|
45
|
+
* const [position, posType] = await encoder.getPosition(
|
|
46
|
+
* EncoderPositionType.POSITION_TYPE_TICKS_COUNT
|
|
47
|
+
* );
|
|
48
|
+
* console.log('The encoder position is currently', position, posType);
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
17
51
|
* @param positionType - The type of position the encoder returns (ticks or
|
|
18
52
|
* degrees)
|
|
19
53
|
*/
|