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