nova-control-node 0.0.7 → 0.0.9
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/README.md +21 -20
- package/dist/nova-control-node.js +36 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,12 +94,13 @@ Controls how servo movements are executed when `withinMS` is specified on a move
|
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
96
96
|
interface NovaController {
|
|
97
|
-
home ():Promise<void>
|
|
98
|
-
shiftHeadTo (
|
|
99
|
-
rollHeadTo (
|
|
100
|
-
pitchHeadTo (
|
|
101
|
-
liftHeadTo (
|
|
102
|
-
rotateBodyTo (
|
|
97
|
+
home (withinMS?:number):Promise<void>
|
|
98
|
+
shiftHeadTo (Angle:number, withinMS?:number):Promise<void>
|
|
99
|
+
rollHeadTo (Angle:number, withinMS?:number):Promise<void>
|
|
100
|
+
pitchHeadTo (Angle:number, withinMS?:number):Promise<void>
|
|
101
|
+
liftHeadTo (Angle:number, withinMS?:number):Promise<void>
|
|
102
|
+
rotateBodyTo (Angle:number, withinMS?:number):Promise<void>
|
|
103
|
+
moveTo (Target:ServoUpdate, withinMS?:number):Promise<void>
|
|
103
104
|
get State ():ServoState
|
|
104
105
|
set State (Update:ServoUpdate)
|
|
105
106
|
sendServoState ():Promise<void>
|
|
@@ -109,12 +110,12 @@ interface NovaController {
|
|
|
109
110
|
|
|
110
111
|
| method / property | description |
|
|
111
112
|
| --- | --- |
|
|
112
|
-
| `home()` | sends all servos to `HomePosition` |
|
|
113
|
-
| `shiftHeadTo(
|
|
114
|
-
| `rollHeadTo(
|
|
115
|
-
| `pitchHeadTo(
|
|
116
|
-
| `liftHeadTo(
|
|
117
|
-
| `rotateBodyTo(
|
|
113
|
+
| `home(withinMS?)` | sends all servos to `HomePosition` |
|
|
114
|
+
| `shiftHeadTo(Angle, withinMS?)` | sets s1 — head forward `> 90°`, back `< 90°` |
|
|
115
|
+
| `rollHeadTo(Angle, withinMS?)` | sets s2 — head clockwise `> 90°`, counter-clockwise `< 90°` |
|
|
116
|
+
| `pitchHeadTo(Angle, withinMS?)` | sets s3 — head up `> 110°`, down toward `40°` |
|
|
117
|
+
| `liftHeadTo(Angle, withinMS?)` | sets s5 — secondary head up/down, range `20°`–`150°` |
|
|
118
|
+
| `rotateBodyTo(Angle, withinMS?)` | sets s4 — rotates the entire body around the Z-axis |
|
|
118
119
|
| `moveTo(Target, withinMS?)` | moves the servos listed in `Target` to their target angles; with `withinMS`, uses the trapezoidal profile |
|
|
119
120
|
| `State` (get) | returns a deep copy of the pending state if any, else the last-sent state |
|
|
120
121
|
| `State` (set) | replaces any pending entry with `Update` merged onto the *last-sent* state (not onto pending); flush with `sendServoState()` |
|
|
@@ -139,16 +140,16 @@ Supported commands:
|
|
|
139
140
|
|
|
140
141
|
| command | description |
|
|
141
142
|
| --- | --- |
|
|
142
|
-
| `home` | send all servos to home positions |
|
|
143
|
-
| `shift-to <
|
|
144
|
-
| `roll-to <
|
|
145
|
-
| `pitch-to <
|
|
146
|
-
| `rotate-to <
|
|
147
|
-
| `lift-to <
|
|
148
|
-
| `move [
|
|
143
|
+
| `home [<within_ms>]` | send all servos to home positions |
|
|
144
|
+
| `shift-to <angle> [<within_ms>]` | s1 — head forward / back |
|
|
145
|
+
| `roll-to <angle> [<within_ms>]` | s2 — head CW / CCW |
|
|
146
|
+
| `pitch-to <angle> [<within_ms>]` | s3 — head up / down |
|
|
147
|
+
| `rotate-to <angle> [<within_ms>]` | s4 — body Z-axis rotation |
|
|
148
|
+
| `lift-to <angle> [<within_ms>]` | s5 — secondary head axis |
|
|
149
|
+
| `move [shift-to <angle>] [roll-to <angle>] [pitch-to <angle>] [rotate-to <angle>] [lift-to <angle>] [within-ms <ms>]` | set multiple servos atomically (e.g. `move shift-to 100 rotate-to 120 within-ms 500`) |
|
|
149
150
|
| `wait <ms>` | pause for the given number of milliseconds |
|
|
150
151
|
|
|
151
|
-
Throws a descriptive error containing the line number if an unknown command or invalid argument is encountered.
|
|
152
|
+
Each command is fully awaited before the next begins. Throws a descriptive error containing the line number if an unknown command or invalid argument is encountered.
|
|
152
153
|
|
|
153
154
|
### Types
|
|
154
155
|
|
|
@@ -157,65 +157,83 @@ async function u(e, t) {
|
|
|
157
157
|
if (r === "" || r.startsWith("#")) continue;
|
|
158
158
|
let a = r.split(/\s+/), o = a[0].toLowerCase();
|
|
159
159
|
switch (!0) {
|
|
160
|
-
case o === "home":
|
|
161
|
-
|
|
160
|
+
case o === "home": {
|
|
161
|
+
let t = a[1] == null ? void 0 : Number(a[1]);
|
|
162
|
+
if (t != null && isNaN(t)) throw Error(`line ${i}: home: within_ms must be a number, got '${a[1]}'`);
|
|
163
|
+
await e.home(t);
|
|
162
164
|
break;
|
|
165
|
+
}
|
|
163
166
|
case o === "shift-to": {
|
|
164
167
|
let t = Number(a[1]);
|
|
165
168
|
if (isNaN(t)) throw Error(`line ${i}: shift-to requires a numeric angle, got '${a[1]}'`);
|
|
166
|
-
|
|
169
|
+
let n = a[2] == null ? void 0 : Number(a[2]);
|
|
170
|
+
if (n != null && isNaN(n)) throw Error(`line ${i}: shift-to: within_ms must be a number, got '${a[2]}'`);
|
|
171
|
+
await e.shiftHeadTo(t, n);
|
|
167
172
|
break;
|
|
168
173
|
}
|
|
169
174
|
case o === "roll-to": {
|
|
170
175
|
let t = Number(a[1]);
|
|
171
176
|
if (isNaN(t)) throw Error(`line ${i}: roll-to requires a numeric angle, got '${a[1]}'`);
|
|
172
|
-
|
|
177
|
+
let n = a[2] == null ? void 0 : Number(a[2]);
|
|
178
|
+
if (n != null && isNaN(n)) throw Error(`line ${i}: roll-to: within_ms must be a number, got '${a[2]}'`);
|
|
179
|
+
await e.rollHeadTo(t, n);
|
|
173
180
|
break;
|
|
174
181
|
}
|
|
175
182
|
case o === "pitch-to": {
|
|
176
183
|
let t = Number(a[1]);
|
|
177
184
|
if (isNaN(t)) throw Error(`line ${i}: pitch-to requires a numeric angle, got '${a[1]}'`);
|
|
178
|
-
|
|
185
|
+
let n = a[2] == null ? void 0 : Number(a[2]);
|
|
186
|
+
if (n != null && isNaN(n)) throw Error(`line ${i}: pitch-to: within_ms must be a number, got '${a[2]}'`);
|
|
187
|
+
await e.pitchHeadTo(t, n);
|
|
179
188
|
break;
|
|
180
189
|
}
|
|
181
190
|
case o === "rotate-to": {
|
|
182
191
|
let t = Number(a[1]);
|
|
183
192
|
if (isNaN(t)) throw Error(`line ${i}: rotate-to requires a numeric angle, got '${a[1]}'`);
|
|
184
|
-
|
|
193
|
+
let n = a[2] == null ? void 0 : Number(a[2]);
|
|
194
|
+
if (n != null && isNaN(n)) throw Error(`line ${i}: rotate-to: within_ms must be a number, got '${a[2]}'`);
|
|
195
|
+
await e.rotateBodyTo(t, n);
|
|
185
196
|
break;
|
|
186
197
|
}
|
|
187
198
|
case o === "lift-to": {
|
|
188
199
|
let t = Number(a[1]);
|
|
189
200
|
if (isNaN(t)) throw Error(`line ${i}: lift-to requires a numeric angle, got '${a[1]}'`);
|
|
190
|
-
|
|
201
|
+
let n = a[2] == null ? void 0 : Number(a[2]);
|
|
202
|
+
if (n != null && isNaN(n)) throw Error(`line ${i}: lift-to: within_ms must be a number, got '${a[2]}'`);
|
|
203
|
+
await e.liftHeadTo(t, n);
|
|
191
204
|
break;
|
|
192
205
|
}
|
|
193
206
|
case o === "move": {
|
|
194
|
-
let t = {};
|
|
207
|
+
let t = {}, n;
|
|
195
208
|
for (let e = 1; e < a.length; e += 2) {
|
|
196
|
-
let
|
|
197
|
-
if (
|
|
198
|
-
|
|
209
|
+
let r = a[e].toLowerCase(), o = Number(a[e + 1]);
|
|
210
|
+
if (r === "within-ms") {
|
|
211
|
+
if (isNaN(o)) throw Error(`line ${i}: within-ms requires a numeric value, got '${a[e + 1]}'`);
|
|
212
|
+
n = o;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
if (isNaN(o)) throw Error(`line ${i}: '${r}' requires a numeric angle, got '${a[e + 1]}'`);
|
|
216
|
+
switch (r) {
|
|
199
217
|
case "shift-to":
|
|
200
|
-
t.s1 =
|
|
218
|
+
t.s1 = o;
|
|
201
219
|
break;
|
|
202
220
|
case "roll-to":
|
|
203
|
-
t.s2 =
|
|
221
|
+
t.s2 = o;
|
|
204
222
|
break;
|
|
205
223
|
case "pitch-to":
|
|
206
|
-
t.s3 =
|
|
224
|
+
t.s3 = o;
|
|
207
225
|
break;
|
|
208
226
|
case "rotate-to":
|
|
209
|
-
t.s4 =
|
|
227
|
+
t.s4 = o;
|
|
210
228
|
break;
|
|
211
229
|
case "lift-to":
|
|
212
|
-
t.s5 =
|
|
230
|
+
t.s5 = o;
|
|
213
231
|
break;
|
|
214
|
-
default: throw Error(`line ${i}: unknown move argument '${
|
|
232
|
+
default: throw Error(`line ${i}: unknown move argument '${r}'`);
|
|
215
233
|
}
|
|
216
234
|
}
|
|
217
235
|
if (Object.keys(t).length === 0) throw Error(`line ${i}: move requires at least one servo argument`);
|
|
218
|
-
e.
|
|
236
|
+
await e.moveTo(t, n);
|
|
219
237
|
break;
|
|
220
238
|
}
|
|
221
239
|
case o === "wait": {
|