forked from viamrobotics/viam-typescript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservo.ts
79 lines (75 loc) · 2.05 KB
/
servo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import type { Struct } from '@bufbuild/protobuf';
import type { Resource } from '../../types';
/** Represents a physical servo. */
export interface Servo extends Resource {
/**
* Move the servo by a given angle in degrees.
*
* @example
*
* ```ts
* const servo = new VIAM.ServoClient(machine, 'my_servo');
*
* // Move the servo from its origin to the desired angle of 10 degrees
* await servo.move(10);
*
* // Move the servo from its origin to the desired angle of 90 degrees
* await servo.move(90);
* ```
*
* For more information, see [Servo
* API](https://docs.viam.com/dev/reference/apis/components/servo/#move).
*/
move(angleDeg: number, extra?: Struct): Promise<void>;
/**
* Return the current set angle of the servo in degrees.
*
* @example
*
* ```ts
* const servo = new VIAM.ServoClient(machine, 'my_servo');
*
* // Get the current set angle of the servo
* const pos = await servo.getPosition();
* ```
*
* For more information, see [Servo
* API](https://docs.viam.com/dev/reference/apis/components/servo/#getposition).
*/
getPosition(extra?: Struct): Promise<number>;
/**
* Stop the servo.
*
* @example
*
* ```ts
* const servo = new VIAM.ServoClient(machine, 'my_servo');
*
* // Move the servo from its origin to the desired angle of 10 degrees
* await servo.move(10);
*
* // Stop the servo. It is assumed that the servo stops moving immediately
* await servo.stop();
* ```
*
* For more information, see [Servo
* API](https://docs.viam.com/dev/reference/apis/components/servo/#stop).
*/
stop(extra?: Struct): Promise<void>;
/**
* Return true if the servo is in motion.
*
* @example
*
* ```ts
* const servo = new VIAM.ServoClient(machine, 'my_servo');
*
* const moving = await servo.isMoving();
* console.log('Moving:', moving);
* ```
*
* For more information, see [Servo
* API](https://docs.viam.com/dev/reference/apis/components/servo/#ismoving).
*/
isMoving(): Promise<boolean>;
}