tpmkms_4wp 9.5.1-beta.9 → 9.6.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.
Files changed (87) hide show
  1. package/common/asking.js +12 -4
  2. package/common/avatar.test.json +1001 -860
  3. package/common/can.instance.json +2162 -5
  4. package/common/can.js +101 -35
  5. package/common/can.test.json +51307 -0
  6. package/common/colors.instance.json +2 -30
  7. package/common/comparable.instance.json +1 -1
  8. package/common/concept.js +25 -27
  9. package/common/concept.test.json +142 -120
  10. package/common/conjunction.test.json +32 -42
  11. package/common/crew.instance.json +163 -113
  12. package/common/dateTimeSelectors.instance.json +2 -2
  13. package/common/dateTimeSelectors.js +3 -3
  14. package/common/dateTimeSelectors.test.json +76935 -35739
  15. package/common/dates.instance.json +0 -84
  16. package/common/dates.test.json +284 -287
  17. package/common/dialogues.js +31 -112
  18. package/common/dialogues.test.json +1171 -996
  19. package/common/dimension.instance.json +21374 -562
  20. package/common/dimension.js +145 -51
  21. package/common/dimension.test.json +8753 -3495
  22. package/common/drone.instance.json +23712 -0
  23. package/common/drone.js +448 -0
  24. package/common/drone.test.json +66665 -0
  25. package/common/edible.instance.json +9 -65
  26. package/common/emotions.instance.json +47 -70
  27. package/common/errors.js +3 -3
  28. package/common/fastfood.instance.json +758 -266
  29. package/common/fastfood.js +7 -7
  30. package/common/fastfood.test.json +6970 -6829
  31. package/common/gdefaults.js +58 -13
  32. package/common/help.js +9 -9
  33. package/common/help.test.json +65 -11
  34. package/common/helpers/dialogues.js +6 -1
  35. package/common/helpers/properties.js +36 -16
  36. package/common/helpers.js +32 -2
  37. package/common/hierarchy.js +3 -1
  38. package/common/kirk.test.json +600 -424
  39. package/common/latin.instance.json +10 -10
  40. package/common/latin.js +5 -5
  41. package/common/length.instance.json +27611 -2889
  42. package/common/length.js +6 -1
  43. package/common/length.test.json +45315 -3925
  44. package/common/math.instance.json +1 -1
  45. package/common/menus.instance.json +4 -7
  46. package/common/menus.js +1 -8
  47. package/common/meta.js +1 -0
  48. package/common/nameable.js +13 -6
  49. package/common/nameable.test.json +436 -0
  50. package/common/numbers.js +1 -1
  51. package/common/ordering.instance.json +4 -2
  52. package/common/ordering.test.json +104 -174
  53. package/common/people.instance.json +60 -315
  54. package/common/pipboy.instance.json +1 -57
  55. package/common/pokemon.instance.json +5 -5
  56. package/common/pressure.instance.json +3959 -1990
  57. package/common/pressure.test.json +433 -477
  58. package/common/properties.instance.json +5 -16
  59. package/common/properties.js +3 -3
  60. package/common/properties.test.json +9565 -6951
  61. package/common/rates.instance.json +59 -0
  62. package/common/rates.js +97 -0
  63. package/common/rates.test.json +27702 -0
  64. package/common/reminders.js +2 -2
  65. package/common/reminders.test.json +64635 -25787
  66. package/common/reports.instance.json +2 -2
  67. package/common/spock.test.json +606 -430
  68. package/common/stm.js +13 -2
  69. package/common/temperature.instance.json +3658 -1689
  70. package/common/temperature.test.json +433 -477
  71. package/common/time.instance.json +24762 -0
  72. package/common/time.js +135 -139
  73. package/common/time.test.json +31876 -3757
  74. package/common/ui.instance.json +2 -5
  75. package/common/ui.js +1 -8
  76. package/common/weight.instance.json +10359 -4077
  77. package/common/weight.test.json +2601 -2263
  78. package/common/words.instance.json +9 -0
  79. package/common/words.js +53 -0
  80. package/common/words.test.json +2 -0
  81. package/common/wp.instance.json +330 -58
  82. package/common/wp.js +4 -0
  83. package/common/wp.test.json +7385 -6906
  84. package/main.js +4 -2
  85. package/package.json +16 -5
  86. package/common/listener.js +0 -50
  87. package/common/listener.test.json +0 -142
