tpmkms_4wp 9.5.1-beta.3 → 9.5.1-beta.31

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 (114) hide show
  1. package/common/animals.instance.json +21 -61
  2. package/common/asking.js +112 -102
  3. package/common/avatar.test.json +1001 -860
  4. package/common/can.instance.json +2174 -0
  5. package/common/can.js +254 -0
  6. package/common/can.test.json +51307 -0
  7. package/common/characters.js +3 -3
  8. package/common/colors.instance.json +10 -10
  9. package/common/comparable.instance.json +2 -2
  10. package/common/concept.js +19 -22
  11. package/common/concept.test.json +54 -40
  12. package/common/conjunction.js +13 -5
  13. package/common/conjunction.test.json +32 -42
  14. package/common/crew.instance.json +164 -150
  15. package/common/crew.js +1 -1
  16. package/common/currency.js +1 -1
  17. package/common/dateTimeSelectors.instance.json +2 -2
  18. package/common/dateTimeSelectors.js +3 -3
  19. package/common/dateTimeSelectors.test.json +76935 -35739
  20. package/common/dates.instance.json +3 -3
  21. package/common/dates.test.json +284 -287
  22. package/common/dialogues.js +41 -119
  23. package/common/dialogues.test.json +1171 -996
  24. package/common/dimension.instance.json +21374 -562
  25. package/common/dimension.js +145 -51
  26. package/common/dimension.test.json +8753 -3495
  27. package/common/drone.instance.json +23710 -0
  28. package/common/drone.js +429 -0
  29. package/common/drone.test.json +61113 -0
  30. package/common/edible.instance.json +23 -95
  31. package/common/emotions.instance.json +53 -80
  32. package/common/emotions.js +1 -1
  33. package/common/english_helpers.js +277 -67
  34. package/common/fastfood.instance.json +180 -372
  35. package/common/fastfood.js +4 -4
  36. package/common/fastfood.test.json +6970 -6829
  37. package/common/formulas.instance.json +1 -1
  38. package/common/gdefaults.js +94 -17
  39. package/common/help.js +11 -11
  40. package/common/help.test.json +65 -11
  41. package/common/helpers/concept.js +1 -1
  42. package/common/helpers/conjunction.js +54 -44
  43. package/common/helpers/dateTimeSelectors.js +2 -2
  44. package/common/helpers/dialogues.js +7 -2
  45. package/common/helpers/formulas.js +13 -11
  46. package/common/helpers/menus.js +12 -12
  47. package/common/helpers/meta.js +8 -8
  48. package/common/helpers/properties.js +104 -23
  49. package/common/helpers.js +114 -48
  50. package/common/hierarchy.js +6 -4
  51. package/common/kirk.instance.json +1 -1
  52. package/common/kirk.test.json +600 -424
  53. package/common/latin.instance.json +10 -10
  54. package/common/latin.js +5 -5
  55. package/common/length.instance.json +27612 -2890
  56. package/common/length.js +6 -1
  57. package/common/length.test.json +45315 -3925
  58. package/common/math.instance.json +20 -20
  59. package/common/math.js +45 -44
  60. package/common/menus.instance.json +6 -9
  61. package/common/menus.js +2 -9
  62. package/common/meta.js +50 -33
  63. package/common/nameable.js +13 -6
  64. package/common/nameable.test.json +436 -0
  65. package/common/numbers.js +1 -1
  66. package/common/ordering.instance.json +20 -30
  67. package/common/ordering.js +1 -1
  68. package/common/ordering.test.json +414 -426
  69. package/common/people.instance.json +82 -348
  70. package/common/people.js +1 -1
  71. package/common/people.test.json +952 -681
  72. package/common/pipboy.instance.json +16 -16
  73. package/common/pokemon.instance.json +8 -8
  74. package/common/pokemon.js +1 -1
  75. package/common/pressure.instance.json +3579 -1610
  76. package/common/pressure.test.json +433 -477
  77. package/common/properties.instance.json +6 -17
  78. package/common/properties.js +19 -6
  79. package/common/properties.test.json +8746 -6638
  80. package/common/rates.instance.json +59 -0
  81. package/common/rates.js +97 -0
  82. package/common/rates.test.json +27702 -0
  83. package/common/reminders.js +1 -1
  84. package/common/reminders.test.json +64635 -25787
  85. package/common/reports.instance.json +3 -3
  86. package/common/reports.js +18 -16
  87. package/common/scorekeeper.js +4 -4
  88. package/common/sdefaults.js +22 -2
  89. package/common/spock.instance.json +1 -1
  90. package/common/spock.test.json +606 -430
  91. package/common/stgame.js +1 -1
  92. package/common/stm.js +15 -4
  93. package/common/tell.js +1 -1
  94. package/common/temperature.instance.json +3786 -1705
  95. package/common/temperature.test.json +433 -477
  96. package/common/tester.js +3 -3
  97. package/common/time.instance.json +24762 -0
  98. package/common/time.js +137 -141
  99. package/common/time.test.json +31876 -3757
  100. package/common/tokenize.js +1 -1
  101. package/common/ui.instance.json +2 -5
  102. package/common/ui.js +1 -8
  103. package/common/weight.instance.json +10359 -4077
  104. package/common/weight.test.json +2601 -2263
  105. package/common/words.instance.json +9 -0
  106. package/common/words.js +53 -0
  107. package/common/words.test.json +2 -0
  108. package/common/wp.instance.json +336 -8
  109. package/common/wp.js +8 -4
  110. package/common/wp.test.json +7385 -6906
  111. package/main.js +4 -2
  112. package/package.json +18 -5
  113. package/common/listener.js +0 -50
  114. package/common/listener.test.json +0 -142
