tpmkms_4wp 9.5.1-beta.30 → 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.
@@ -1,8 +1,9 @@
1
1
  const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck, getValue, setValue } = require('./helpers')
3
- const tank_tests = require('./tank.test.json')
4
- const tank_instance = require('./tank.instance.json')
3
+ const drone_tests = require('./drone.test.json')
4
+ const drone_instance = require('./drone.instance.json')
5
5
  const hierarchy = require('./hierarchy')
6
+ const nameable = require('./nameable')
6
7
  const rates = require('./rates')
7
8
  const help = require('./help')
8
9
 
@@ -16,7 +17,7 @@ todo
16
17
  FreeNode Tank
17
18
 
18
19
  https://docs.freenove.com/projects/fnk0077/en/latest/fnk0077/codes/tutorial/3_Module_test_%28necessary%29.html
19
- 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+tank+robot+kit%2Caps%2C130&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1
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
20
21
 
21
22
 
22
23
  send commands to arduino from another computer:
@@ -26,7 +27,7 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
26
27
  KEYESTUDIO Mini Tank Robot V2 Smart Car Kit for Arduino
27
28
 
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
29
- https://github.com/ericmend/mini-tank/blob/master/README.md
30
+ https://github.com/ericmend/mini-drone/blob/master/README.md
30
31
 
31
32
 
32
33
 
@@ -49,8 +50,9 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
49
50
  call this point a
50
51
  move 5 feet
51
52
  call this point b
52
- moving between a and b is patrol 1
53
+ moving between a and b is called patrol 1
53
54
  do patrol 1 every 3 minutes
55
+
54
56
  what is patrol 1
55
57
 
56
58
  calibrate distance
@@ -78,12 +80,19 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
78
80
 
79
81
  pan camera left slowly
80
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
81
89
  */
82
90
 
