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 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 (Degrees:number):Promise<void>
94
- rollHeadTo (Degrees:number):Promise<void>
95
- pitchHeadTo (Degrees:number):Promise<void>
96
- liftHeadTo (Degrees:number):Promise<void>
97
- rotateBodyTo (Degrees:number):Promise<void>
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(Degrees)` | sets s1 — head forward `> 90°`, back `< 90°` |
109
- | `rollHeadTo(Degrees)` | sets s2 — head clockwise `> 90°`, counter-clockwise `< 90°` |
110
- | `pitchHeadTo(Degrees)` | sets s3 — head up `> 110°`, down toward `40°` |
111
- | `liftHeadTo(Degrees)` | sets s5 — secondary head up/down, range `20°`–`150°` |
112
- | `rotateBodyTo(Degrees)` | sets s4 — rotates the entire body around the Z-axis |
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 <deg>` | s1 — head forward / back |
139
- | `roll-to <deg>` | s2 — head CW / CCW |
140
- | `pitch-to <deg>` | s3 — head up / down |
141
- | `rotate-to <deg>` | s4 — body Z-axis rotation |
142
- | `lift-to <deg>` | s5 — secondary head axis |
143
- | `move [key val ]` | set multiple servos atomically (e.g. `move shift-to 100 rotate-to 120`) |
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
- await e.home();
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
- await e.shiftHeadTo(t);
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
- await e.rollHeadTo(t);
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
- await e.pitchHeadTo(t);
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
- await e.rotateBodyTo(t);
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
- await e.liftHeadTo(t);
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 n = a[e].toLowerCase(), r = Number(a[e + 1]);
191
- if (isNaN(r)) throw Error(`line ${i}: '${n}' requires a numeric angle, got '${a[e + 1]}'`);
192
- switch (n) {
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 = r;
212
+ t.s1 = o;
195
213
  break;
196
214
  case "roll-to":
197
- t.s2 = r;
215
+ t.s2 = o;
198
216
  break;
199
217
  case "pitch-to":
200
- t.s3 = r;
218
+ t.s3 = o;
201
219
  break;
202
220
  case "rotate-to":
203
- t.s4 = r;
221
+ t.s4 = o;
204
222
  break;
205
223
  case "lift-to":
206
- t.s5 = r;
224
+ t.s5 = o;
207
225
  break;
208
- default: throw Error(`line ${i}: unknown move argument '${n}'`);
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.State = t, await e.sendServoState();
230
+ await e.moveTo(t, n);
213
231
  break;
214
232
  }
215
233
  case o === "wait": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nova-control-browser",
3
3
  "description": "Control a NOVA DIY Artificial Intelligence Robot by Creoqode from a browser",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "nova",