tpmkms 9.6.1 → 9.6.2
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/common/actions.instance.json +99 -0
- package/common/actions.js +67 -0
- package/common/actions.test.json +656 -0
- package/common/angle.instance.json +20 -0
- package/common/colors.instance.json +0 -28
- package/common/compass.instance.json +15 -0
- package/common/dates.instance.json +0 -84
- package/common/dialogues.js +1 -1
- package/common/dimension.instance.json +96 -12
- package/common/dimension.js +12 -3
- package/common/drone.instance.json +10130 -1641
- package/common/drone.js +217 -71
- package/common/drone.test.json +192134 -3455
- package/common/drone_v1.instance.json +38 -31
- package/common/drone_v1.js +20 -15
- package/common/drone_v1.test.json +659 -389
- package/common/edible.instance.json +0 -128
- package/common/fastfood.instance.json +72 -392
- package/common/gdefaults.js +5 -1
- package/common/helpers/conjunction.js +9 -5
- package/common/helpers/drone.js +13 -1
- package/common/length.instance.json +135 -0
- package/common/nameable.js +63 -24
- package/common/nameable.test.json +3270 -3912
- package/common/ordinals.js +13 -0
- package/common/pipboy.instance.json +0 -56
- package/common/pressure.instance.json +20 -0
- package/common/properties.js +16 -6
- package/common/reports.instance.json +1 -1
- package/common/stm.js +119 -25
- package/common/temperature.instance.json +20 -0
- package/common/time.instance.json +45 -0
- package/common/time.test.json +3403 -0
- package/common/weight.instance.json +60 -0
- package/common/wp.instance.json +0 -56
- package/main.js +2 -0
- package/package.json +6 -2
package/common/drone.js
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
|
2
2
|
const { conjugateVerb } = require('./english_helpers')
|
|
3
|
-
const { OverrideCheck, defaultContextCheck, getValue, setValue } = require('./helpers')
|
|
3
|
+
const { OverrideCheck, defaultContextCheckProperties, defaultContextCheck, getValue, setValue } = require('./helpers')
|
|
4
4
|
const drone_tests = require('./drone.test.json')
|
|
5
5
|
const instance = require('./drone.instance.json')
|
|
6
6
|
const hierarchy = require('./hierarchy')
|
|
7
7
|
const ordinals = require('./ordinals')
|
|
8
8
|
const nameable = require('./nameable')
|
|
9
9
|
const compass = require('./compass')
|
|
10
|
+
const actions = require('./actions')
|
|
10
11
|
const angle = require('./angle')
|
|
11
12
|
const rates = require('./rates')
|
|
12
13
|
const help = require('./help')
|
|
13
|
-
const { rotateDelta, degreesToRadians, radiansToDegrees, cartesianToPolar } = require('./helpers/drone')
|
|
14
|
+
const { rotateDelta, degreesToRadians, radiansToDegrees, cartesianToPolar, smallestRotate } = require('./helpers/drone')
|
|
14
15
|
|
|
15
16
|
/*
|
|
16
|
-
|
|
17
|
+
DONE go back
|
|
18
|
+
go back another point
|
|
19
|
+
go back again
|
|
20
|
+
go back to the start
|
|
21
|
+
go back 2 points along route 1
|
|
22
|
+
go to the start of route 2
|
|
23
|
+
|
|
24
|
+
turn left\nturn back
|
|
25
|
+
|
|
26
|
+
do route 1 pausing 10 seconds at each point
|
|
27
|
+
|
|
28
|
+
forward 1 foot\nwest 1 foot\ngo back to the start <<<<<<<< turn the longer way not he shorter way
|
|
29
|
+
forward 1 foot\nwest 1 foot\ncall the path route 1\ngo to the start of route 1\npatrol route 1\npatrol route 1 <<<<< does the patrol more than once
|
|
17
30
|
|
|
31
|
+
?? elipses of the verb go or some kind of conjunction?!?!?
|
|
32
|
+
go forward 1 meter turn right forward 2 meters stop
|
|
33
|
+
|
|
34
|
+
the patrol called patrol 1 is forward 1 meter pause 10 second west 1 meter pause again then back to the start
|
|
35
|
+
|
|
36
|
+
do a 5 second pause at each point / add a 10 second pause to each point / pause of 5 seconds
|
|
18
37
|
|
|
19
38
|
start again / start here / starting here / restart
|
|
20
39
|
again
|
|
21
|
-
go back to the start
|
|
40
|
+
go back to the start => follows path | go to the start => does not follow the path | go to the start following the path
|
|
22
41
|
go back 2 points/turns
|
|
23
42
|
go back and forth to the start!?!?
|
|
24
43
|
|
|
@@ -28,6 +47,7 @@ go 20 percent faster
|
|
|
28
47
|
lower and raise crane
|
|
29
48
|
round to 2 digits
|
|
30
49
|
|
|
50
|
+
DONE turn left go forward 1 foot <- the turn is lost
|
|
31
51
|
DONE call this patrol 1
|
|
32
52
|
DONE call this path patrol 1
|
|
33
53
|
DONE call that patrol 1
|
|
@@ -80,7 +100,6 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
|
|
|
80
100
|
convert from length to a some kind of standard number
|
|
81
101
|
shut up/dont talk/be quiet -> stop saying responses
|
|
82
102
|
|
|
83
|
-
use it to measure distances -> go forward. stop. how far was that
|
|
84
103
|
|
|
85
104
|
call this point a
|
|
86
105
|
move 5 feet
|
|
@@ -102,6 +121,7 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
|
|
|
102
121
|
this is jeff
|
|
103
122
|
say hi
|
|
104
123
|
|
|
124
|
+
use it to measure distances -> go forward. stop. how far was that
|
|
105
125
|
|
|
106
126
|
say your names
|
|
107
127
|
car 1 do patrol one
|
|
@@ -153,7 +173,7 @@ https://www.amazon.ca/Freenove-Raspberry-Tracking-Avoidance-Ultrasonic/dp/B0BNDQ
|
|
|
153
173
|
amke the default speed 2 times faster
|
|
154
174
|
double the default speed
|
|
155
175
|
|
|
156
|
-
what is the speed
|
|
176
|
+
# what is the speed
|
|
157
177
|
use inches per second and repeat that
|
|
158
178
|
*/
|
|
159
179
|
|
|
@@ -290,7 +310,7 @@ class API {
|
|
|
290
310
|
return this._objects.current.ordinal += 1
|
|
291
311
|
}
|
|
292
312
|
|
|
293
|
-
currentPoint() {
|
|
313
|
+
async currentPoint() {
|
|
294
314
|
const current = this._objects.current
|
|
295
315
|
if (current.durationInSeconds) {
|
|
296
316
|
// okay
|
|
@@ -298,7 +318,7 @@ class API {
|
|
|
298
318
|
return null // in motion
|
|
299
319
|
}
|
|
300
320
|
const ordinal = this.currentOrdinal()
|
|
301
|
-
const lastPoint = this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
321
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
302
322
|
if (!current.startTime && !current.endTime && !current.durationInSeconds) {
|
|
303
323
|
return lastPoint // did not move
|
|
304
324
|
}
|
|
@@ -318,8 +338,8 @@ class API {
|
|
|
318
338
|
return { x: xPrime, y: yPrime }
|
|
319
339
|
}
|
|
320
340
|
|
|
321
|
-
markCurrentPoint() {
|
|
322
|
-
const point = this.currentPoint()
|
|
341
|
+
async markCurrentPoint() {
|
|
342
|
+
const point = await this.currentPoint()
|
|
323
343
|
if (!point) {
|
|
324
344
|
return
|
|
325
345
|
}
|
|
@@ -385,30 +405,35 @@ class API {
|
|
|
385
405
|
objects.current.durationInSeconds = distanceMeters / speed_meters_per_second
|
|
386
406
|
await this.pause(objects.current.durationInSeconds, { batched: true })
|
|
387
407
|
await this.stop({ batched: true })
|
|
388
|
-
this.markCurrentPoint()
|
|
408
|
+
await this.markCurrentPoint()
|
|
389
409
|
}
|
|
390
410
|
|
|
391
411
|
if (objects.current.path.length > 0) {
|
|
392
412
|
if (objects.current.timeRepeats) {
|
|
393
413
|
this.startRepeats(objects.current.timeRepeats)
|
|
394
414
|
}
|
|
395
|
-
let currentPoint = this.args.mentions({ context: { marker: 'point' } }).point
|
|
415
|
+
let currentPoint = (await this.args.mentions({ context: { marker: 'point' } })).point
|
|
396
416
|
this._objects.history.push({ marker: 'history', debug: 'doing path' })
|
|
397
|
-
for (const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
// already there
|
|
417
|
+
for (const pathComponent of objects.current.path) {
|
|
418
|
+
if (pathComponent.marker == 'pause') {
|
|
419
|
+
this.pause(pathComponent.pauseSeconds, { batched: true })
|
|
401
420
|
} else {
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
421
|
+
const destinationPoint = pathComponent.point
|
|
422
|
+
if (currentPoint.x == destinationPoint.x && currentPoint.y == destinationPoint.y) {
|
|
423
|
+
// already there
|
|
424
|
+
} else {
|
|
425
|
+
const polar = cartesianToPolar(currentPoint, destinationPoint)
|
|
426
|
+
const destinationAngleInRadians = polar.angle
|
|
427
|
+
// const angleDelta = (destinationAngleInRadians - objects.current.angleInRadians)
|
|
428
|
+
const angleDelta = rotateDelta(objects.current.angleInRadians, destinationAngleInRadians)
|
|
429
|
+
await this.rotate(angleDelta, { batched: true })
|
|
430
|
+
if (!pathComponent .aimOnly) {
|
|
431
|
+
await this.forward(objects.current.speed, { batched: true })
|
|
432
|
+
await stopAtDistance("forward", polar.radius)
|
|
433
|
+
}
|
|
409
434
|
}
|
|
435
|
+
currentPoint = destinationPoint
|
|
410
436
|
}
|
|
411
|
-
currentPoint = destinationPoint
|
|
412
437
|
}
|
|
413
438
|
if (objects.current.timeRepeats) {
|
|
414
439
|
await this.endRepeats()
|
|
@@ -511,6 +536,35 @@ class API {
|
|
|
511
536
|
return time
|
|
512
537
|
}
|
|
513
538
|
|
|
539
|
+
async back(points) {
|
|
540
|
+
const objects = this._objects
|
|
541
|
+
let ordinal
|
|
542
|
+
if (points?.quantity?.value) {
|
|
543
|
+
ordinal = this.currentOrdinal() - points.quantity?.value
|
|
544
|
+
} else {
|
|
545
|
+
ordinal = this.currentOrdinal() - 1
|
|
546
|
+
}
|
|
547
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
548
|
+
if (!lastPoint) {
|
|
549
|
+
this.args.say(`There is no previous point to go back to`)
|
|
550
|
+
return
|
|
551
|
+
}
|
|
552
|
+
objects.current.path.push(lastPoint)
|
|
553
|
+
objects.runCommand = true
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async backAndForth() {
|
|
557
|
+
const objects = this._objects
|
|
558
|
+
const current = objects.current
|
|
559
|
+
current.backAndForth = true
|
|
560
|
+
const ordinal = this.currentOrdinal()
|
|
561
|
+
const currentPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
562
|
+
const lastPoint = await this.args.mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal-1 })
|
|
563
|
+
current.path.push(lastPoint)
|
|
564
|
+
current.path.push(currentPoint)
|
|
565
|
+
objects.runCommand = true
|
|
566
|
+
}
|
|
567
|
+
|
|
514
568
|
async sonic() {
|
|
515
569
|
return await this.sonicDrone()
|
|
516
570
|
}
|
|
@@ -524,7 +578,7 @@ class API {
|
|
|
524
578
|
shortestRotate = shortestRotate + Math.PI*2
|
|
525
579
|
}
|
|
526
580
|
await this.rotateDrone(angleInRadians, options)
|
|
527
|
-
this._objects.current.angleInRadians = (this._objects.current.angleInRadians + angleInRadians)
|
|
581
|
+
this._objects.current.angleInRadians = smallestRotate(this._objects.current.angleInRadians + angleInRadians)
|
|
528
582
|
}
|
|
529
583
|
|
|
530
584
|
async tiltAngle(angle) {
|
|
@@ -571,7 +625,7 @@ class API {
|
|
|
571
625
|
}
|
|
572
626
|
|
|
573
627
|
async pauseDrone(durationInSeconds, options) {
|
|
574
|
-
this._objects.history.push({ marker: 'history', pause: durationInSeconds, ...options })
|
|
628
|
+
this._objects.history.push({ marker: 'history', pause: durationInSeconds, time: this.now(true, durationInSeconds*1000), ...options })
|
|
575
629
|
this.testDate = new Date(this.testDate.getTime() + (durationInSeconds-1)*1000)
|
|
576
630
|
}
|
|
577
631
|
|
|
@@ -585,15 +639,15 @@ class API {
|
|
|
585
639
|
return 1.2
|
|
586
640
|
}
|
|
587
641
|
|
|
588
|
-
now(lookahead = false) {
|
|
642
|
+
now(lookahead = false, pause = 1000) {
|
|
589
643
|
if (this.args.isProcess || this.args.isTest) {
|
|
590
644
|
if (!this.testDate) {
|
|
591
645
|
this.testDate = new Date(2025, 5, 29, 14, 52, 0)
|
|
592
646
|
}
|
|
593
647
|
if (lookahead) {
|
|
594
|
-
return new Date(this.testDate.getTime() +
|
|
648
|
+
return new Date(this.testDate.getTime() + pause)
|
|
595
649
|
} else {
|
|
596
|
-
this.testDate = new Date(this.testDate.getTime() +
|
|
650
|
+
this.testDate = new Date(this.testDate.getTime() + pause)
|
|
597
651
|
return this.testDate
|
|
598
652
|
}
|
|
599
653
|
} else {
|
|
@@ -691,6 +745,7 @@ function expectDistanceForMove(args) {
|
|
|
691
745
|
const template = {
|
|
692
746
|
fragments: [
|
|
693
747
|
"quantity in meters",
|
|
748
|
+
"quantity in seconds",
|
|
694
749
|
"quantity in meters per second",
|
|
695
750
|
"number meters per second",
|
|
696
751
|
"quantity in units",
|
|
@@ -701,13 +756,14 @@ const template = {
|
|
|
701
756
|
configs: [
|
|
702
757
|
"arm, claw and drone are concepts",
|
|
703
758
|
//TODO "forward left, right, backward are directions",
|
|
704
|
-
"around, forward, left, right, and backward are directions",
|
|
759
|
+
"around, forward, left, right, back, forth and backward are directions",
|
|
705
760
|
"paths are nameable and memorable",
|
|
706
761
|
"start and end are properties of path",
|
|
707
762
|
"start and end are points",
|
|
708
763
|
{
|
|
709
764
|
hierarchy: [
|
|
710
765
|
['thisitthat', 'path'],
|
|
766
|
+
['path', 'action'],
|
|
711
767
|
],
|
|
712
768
|
},
|
|
713
769
|
"speed and power are properties",
|
|
@@ -715,7 +771,7 @@ const template = {
|
|
|
715
771
|
"speed is a quantity",
|
|
716
772
|
"point is a concept",
|
|
717
773
|
// TODO fix/add this "position means point",
|
|
718
|
-
"points are nameable orderable and memorable",
|
|
774
|
+
"points are nameable orderable countable and memorable",
|
|
719
775
|
"drone modifies direction",
|
|
720
776
|
(args) => {
|
|
721
777
|
expectDirection(args)
|
|
@@ -753,20 +809,33 @@ const template = {
|
|
|
753
809
|
},
|
|
754
810
|
{
|
|
755
811
|
operators: [
|
|
756
|
-
"([do] (path))",
|
|
812
|
+
// "([do] (path))",
|
|
757
813
|
"([patrol] (path))",
|
|
758
814
|
"([lift|lift,raise] (@<= arm || @<= claw))",
|
|
759
815
|
"([lower] (@<= arm || @<=claw))",
|
|
760
816
|
"([open] (claw))",
|
|
761
817
|
"([close] (claw))",
|
|
762
|
-
"([
|
|
763
|
-
"(
|
|
818
|
+
"([pathComponent])",
|
|
819
|
+
"(<another> (point))",
|
|
764
820
|
// "([turn] (direction))",
|
|
765
|
-
"([pause] ([number]))",
|
|
821
|
+
// "([pause] ([number]))",
|
|
766
822
|
"([stop] ([drone|])?)",
|
|
767
823
|
"([toPoint|to] (point))",
|
|
768
824
|
],
|
|
769
825
|
bridges: [
|
|
826
|
+
{
|
|
827
|
+
id: 'another',
|
|
828
|
+
bridge: `{
|
|
829
|
+
...next(after[0]),
|
|
830
|
+
another: operator,
|
|
831
|
+
after: after[0],
|
|
832
|
+
interpolate: [ { property: 'another' }, { property: 'after' } ]
|
|
833
|
+
}`,
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
id: 'pathComponent',
|
|
837
|
+
children: ['point', 'pause'],
|
|
838
|
+
},
|
|
770
839
|
{
|
|
771
840
|
id: 'patrol',
|
|
772
841
|
isA: ['verb'],
|
|
@@ -789,6 +858,7 @@ const template = {
|
|
|
789
858
|
objects.runCommand = true
|
|
790
859
|
}
|
|
791
860
|
},
|
|
861
|
+
/*
|
|
792
862
|
{
|
|
793
863
|
id: 'do',
|
|
794
864
|
isA: ['verb'],
|
|
@@ -804,6 +874,7 @@ const template = {
|
|
|
804
874
|
objects.runCommand = true
|
|
805
875
|
}
|
|
806
876
|
},
|
|
877
|
+
*/
|
|
807
878
|
{
|
|
808
879
|
id: 'lift',
|
|
809
880
|
isA: ['verb'],
|
|
@@ -845,13 +916,10 @@ const template = {
|
|
|
845
916
|
}
|
|
846
917
|
},
|
|
847
918
|
{
|
|
848
|
-
id:
|
|
919
|
+
id: 'back',
|
|
849
920
|
isA: ['noun'],
|
|
850
|
-
semantic: async ({objects, mentions, api, e, context}) => {
|
|
851
|
-
|
|
852
|
-
const ordinal = api.currentOrdinal() - 1
|
|
853
|
-
const lastPoint = mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
854
|
-
objects.current.path.push(lastPoint)
|
|
921
|
+
semantic: async ({objects, mentions, api, e, context, say}) => {
|
|
922
|
+
await api.back()
|
|
855
923
|
}
|
|
856
924
|
},
|
|
857
925
|
{
|
|
@@ -872,32 +940,43 @@ const template = {
|
|
|
872
940
|
{
|
|
873
941
|
id: "go",
|
|
874
942
|
level: 0,
|
|
875
|
-
|
|
943
|
+
// convolution: true,
|
|
944
|
+
isA: ['verb', 'action'],
|
|
876
945
|
words: [
|
|
877
946
|
...conjugateVerb('go'),
|
|
878
947
|
],
|
|
948
|
+
check: defaultContextCheckProperties(['direction', 'distance', 'to']),
|
|
879
949
|
bridge: `{
|
|
880
950
|
...next(operator),
|
|
881
951
|
distance: distance?,
|
|
882
952
|
direction: direction?,
|
|
953
|
+
points: points?,
|
|
883
954
|
to: to?,
|
|
884
955
|
operator: operator,
|
|
885
|
-
interpolate: [{ property: 'operator' }, { property: 'direction' }, { property: 'to' }, { property: 'distance' }]
|
|
956
|
+
interpolate: [{ property: 'operator' }, { property: 'direction' }, { property: 'points' }, { property: 'to' }, { property: 'distance' }]
|
|
886
957
|
}`,
|
|
887
958
|
selector: {
|
|
888
959
|
arguments: {
|
|
889
960
|
distance: "(@<= 'quantity' && context.unit.dimension == 'length')",
|
|
890
961
|
direction: "(@<= 'direction')",
|
|
891
962
|
to: "(@<= 'toPoint')",
|
|
963
|
+
points: "(@<= 'point')",
|
|
892
964
|
},
|
|
893
965
|
},
|
|
894
966
|
semantic: async (args) => {
|
|
895
|
-
const {context, objects, e, toEValue} = args
|
|
967
|
+
const {context, objects, e, toArray, toEValue} = args
|
|
896
968
|
if (context.distance) {
|
|
897
969
|
await handleDistance(args, context.distance)
|
|
898
970
|
}
|
|
899
971
|
if (context.direction) {
|
|
900
|
-
|
|
972
|
+
const array = toArray(context.direction)
|
|
973
|
+
if (array.length == 2 && array[0].marker == 'back' && array[1].marker == 'forth') {
|
|
974
|
+
await args.api.backAndForth()
|
|
975
|
+
} else if (context.direction.marker == 'back') {
|
|
976
|
+
await args.api.back(context.points)
|
|
977
|
+
} else {
|
|
978
|
+
objects.current.direction = context.direction.marker
|
|
979
|
+
}
|
|
901
980
|
}
|
|
902
981
|
if (context.to) {
|
|
903
982
|
const evaluation = await e(context.to.point)
|
|
@@ -931,7 +1010,7 @@ const template = {
|
|
|
931
1010
|
if (context.repeats) {
|
|
932
1011
|
current.timeRepeats = toFinalValue(context.repeats.repeats)
|
|
933
1012
|
}
|
|
934
|
-
|
|
1013
|
+
async function toRadians(angle) {
|
|
935
1014
|
const fi = await fragments("40 degrees in radians")
|
|
936
1015
|
return await fi.instantiate([
|
|
937
1016
|
{
|
|
@@ -962,11 +1041,26 @@ const template = {
|
|
|
962
1041
|
{
|
|
963
1042
|
id: 'pause',
|
|
964
1043
|
isA: ['verb'],
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1044
|
+
words: ['pause'],
|
|
1045
|
+
bridge: "{ ...operator, time: or(time?, forTime), interpolate: [{ context: operator }, { property: 'time' }] }",
|
|
1046
|
+
check: defaultContextCheckProperties(['time']),
|
|
1047
|
+
selector: {
|
|
1048
|
+
arguments: {
|
|
1049
|
+
forTime: "(@<= 'forQuantity' && context.quantity.unit.dimension == 'time')",
|
|
1050
|
+
time: "(@<= 'quantity' && context.unit.dimension == 'time')",
|
|
1051
|
+
},
|
|
1052
|
+
},
|
|
1053
|
+
semantic: async ({context, mentioned, api, e, fragments, toFinalValue}) => {
|
|
1054
|
+
let time = context.time
|
|
1055
|
+
if (time.marker == 'forQuantity') {
|
|
1056
|
+
time = time.quantity
|
|
1057
|
+
}
|
|
1058
|
+
const instantiation = await fragments("quantity in seconds", { quantity: time})
|
|
1059
|
+
const result = await e(instantiation)
|
|
1060
|
+
const seconds = toFinalValue(toFinalValue(result).amount)
|
|
1061
|
+
context.pauseSeconds = seconds
|
|
1062
|
+
mentioned(context)
|
|
1063
|
+
api.pause(seconds)
|
|
970
1064
|
}
|
|
971
1065
|
},
|
|
972
1066
|
{
|
|
@@ -978,7 +1072,7 @@ const template = {
|
|
|
978
1072
|
bridge: "{ ...next(operator), object: after[0], interpolate: [{ context: operator }, { property: 'object' }] }",
|
|
979
1073
|
semantic: async ({mentioned, context, objects, api, say}) => {
|
|
980
1074
|
await api.stop()
|
|
981
|
-
api.markCurrentPoint()
|
|
1075
|
+
await api.markCurrentPoint()
|
|
982
1076
|
}
|
|
983
1077
|
},
|
|
984
1078
|
],
|
|
@@ -993,9 +1087,20 @@ const template = {
|
|
|
993
1087
|
},
|
|
994
1088
|
],
|
|
995
1089
|
semantics: [
|
|
1090
|
+
{
|
|
1091
|
+
match: ({context}) => context.marker == 'doAction',
|
|
1092
|
+
apply: async ({context, e, toEValue, objects}) => {
|
|
1093
|
+
const evaluated = await(e(context.action))
|
|
1094
|
+
const path = toEValue(evaluated)
|
|
1095
|
+
for (const point of path.points) {
|
|
1096
|
+
objects.current.path.push(point)
|
|
1097
|
+
}
|
|
1098
|
+
objects.runCommand = true
|
|
1099
|
+
}
|
|
1100
|
+
},
|
|
996
1101
|
{
|
|
997
1102
|
match: ({context, contextHierarchy}) => {
|
|
998
|
-
if (!context.pullFromContext || !context.evaluate || contextHierarchy.under('
|
|
1103
|
+
if (!context.pullFromContext || !context.evaluate || contextHierarchy.under(['doAction', 'evaluate'])) {
|
|
999
1104
|
return false
|
|
1000
1105
|
}
|
|
1001
1106
|
|
|
@@ -1003,12 +1108,37 @@ const template = {
|
|
|
1003
1108
|
return true
|
|
1004
1109
|
}
|
|
1005
1110
|
},
|
|
1006
|
-
apply: async ({context, fragments, stm, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {
|
|
1007
|
-
const
|
|
1111
|
+
apply: async ({context, frameOfReference, toArray, fragments, stm, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {
|
|
1112
|
+
const pathComponents = toArray(await mentions({ context: { marker: 'pathComponent' }, all: true }))
|
|
1008
1113
|
const path = (await fragments('path')).contexts()[0]
|
|
1009
|
-
path.
|
|
1114
|
+
delete path.value
|
|
1115
|
+
path.points = pathComponents.reverse()
|
|
1116
|
+
frameOfReference(path, { mentioned: 'points', reversed: true })
|
|
1010
1117
|
await mentioned(path)
|
|
1011
|
-
|
|
1118
|
+
|
|
1119
|
+
_continue() // let the call pick the object out from the stm
|
|
1120
|
+
},
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
match: ({context, contextHierarchy}) => {
|
|
1124
|
+
if (!context.pullFromContext || !context.evaluate || !contextHierarchy.under('call') || context.notUnderCall) {
|
|
1125
|
+
return false
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
if (context.marker == 'point' || context.marker == 'ordinal') {
|
|
1129
|
+
return true
|
|
1130
|
+
}
|
|
1131
|
+
},
|
|
1132
|
+
apply: async ({context, e, fragments, stm, toEValue, toArray, objects, mentioned, mentions, resolveEvaluate, _continue, contextHierarchy}) => {
|
|
1133
|
+
const evaluated = await e({...context, notUnderCall: true})
|
|
1134
|
+
const pointsContext = toEValue(evaluated)
|
|
1135
|
+
const pathComponents = toArray(pointsContext)
|
|
1136
|
+
|
|
1137
|
+
const path = (await fragments('path')).contexts()[0]
|
|
1138
|
+
delete path.value
|
|
1139
|
+
path.points = pathComponents.reverse()
|
|
1140
|
+
await mentioned(path)
|
|
1141
|
+
resolveEvaluate(context, path)
|
|
1012
1142
|
},
|
|
1013
1143
|
},
|
|
1014
1144
|
{
|
|
@@ -1022,7 +1152,7 @@ const template = {
|
|
|
1022
1152
|
{
|
|
1023
1153
|
match: ({context}) => context.evaluate && ['start', 'end'].includes(context.marker) && context.objects && context.objects[1].marker == 'path',
|
|
1024
1154
|
apply: async ({gp, s, context, objects, fragments, resolveEvaluate, api, mentions}) => {
|
|
1025
|
-
const path = mentions({ context: context.objects[1] })
|
|
1155
|
+
const path = await mentions({ context: context.objects[1] })
|
|
1026
1156
|
if (!path?.points) {
|
|
1027
1157
|
return
|
|
1028
1158
|
}
|
|
@@ -1084,15 +1214,8 @@ const template = {
|
|
|
1084
1214
|
return true
|
|
1085
1215
|
}
|
|
1086
1216
|
},
|
|
1087
|
-
apply: ({
|
|
1088
|
-
|
|
1089
|
-
objects.current.backAndForth = true
|
|
1090
|
-
const ordinal = api.currentOrdinal()
|
|
1091
|
-
const currentPoint = mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal })
|
|
1092
|
-
const lastPoint = mentions({ context: { marker: 'point' }, condition: (context) => context.ordinal == ordinal-1 })
|
|
1093
|
-
objects.current.path.push(lastPoint)
|
|
1094
|
-
objects.current.path.push(currentPoint)
|
|
1095
|
-
// objects.current.path.push({ ...lastPoint, aimOnly: true })
|
|
1217
|
+
apply: async ({api}) => {
|
|
1218
|
+
await api.backAndForth()
|
|
1096
1219
|
}
|
|
1097
1220
|
}
|
|
1098
1221
|
],
|
|
@@ -1102,7 +1225,7 @@ const template = {
|
|
|
1102
1225
|
|
|
1103
1226
|
knowledgeModule( {
|
|
1104
1227
|
config: { name: 'drone' },
|
|
1105
|
-
includes: [angle, compass, nameable, ordinals, hierarchy, rates, help],
|
|
1228
|
+
includes: [actions, angle, compass, nameable, ordinals, hierarchy, rates, help],
|
|
1106
1229
|
api: () => new API(),
|
|
1107
1230
|
|
|
1108
1231
|
module,
|
|
@@ -1112,9 +1235,32 @@ knowledgeModule( {
|
|
|
1112
1235
|
contents: drone_tests,
|
|
1113
1236
|
checks: {
|
|
1114
1237
|
context: [
|
|
1115
|
-
defaultContextCheck({ marker: 'path', exported: true,
|
|
1116
|
-
|
|
1117
|
-
|
|
1238
|
+
defaultContextCheck({ marker: 'path', exported: true,
|
|
1239
|
+
extra: [
|
|
1240
|
+
'points',
|
|
1241
|
+
{
|
|
1242
|
+
property: 'namespaced',
|
|
1243
|
+
check: [
|
|
1244
|
+
{ property: 'stm', check: ['id'] },
|
|
1245
|
+
{ property: 'nameable', check: ['names'] },
|
|
1246
|
+
]
|
|
1247
|
+
}
|
|
1248
|
+
]
|
|
1249
|
+
}),
|
|
1250
|
+
defaultContextCheck({ marker: 'point', exported: true,
|
|
1251
|
+
extra: [
|
|
1252
|
+
'ordinal',
|
|
1253
|
+
{ property: 'point', check: ['x', 'y'] },
|
|
1254
|
+
'description',
|
|
1255
|
+
{
|
|
1256
|
+
property: 'namespaced',
|
|
1257
|
+
check: [
|
|
1258
|
+
{ property: 'stm', check: ['id'] },
|
|
1259
|
+
{ property: 'nameable', check: ['names'] },
|
|
1260
|
+
]
|
|
1261
|
+
},
|
|
1262
|
+
]
|
|
1263
|
+
}),
|
|
1118
1264
|
defaultContextCheck({ marker: 'turn', exported: true, extra: ['direction', 'repeats'] }),
|
|
1119
1265
|
defaultContextCheck({ marker: 'history', exported: true, extra: ['debug', 'pause', 'direction', 'speed', 'turn', 'time', 'sonic', 'batched', 'repeats', 'armAction', 'clawAction'] }),
|
|
1120
1266
|
defaultContextCheck(),
|