83
91
  class API {
84
92
  initialize({ objects }) {
85
93
  this._objects = objects
86
94
  this._objects.defaultTime = { hour: 9, minute: 0, second: 0, millisecond: 0 }
95
+ this._objects.ordinal = 0
87
96
  delete this.testDate
88
97
 
89
98
  objects.calibration = {
@@ -102,6 +111,10 @@ class API {
102
111
  objects.isCalibrated = false
103
112
  }
104
113
 
114
+ nextOrdinal() {
115
+ return this._objects.ordinal += 1
116
+ }
117
+
105
118
  now() {
106
119
  if (this.args.isProcess || this.args.isTest) {
107
120
  if (!this.testDate) {
@@ -172,7 +185,7 @@ class API {
172
185
  }
173
186
  }
174
187
 
175
- const howToCalibrate = "When you are ready say calibrate. The tank 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 tank at percentage of power."
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."
176
189
 
177
190
  function askForProperty({
178
191
  ask,
@@ -202,7 +215,7 @@ function askForCalibrationDistance(args) {
202
215
  askForProperty({
203
216
  ...args,
204
217
  propertyPath: ['calibration', 'distance'],
205
- query: "How far did the tank go?",
218
+ query: "How far did the drone go?",
206
219
  matchr: ({context, objects}) => objects.calibration.endTime && context.marker == 'quantity' && context.unit.dimension == 'length',
207
220
  })
208
221
  }
@@ -211,7 +224,7 @@ function askForEndTime(args) {
211
224
  askForProperty({
212
225
  ...args,
213
226
  propertyPath: ['calibration', 'endTime'],
214
- query: "Say stop when the tank has driven enough.",
227
+ query: "Say stop when the drone has driven enough.",
215
228
  matchr: () => false,
216
229
  })
217
230
  }
@@ -264,10 +277,11 @@ function expectCalibrationCompletion(args) {
264
277
  args.config.addSemantic({
265
278
  oneShot: true,
266
279
  match: ({context, objects, isA}) => context.marker == 'controlEnd' && objects.calibration.distance && objects.calibration.duration && !objects.calibration.speed,
267
- apply: ({context, objects, _continue, say}) => {
280
+ apply: ({api, context, objects, _continue, say, mentioned}) => {
268
281
  objects.calibration.speed = objects.calibration.distance / objects.calibration.duration
269
282
  objects.isCalibrated = true
270
- say(`The tank is calibrated. The speed is ${objects.calibration.speed.toFixed(4)} meters per second at 10 percent power`)
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 })
271
285
  _continue()
272
286
  expectDistanceForMove(args)
273
287
  }
@@ -280,10 +294,13 @@ const template = {
280
294
  "quantity in meters per second",
281
295
  ],
282
296
  configs: [
283
- "tank is a concept",
297
+ "drone is a concept",
284
298
  //TODO "forward left, right, backward are directions",
285
299
  "around, forward, left, right, and backward are directions",
286
300
  "speed and power are properties",
301
+ "point is a concept",
302
+ // TODO fix/add this "position means point",
303
+ "points are nameable",
287
304
  (args) => {
288
305
  askForCalibrationDistance(args)
289
306
  askForEndTime(args)
@@ -296,7 +313,7 @@ const template = {
296
313
  args.config.addSemantic({
297
314
  match: ({context, isA}) => isA(context.marker, 'quantity') && isA(context.unit.marker, 'unitPerUnit'),
298
315
  apply: async ({context, objects, api, fragments, e}) => {
299
- // send a command to the tank
316
+ // send a command to the drone
300
317
  const instantiation = await fragments("quantity in meters per second", { quantity: context })
301
318
  const result = await e(instantiation)
302
319
  const desired_speed = result.evalue.amount.evalue.evalue
@@ -308,7 +325,7 @@ const template = {
308
325
  args.config.addSemantic({
309
326
  match: ({context, objects, isA}) => objects.current.direction && objects.isCalibrated && context.marker == 'controlEnd',
310
327
  apply: ({context, objects, api}) => {
311
- // send a command to the tank
328
+ // send a command to the drone
312
329
  api.sendCommand()
313
330
  }
314
331
  })
@@ -318,7 +335,7 @@ const template = {
318
335
  "([calibrate])",
319
336
  "([turn] (direction))",
320
337
  "([pause] ([number]))",
321
- "([stop] ([tank|])?)",
338
+ "([stop] ([drone|])?)",
322
339
  "([go])",
323
340
  ],
324
341
  bridges: [
@@ -336,9 +353,10 @@ const template = {
336
353
  id: 'calibrate',
337
354
  isA: ['verb'],
338
355
  bridge: "{ ...next(operator), interpolate: [{ context: operator }] }",
339
- semantic: ({context, objects, api}) => {
356
+ semantic: ({context, objects, api, mentioned}) => {
340
357
  objects.calibration.startTime = api.now()
341
- // send command to tank to go forward
358
+ mentioned({ marker: 'point', ordinal: api.nextOrdinal() })
359
+ // send command to drone to go forward
342
360
  }
343
361
  },
344
362
  {
@@ -355,7 +373,7 @@ const template = {
355
373
  id: 'stop',
356
374
  isA: ['verb'],
357
375
  optional: {
358
- 1: "{ marker: 'tank' }",
376
+ 1: "{ marker: 'drone' }",
359
377
  },
360
378
  bridge: "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
361
379
  semantic: ({context, objects, api, say}) => {
@@ -379,30 +397,33 @@ const template = {
379
397
  }
380
398
 
381
399
  knowledgeModule( {
382
- config: { name: 'tank' },
383
- includes: [hierarchy, rates, help],
400
+ config: { name: 'drone' },
401
+ includes: [nameable, hierarchy, rates, help],
384
402
  api: () => new API(),
385
403
 
386
404
  module,
387
- description: 'controlling a tank',
405
+ description: 'controlling a drone',
388
406
  test: {
389
- name: './tank.test.json',
390
- contents: tank_tests,
407
+ name: './drone.test.json',
408
+ contents: drone_tests,
391
409
  checks: {
392
410
  context: [
411
+ defaultContextCheck({ marker: 'point', exported: true, extra: ['ordinal'] }),
393
412
  defaultContextCheck({ marker: 'turn', exported: true, extra: ['direction'] }),
394
413
  defaultContextCheck(),
395
414
  ],
396
415
  objects: [
397
- 'calibration',
398
- 'history',
399
- 'current',
416
+ { km: 'stm' },
417
+ { path: ['calibration'] },
418
+ { path: ['history'] },
419
+ { path: ['current'] },
420
+ // defaultContextCheck(['calibration', 'history', 'current']),
400
421
  ],
401
422
  }
402
423
  },
403
424
  template: {
404
425
  template,
405
- instance: tank_instance,
426
+ instance: drone_instance,
406
427
  },
407
428
 
408
429
  })