@@ -0,0 +1,448 @@
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
+ const { defaultContextCheck, getValue, setValue } = require('./helpers')
3
+ const drone_tests = require('./drone.test.json')
4
+ const drone_instance = require('./drone.instance.json')
5
+ const hierarchy = require('./hierarchy')
6
+ const nameable = require('./nameable')
7
+ const rates = require('./rates')
8
+ const help = require('./help')
9
+
10
+ /*
11
+ todo
12
+
13
+ VOSK
14
+
15
+ https://alphacephei.com/vosk/
16
+
17
+ FreeNode Tank
18
+
19
+ https://docs.freenove.com/projects/fnk0077/en/latest/fnk0077/codes/tutorial/3_Module_test_%28necessary%29.html
20
+ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQFRP1/ref=sr_1_1_sspa?crid=1JT788RT84O8C&dib=eyJ2IjoiMSJ9.1W6XTWnHwPcqZTD8iRfmF7hHwiVycHjB02NHKEcqGfQSUKyJfN0OLyaaoCcypQug_C9CGah-7wLgfAtJRs_JKiwDsqYXqFfvvoU5ETBk_Le-S9Qt4kwh92r0w19bzA5my7aQpT52ssw8-f8Xpzjbqm1uFsLh82jF4V7P8xMKobjVHHILXalReEPuJz2OlF6y_ihwtUuVLDjMkuvNPoK-M7YLntLqKQy229XKjtDSUV4J0YT1L8uLVWHZ-ySs_MmG_w-oyZ9QFIe0a9hJEMuiu_BcaDmxFkwMeGBro2uczAU.NlqF_FH_6PvflZKozPylFlIyKuwx7mAB-jAggC1aPFk&dib_tag=se&keywords=Freenove+Tank+Robot+Kit&qid=1766258114&sprefix=freenove+drone+robot+kit%2Caps%2C130&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1
21
+
22
+
23
+ send commands to arduino from another computer:
24
+
25
+ https://www.npmjs.com/package/johnny-five
26
+
27
+ KEYESTUDIO Mini Tank Robot V2 Smart Car Kit for Arduino
28
+
29
+ https://www.amazon.ca/KEYESTUDIO-Infrared-Ultrasonic-Obstacle-Avoidance/dp/B07X4W7SZ5/ref=sr_1_10?crid=2A71NHZNTAION&dib=eyJ2IjoiMSJ9.W-I4I_tfyGdGt2UrNlNrlFeKnfIwppniNSX5FJndx77Ht944f9RylJD9me0PiqV5V_b185b17BsrPdKxmYYHnJ-Odb7hbdVzKs019mag1nCL-Wqe4aR0IYrEOzJkKTnR4YbXGYwriLd26OBYjhNvgaCFyE5uwsYkAK-qJXI2Xiui19oLiLYrmJvBz0bCHe4s7U6OdmaumYhhfxpVErk1E1zAwxE8kdq_YD7ZCMRjKS9Tr6cbayIh9GKDwMLuW-LCdzOW2eQx-dTB7yXV53rpV34IBAcCE1IgmwwNIIW7E6Y.fdaAuj4qvXq-67f5ktOq7Coo8lggrMiB_TFFtluqDtI&dib_tag=se&keywords=Adafruit+Mini+Round+Robot+Chassis+Kit&qid=1766256581&sprefix=adafruit+mini+round+robot+chassis+kit+%2Caps%2C123&sr=8-10
30
+ https://github.com/ericmend/mini-drone/blob/master/README.md
31
+
32
+
33
+
34
+
35
+ vosk
36
+
37
+ https://github.com/sunfounder/picar-x/tree/v2.0/gpt_examples
38
+ https://github.com/sunfounder/picar-x/tree/v2.0/example
39
+ VOSK: https://docs.sunfounder.com/projects/picar-x-v20/en/latest/ai_interaction/python_voice_control.html
40
+
41
+ DONE why is 3 meters not marker: length its marker dimension
42
+ DONE how to handle time in the testing
43
+ repeat that/what/say again/say that again
44
+ make it say the howToCalibrate right from the start. maybe have some prime it call?!?!?!
45
+ convert from length to a some kind of standard number
46
+ shut up/dont talk/be quiet -> stop saying responses
47
+
48
+ use it to measure distances -> go forward. stop. how far was that
49
+
50
+ call this point a
51
+ move 5 feet
52
+ call this point b
53
+ moving between a and b is called patrol 1
54
+ do patrol 1 every 3 minutes
55
+
56
+ what is patrol 1
57
+
58
+ calibrate distance
59
+ stop
60
+
61
+ go forward slowly
62
+ stop
63
+ that was 2 feet
64
+
65
+ do a circle 2 feet in diameter every 2 minutes
66
+
67
+ this is jeff
68
+ say hi
69
+
70
+
71
+ say your names
72
+ car 1 do patrol one
73
+ car 1 and 2 go to point a
74
+
75
+ who car 1
76
+
77
+ just say the speed
78
+
79
+ go forward 2 meters
80
+
81
+ pan camera left slowly
82
+ do the cylon every 30 seconds
83
+
84
+ patrol one is forward 10 feet left 2 feet right 3 feet and back to the start
85
+ go forward 10 feet then go back to the start
86
+
87
+ go to the last point
88
+ go back 2 positions
89
+ */
90
+
91
+ class API {
92
+ initialize({ objects }) {
93
+ this._objects = objects
94
+ this._objects.defaultTime = { hour: 9, minute: 0, second: 0, millisecond: 0 }
95
+ this._objects.ordinal = 0
96
+ delete this.testDate
97
+
98
+ objects.calibration = {
99
+ startTime: undefined, // start time for calibration
100
+ endTime: undefined, // end time for calibration
101
+ duration: undefined, // end time - start time
102
+ distance: undefined, // distance travelled during calibration in mm
103
+ power: 0.1,
104
+ speed: undefined, // meters per second
105
+ }
106
+ objects.current = {
107
+ // direction: undefined, // direction to go if going
108
+ // power: undefined, // power
109
+ }
110
+ objects.history = []
111
+ objects.isCalibrated = false
112
+ }
113
+
114
+ nextOrdinal() {
115
+ return this._objects.ordinal += 1
116
+ }
117
+
118
+ now() {
119
+ if (this.args.isProcess || this.args.isTest) {
120
+ if (!this.testDate) {
121
+ this.testDate = new Date(2025, 5, 29, 14, 52, 0)
122
+ }
123
+ this.testDate = new Date(this.testDate.getTime() + 1000)
124
+ return this.testDate
125
+ } else {
126
+ return new Date()
127
+ }
128
+ }
129
+
130
+ sendCommand() {
131
+ const command = { power: this._objects.calibration.power, ...this._objects.current }
132
+ switch (command.direction) {
133
+ case 'forward':
134
+ this.forward(command.power)
135
+ break
136
+ case 'backward':
137
+ this.backward(command.power)
138
+ break
139
+ case 'around':
140
+ this.rotate(180)
141
+ break
142
+ }
143
+
144
+ if (command.distance) {
145
+ const distance_meters = command.distance
146
+ const speed_meters_per_second = this._objects.calibration.speed
147
+ const duration_seconds = distance_meters / speed_meters_per_second
148
+ this.pause(duration_seconds)
149
+ this.stop()
150
+ }
151
+ }
152
+
153
+ pause(duration_seconds) {
154
+ this._objects.history.push({ marker: 'history', pause: duration_seconds })
155
+ }
156
+
157
+ // subclass and override the remaining to call the car
158
+
159
+ forward(power) {
160
+ this._objects.history.push({ marker: 'history', direction: 'forward', power })
161
+ }
162
+
163
+ backward(power) {
164
+ this._objects.history.push({ marker: 'history', direction: 'backward', power })
165
+ }
166
+
167
+ // -angle is counterclockwise
168
+ // +angle is clockwise
169
+
170
+ rotate(angle) {
171
+ this._objects.history.push({ marker: 'history', turn: angle })
172
+ }
173
+
174
+ turn(angle) {
175
+ this._objects.runCommand = true
176
+ }
177
+
178
+ tilt_angle(angle) {
179
+ }
180
+
181
+ pan_angle(angle) {
182
+ }
183
+
184
+ stop() {
185
+ this._objects.history.push({ marker: 'history', power: 0 })
186
+ }
187
+ }
188
+
189
+ const howToCalibrate = "When you are ready say calibrate. The drone will drive forward at 10 percent power then say stop. Measure the distance and tell me that. Or you can say the speed of the drone at percentage of power."
190
+
191
+ function askForProperty({
192
+ ask,
193
+ propertyPath,
194
+ contextPath=[],
195
+ query,
196
+ matchr,
197
+ oneShot=false,
198
+ }) {
199
+ ask({
200
+ where: where(),
201
+ oneShot,
202
+
203
+ matchq: ({ api, context, objects }) => !getValue(propertyPath, objects) && context.marker == 'controlEnd',
204
+ applyq: async ({ say, objects }) => {
205
+ return query
206
+ },
207
+
208
+ matchr,
209
+ applyr: async ({objects, context}) => {
210
+ setValue(propertyPath, objects, getValue(contextPath, context))
211
+ },
212
+ })
213
+ }
214
+
215
+ function askForCalibrationDistance(args) {
216
+ askForProperty({
217
+ ...args,
218
+ propertyPath: ['calibration', 'distance'],
219
+ query: "How far did the drone go?",
220
+ matchr: ({context, objects}) => objects.calibration.endTime && context.marker == 'quantity' && context.unit.dimension == 'length',
221
+ })
222
+ }
223
+
224
+ function askForEndTime(args) {
225
+ askForProperty({
226
+ ...args,
227
+ propertyPath: ['calibration', 'endTime'],
228
+ query: "Say stop when the drone has driven enough.",
229
+ matchr: () => false,
230
+ })
231
+ }
232
+
233
+ function askForStartTime(args) {
234
+ askForProperty({
235
+ ...args,
236
+ propertyPath: ['calibration', 'startTime'],
237
+ query: howToCalibrate,
238
+ matchr: () => false,
239
+ })
240
+ }
241
+
242
+ // expectProperty
243
+ function expectDirection(args) {
244
+ args.config.addSemantic({
245
+ match: ({context, isA}) => isA(context.marker, 'direction'),
246
+ apply: ({objects, context}) => {
247
+ objects.runCommand = true
248
+ objects.current.direction = context.marker
249
+ }
250
+ })
251
+ }
252
+
253
+ // expectProperty
254
+ function expectDistanceForCalibration(args) {
255
+ args.config.addSemantic({
256
+ oneShot: true,
257
+ match: ({context, isA, objects}) => isA(context.marker, 'quantity') && !isA(context.unit.marker, 'unitPerUnit') && objects.calibration.startTime,
258
+ apply: async ({context, objects, fragments, e}) => {
259
+ const instantiation = await fragments("quantity in meters", { quantity: context })
260
+ const result = await e(instantiation)
261
+ objects.calibration.distance = result.evalue.amount.evalue.evalue
262
+ }
263
+ })
264
+ }
265
+
266
+ function expectDistanceForMove(args) {
267
+ // TODO save id for recalibration
268
+ args.config.addSemantic({
269
+ match: ({context, isA}) => isA(context.marker, 'quantity') && !isA(context.unit.marker, 'unitPerUnit'),
270
+ apply: async ({context, objects, fragments, e}) => {
271
+ const instantiation = await fragments("quantity in meters", { quantity: context })
272
+ const result = await e(instantiation)
273
+ objects.runCommand = true
274
+ objects.current.distance = result.evalue.amount.evalue.evalue
275
+ }
276
+ })
277
+ }
278
+
279
+ function expectCalibrationCompletion(args) {
280
+ args.config.addSemantic({
281
+ oneShot: true,
282
+ match: ({context, objects, isA}) => context.marker == 'controlEnd' && objects.calibration.distance && objects.calibration.duration && !objects.calibration.speed,
283
+ apply: ({api, context, objects, _continue, say, mentioned}) => {
284
+ objects.calibration.speed = objects.calibration.distance / objects.calibration.duration
285
+ objects.isCalibrated = true
286
+ say(`The drone is calibrated. The speed is ${objects.calibration.speed.toFixed(4)} meters per second at 10 percent power`)
287
+ mentioned({ marker: 'point', ordinal: api.nextOrdinal(), distance: objects.calibration.distance })
288
+ _continue()
289
+ expectDistanceForMove(args)
290
+ }
291
+ })
292
+ }
293
+
294
+ const template = {
295
+ fragments: [
296
+ "quantity in meters",
297
+ "quantity in meters per second",
298
+ ],
299
+ configs: [
300
+ "drone is a concept",
301
+ //TODO "forward left, right, backward are directions",
302
+ "around, forward, left, right, and backward are directions",
303
+ "speed and power are properties",
304
+ "point is a concept",
305
+ // TODO fix/add this "position means point",
306
+ "points are nameable",
307
+ (args) => {
308
+ askForCalibrationDistance(args)
309
+ askForEndTime(args)
310
+ askForStartTime(args)
311
+
312
+ expectDirection(args)
313
+ expectDistanceForCalibration(args)
314
+ expectCalibrationCompletion(args)
315
+
316
+ args.config.addSemantic({
317
+ match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),
318
+ apply: async ({context, objects, api, fragments, e}) => {
319
+ // send a command to the drone
320
+ const instantiation = await fragments("quantity in meters per second", { quantity: context })
321
+ const result = await e(instantiation)
322
+ const desired_speed = result.evalue.amount.evalue.evalue
323
+ const desired_power = objects.calibration.power * (desired_speed / objects.calibration.speed)
324
+ objects.runCommand = true
325
+ objects.current.power = desired_power
326
+ }
327
+ })
328
+
329
+ args.config.addSemantic({
330
+ match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlStart',
331
+ apply: ({context, objects, api}) => {
332
+ objects.runCommand = false
333
+ }
334
+ })
335
+
336
+ args.config.addSemantic({
337
+ // match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && (context.marker == 'controlEnd' || context.marker == 'controlBetween'),
338
+ match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',
339
+ apply: ({context, objects, api}) => {
340
+ // send a command to the drone
341
+ if (objects.runCommand) {
342
+ api.sendCommand()
343
+ }
344
+ }
345
+ })
346
+ },
347
+ {
348
+ operators: [
349
+ "([calibrate])",
350
+ "([turn] (direction))",
351
+ "([pause] ([number]))",
352
+ "([stop] ([drone|])?)",
353
+ "([go])",
354
+ ],
355
+ bridges: [
356
+ { id: "go" },
357
+ {
358
+ id: 'turn',
359
+ isA: ['verb'],
360
+ bridge: "{ ...next(operator), direction: after[0], interpolate: [{ context: operator }, { property: 'direction' }] }",
361
+ semantic: ({context, objects, api}) => {
362
+ objects.runCommand = true
363
+ objects.current.direction = context.direction.marker
364
+ },
365
+ // check: { marker: 'turn', exported: true, extra: ['direction'] }
366
+ },
367
+ {
368
+ id: 'calibrate',
369
+ isA: ['verb'],
370
+ bridge: "{ ...next(operator), interpolate: [{ context: operator }] }",
371
+ semantic: ({context, objects, api, mentioned}) => {
372
+ objects.calibration.startTime = api.now()
373
+ mentioned({ marker: 'point', ordinal: api.nextOrdinal() })
374
+ // send command to drone to go forward
375
+ }
376
+ },
377
+ {
378
+ id: 'pause',
379
+ isA: ['verb'],
380
+ bridge: "{ ...operator, time: after[0], interpolate: [{ context: operator }, { property: 'time' }] }",
381
+ semantic: async ({context}) => {
382
+ // why doesn't nodejs add a sleep function. I always have to look up how to do this because its not fucking memorable.
383
+ // function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
384
+ // await sleep(context.time.value*1000)
385
+ }
386
+ },
387
+ {
388
+ id: 'stop',
389
+ isA: ['verb'],
390
+ optional: {
391
+ 1: "{ marker: 'drone' }",
392
+ },
393
+ bridge: "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
394
+ semantic: ({context, objects, api, say}) => {
395
+ if (!objects.calibration.startTime) {
396
+ // default will say how to calibrate
397
+ } else {
398
+ objects.calibration.endTime = api.now()
399
+ objects.calibration.duration = (objects.calibration.endTime - objects.calibration.startTime)/1000
400
+ }
401
+ }
402
+ },
403
+ ],
404
+ generators: [
405
+ {
406
+ match: ({context}) => context.marker == 'help' && !context.paraphrase && context.isResponse,
407
+ apply: () => ''
408
+ },
409
+ ],
410
+ semantics: [
411
+
412
+ ],
413
+ },
414
+ ],
415
+ }
416
+
417
+ knowledgeModule( {
418
+ config: { name: 'drone' },
419
+ includes: [nameable, hierarchy, rates, help],
420
+ api: () => new API(),
421
+
422
+ module,
423
+ description: 'controlling a drone',
424
+ test: {
425
+ name: './drone.test.json',
426
+ contents: drone_tests,
427
+ checks: {
428
+ context: [
429
+ defaultContextCheck({ marker: 'point', exported: true, extra: ['ordinal', { property: 'stm', check: ['id', 'names'] }] }),
430
+ defaultContextCheck({ marker: 'turn', exported: true, extra: ['direction'] }),
431
+ defaultContextCheck({ marker: 'history', exported: true, extra: ['pause', 'direction', 'power', 'turn'] }),
432
+ defaultContextCheck(),
433
+ ],
434
+ objects: [
435
+ { km: 'stm' },
436
+ { path: ['calibration'] },
437
+ { path: ['history'] },
438
+ { path: ['current'] },
439
+ { path: ['runCommand'] },
440
+ ],
441
+ }
442
+ },
443
+ template: {
444
+ template,
445
+ instance: drone_instance,
446
+ },
447
+
448
+ })