@@ -0,0 +1,429 @@
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({ pause: duration_seconds })
155
+ }
156
+
157
+ // subclass and override the remaining to call the car
158
+
159
+ forward(power) {
160
+ this._objects.history.push({ direction: 'forward', power })
161
+ }
162
+
163
+ backward(power) {
164
+ this._objects.history.push({ direction: 'backward', power })
165
+ }
166
+
167
+ // -angle is counterclockwise
168
+ // +angle is clockwise
169
+
170
+ rotate(angle) {
171
+ this._objects.history.push({ turn: angle })
172
+ }
173
+
174
+ turn(angle) {
175
+ }
176
+
177
+ tilt_angle(angle) {
178
+ }
179
+
180
+ pan_angle(angle) {
181
+ }
182
+
183
+ stop() {
184
+ this._objects.history.push({ power: 0 })
185
+ }
186
+ }
187
+
188
+ 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."
189
+
190
+ function askForProperty({
191
+ ask,
192
+ propertyPath,
193
+ contextPath=[],
194
+ query,
195
+ matchr,
196
+ oneShot=false,
197
+ }) {
198
+ ask({
199
+ where: where(),
200
+ oneShot,
201
+
202
+ matchq: ({ api, context, objects }) => !getValue(propertyPath, objects) && context.marker == 'controlEnd',
203
+ applyq: async ({ say, objects }) => {
204
+ return query
205
+ },
206
+
207
+ matchr,
208
+ applyr: async ({objects, context}) => {
209
+ setValue(propertyPath, objects, getValue(contextPath, context))
210
+ },
211
+ })
212
+ }
213
+
214
+ function askForCalibrationDistance(args) {
215
+ askForProperty({
216
+ ...args,
217
+ propertyPath: ['calibration', 'distance'],
218
+ query: "How far did the drone go?",
219
+ matchr: ({context, objects}) => objects.calibration.endTime && context.marker == 'quantity' && context.unit.dimension == 'length',
220
+ })
221
+ }
222
+
223
+ function askForEndTime(args) {
224
+ askForProperty({
225
+ ...args,
226
+ propertyPath: ['calibration', 'endTime'],
227
+ query: "Say stop when the drone has driven enough.",
228
+ matchr: () => false,
229
+ })
230
+ }
231
+
232
+ function askForStartTime(args) {
233
+ askForProperty({
234
+ ...args,
235
+ propertyPath: ['calibration', 'startTime'],
236
+ query: howToCalibrate,
237
+ matchr: () => false,
238
+ })
239
+ }
240
+
241
+ // expectProperty
242
+ function expectDirection(args) {
243
+ args.config.addSemantic({
244
+ match: ({context, isA}) => isA(context.marker, 'direction'),
245
+ apply: ({objects, context}) => {
246
+ objects.current.direction = context.marker
247
+ }
248
+ })
249
+ }
250
+
251
+ // expectProperty
252
+ function expectDistanceForCalibration(args) {
253
+ args.config.addSemantic({
254
+ oneShot: true,
255
+ match: ({context, isA, objects}) => isA(context.marker, 'quantity') && !isA(context.unit.marker, 'unitPerUnit') && objects.calibration.startTime,
256
+ apply: async ({context, objects, fragments, e}) => {
257
+ const instantiation = await fragments("quantity in meters", { quantity: context })
258
+ const result = await e(instantiation)
259
+ objects.calibration.distance = result.evalue.amount.evalue.evalue
260
+ }
261
+ })
262
+ }
263
+
264
+ function expectDistanceForMove(args) {
265
+ // TODO save id for recalibration
266
+ args.config.addSemantic({
267
+ match: ({context, isA}) => isA(context.marker, 'quantity') && !isA(context.unit.marker, 'unitPerUnit'),
268
+ apply: async ({context, objects, fragments, e}) => {
269
+ const instantiation = await fragments("quantity in meters", { quantity: context })
270
+ const result = await e(instantiation)
271
+ objects.current.distance = result.evalue.amount.evalue.evalue
272
+ }
273
+ })
274
+ }
275
+
276
+ function expectCalibrationCompletion(args) {
277
+ args.config.addSemantic({
278
+ oneShot: true,
279
+ match: ({context, objects, isA}) => context.marker == 'controlEnd' && objects.calibration.distance && objects.calibration.duration && !objects.calibration.speed,
280
+ apply: ({api, context, objects, _continue, say, mentioned}) => {
281
+ objects.calibration.speed = objects.calibration.distance / objects.calibration.duration
282
+ objects.isCalibrated = true
283
+ say(`The drone is calibrated. The speed is ${objects.calibration.speed.toFixed(4)} meters per second at 10 percent power`)
284
+ mentioned({ marker: 'point', ordinal: api.nextOrdinal(), distance: objects.calibration.distance })
285
+ _continue()
286
+ expectDistanceForMove(args)
287
+ }
288
+ })
289
+ }
290
+
291
+ const template = {
292
+ fragments: [
293
+ "quantity in meters",
294
+ "quantity in meters per second",
295
+ ],
296
+ configs: [
297
+ "drone is a concept",
298
+ //TODO "forward left, right, backward are directions",
299
+ "around, forward, left, right, and backward are directions",
300
+ "speed and power are properties",
301
+ "point is a concept",
302
+ // TODO fix/add this "position means point",
303
+ "points are nameable",
304
+ (args) => {
305
+ askForCalibrationDistance(args)
306
+ askForEndTime(args)
307
+ askForStartTime(args)
308
+
309
+ expectDirection(args)
310
+ expectDistanceForCalibration(args)
311
+ expectCalibrationCompletion(args)
312
+
313
+ args.config.addSemantic({
314
+ match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),
315
+ apply: async ({context, objects, api, fragments, e}) => {
316
+ // send a command to the drone
317
+ const instantiation = await fragments("quantity in meters per second", { quantity: context })
318
+ const result = await e(instantiation)
319
+ const desired_speed = result.evalue.amount.evalue.evalue
320
+ const desired_power = objects.calibration.power * (desired_speed / objects.calibration.speed)
321
+ objects.current.power = desired_power
322
+ }
323
+ })
324
+
325
+ args.config.addSemantic({
326
+ match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',
327
+ apply: ({context, objects, api}) => {
328
+ // send a command to the drone
329
+ api.sendCommand()
330
+ }
331
+ })
332
+ },
333
+ {
334
+ operators: [
335
+ "([calibrate])",
336
+ "([turn] (direction))",
337
+ "([pause] ([number]))",
338
+ "([stop] ([drone|])?)",
339
+ "([go])",
340
+ ],
341
+ bridges: [
342
+ { id: "go" },
343
+ {
344
+ id: 'turn',
345
+ isA: ['verb'],
346
+ bridge: "{ ...next(operator), direction: after[0], interpolate: [{ context: operator }, { property: 'direction' }] }",
347
+ semantic: ({context, objects, api}) => {
348
+ objects.current.direction = context.direction.marker
349
+ },
350
+ // check: { marker: 'turn', exported: true, extra: ['direction'] }
351
+ },
352
+ {
353
+ id: 'calibrate',
354
+ isA: ['verb'],
355
+ bridge: "{ ...next(operator), interpolate: [{ context: operator }] }",
356
+ semantic: ({context, objects, api, mentioned}) => {
357
+ objects.calibration.startTime = api.now()
358
+ mentioned({ marker: 'point', ordinal: api.nextOrdinal() })
359
+ // send command to drone to go forward
360
+ }
361
+ },
362
+ {
363
+ id: 'pause',
364
+ isA: ['verb'],
365
+ bridge: "{ ...operator, time: after[0], interpolate: [{ context: operator }, { property: 'time' }] }",
366
+ semantic: async ({context}) => {
367
+ // why doesn't nodejs add a sleep function. I always have to look up how to do this because its not fucking memorable.
368
+ // function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
369
+ // await sleep(context.time.value*1000)
370
+ }
371
+ },
372
+ {
373
+ id: 'stop',
374
+ isA: ['verb'],
375
+ optional: {
376
+ 1: "{ marker: 'drone' }",
377
+ },
378
+ bridge: "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
379
+ semantic: ({context, objects, api, say}) => {
380
+ if (!objects.calibration.startTime) {
381
+ // default will say how to calibrate
382
+ } else {
383
+ objects.calibration.endTime = api.now()
384
+ objects.calibration.duration = (objects.calibration.endTime - objects.calibration.startTime)/1000
385
+ }
386
+ }
387
+ },
388
+ ],
389
+ generators: [
390
+ {
391
+ match: ({context}) => context.marker == 'help' && !context.paraphrase && context.isResponse,
392
+ apply: () => ''
393
+ },
394
+ ],
395
+ },
396
+ ],
397
+ }
398
+
399
+ knowledgeModule( {
400
+ config: { name: 'drone' },
401
+ includes: [nameable, hierarchy, rates, help],
402
+ api: () => new API(),
403
+
404
+ module,
405
+ description: 'controlling a drone',
406
+ test: {
407
+ name: './drone.test.json',
408
+ contents: drone_tests,
409
+ checks: {
410
+ context: [
411
+ defaultContextCheck({ marker: 'point', exported: true, extra: ['ordinal'] }),
412
+ defaultContextCheck({ marker: 'turn', exported: true, extra: ['direction'] }),
413
+ defaultContextCheck(),
414
+ ],
415
+ objects: [
416
+ { km: 'stm' },
417
+ { path: ['calibration'] },
418
+ { path: ['history'] },
419
+ { path: ['current'] },
420
+ // defaultContextCheck(['calibration', 'history', 'current']),
421
+ ],
422
+ }
423
+ },
424
+ template: {
425
+ template,
426
+ instance: drone_instance,
427
+ },
428
+
429
+ })