-
Notifications
You must be signed in to change notification settings - Fork 11
Reversible primitives #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows the debugger to inspect the current io state and load io states from snapshots. Currently only works with chip_digital_write.
There currently is no support for analog values.
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.
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.
Reversible primitives are now defined by using def_prim_reverse and def_prim_serialize.
Rebase was a bit complex due to main and this branch both have partially the same feature (the Zephyr platform) so I ended up just merging main into this branch. Will be squashed later anyway.
…ed 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.
Also added helper functions to reduce duplicated code between drive_motor_degrees and drive_motor_degrees_relative.
…reate_stack template function
|
I think I'm just going to open this up for review. I'm not happy with how some of the code is duplicated for each of the platform primitives but fixing that requires a bit of a refactor to the primitive system that should probably be done in another PR. The PR adds the macros and functions needed for all platforms but currently only adds reversibility to |
b348083 to
296fffd
Compare
1996698 to
5d87aad
Compare
This PR adds the initial support for reversible primitives to WARDuino. This makes it possible to define the action that should be executed to revert the action of a primitive. For example defining that if an led was off and is then turned on it should be turned off again when stepping back. This can be done using some new macros. To define the action you can use
def_prim_reverse, to define the method used to serialize external state you usedef_prim_serialize.This PR also adds some useful code for invoking primitives from within code for example:
will run chip_digital_write(5, 1) in the vm.
Currently, the macros and code needed to have reversible primitives is replicated for all platforms which is not ideal. We should probably try reduce the amount of duplicated code in the primitive files in a future PR.