Commit d038faf
authored
Reversible primitives (#250)
* Initial work on io state inspection
This allows the debugger to inspect the current io state and load io states from snapshots. Currently only works with chip_digital_write.
* Obtain io state through portOutput/InputRegister
There currently is no support for analog values.
* Remove io map from Module struct
* Use NUM_DIGITAL_PINS because SOC_GPIO_PIN_COUNT is esp specific
* Serialize/deserialize pin mode in snapshot data
* Use digitalPinToBitMask in an attempt to make the code more microcontroller agnostic
* Port WARDuino to the Zephyr RTOS
The main reason for this is to support boards such as Open Bot Brain which uses
an stm32l496zg. By porting to Zephyr we can also add support for some other
boards with relative ease.
* Try correcting for drift in the servo motor driver
* Fixed cmake with branch rebase
* Use vfprintf instead of fprintf to handle variadic arguments
* Loading snapshots should work again now
* Hacky but it's starting to work
* Somewhat hacky way of extracting the current sensor value
* Put uart heartbeat for sensors in a thread + colour_sensor now returns sensor value
* Allow controlling multiple motors
* Added anti-stall system to motor driver
This makes it so if the motor tries to move but it's not actually moving the
voltage applied to the motor is increased until it moves and completes the
operation.
* Make motor driver reversible
* Added some things needed to make uart sensor work
* Added invoke_primitive function that makes it easy to call primitives with arguments
* New API for reversible primitives
Reversible primitives are now defined by using def_prim_reverse and def_prim_serialize.
* Rename PinState to IOStateElement and clean up debugger ioState interrupt
* Clang format
* Only run the reverse operation for the primitive that was just executed and not for all primitives
This particularly important for motor primitives that for example drive two motors at the same time vs a primitive that drives one motor at a time, executing the wrong reverse operation will result in the correct angles but the wrong position.
* Use ms to configure stall timeout for motors
* Adjust speed faster when stalling
Also added helper functions to reduce duplicated code between drive_motor_degrees and drive_motor_degrees_relative.
* Don't wait for the full 10ms if we have already detected movement
* Stripped out open bot brain primitives
* Clang format
* Make chip_digital_write on arduino reversible using the new macros
* Remove io-arduino.cpp and fix usage of PinState
* def_prim_serialize should not return anything for chip_digital_write
* Add extra clause to if so int32_t and int are bot considered I32 in create_stack template function
* Add new macros + restore_external_state + get_io_state to ESP-IDF
* Install primitive reverse for chip_digital_write
* Just use NUM_PRIMITIVES and set it to 5
* Move last remaining bits of io.h into primitives.h
* Add reversible primitive code to emulated.cpp
* Fixed zephyr build1 parent f27ce03 commit d038faf
File tree
9 files changed
+386
-13
lines changed- platforms/Zephyr/boards
- src
- Debug
- Primitives
9 files changed
+386
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
111 | 116 | | |
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
118 | | - | |
| 123 | + | |
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
714 | 715 | | |
715 | 716 | | |
716 | 717 | | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
722 | 730 | | |
723 | 731 | | |
724 | 732 | | |
| |||
843 | 851 | | |
844 | 852 | | |
845 | 853 | | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
846 | 874 | | |
847 | 875 | | |
848 | 876 | | |
| |||
953 | 981 | | |
954 | 982 | | |
955 | 983 | | |
956 | | - | |
| 984 | + | |
| 985 | + | |
957 | 986 | | |
958 | 987 | | |
959 | 988 | | |
| |||
1169 | 1198 | | |
1170 | 1199 | | |
1171 | 1200 | | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
1172 | 1224 | | |
1173 | 1225 | | |
1174 | 1226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
158 | 167 | | |
159 | 168 | | |
160 | 169 | | |
161 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
162 | 179 | | |
163 | 180 | | |
164 | 181 | | |
| |||
491 | 508 | | |
492 | 509 | | |
493 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
494 | 541 | | |
495 | 542 | | |
496 | 543 | | |
| |||
954 | 1001 | | |
955 | 1002 | | |
956 | 1003 | | |
| 1004 | + | |
957 | 1005 | | |
958 | 1006 | | |
959 | 1007 | | |
| |||
1026 | 1074 | | |
1027 | 1075 | | |
1028 | 1076 | | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
55 | 64 | | |
56 | 65 | | |
57 | 66 | | |
58 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
59 | 76 | | |
60 | 77 | | |
61 | 78 | | |
| |||
572 | 589 | | |
573 | 590 | | |
574 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
575 | 630 | | |
0 commit comments