I want to make a “melty brain”/translational drift battle robot using the OpenMV for optical flow stabilisation. To make this happen I want to:
- Receive a clock from each of my two brushless motor controllers that indicates wheel odometry.
- Every N pulses (where N is approximately 100 to 150) I want to quickly trigger a steering servo or solenoid (which will need to be clocked at 400Hz instead of the usual 50Hz) snap a photo and compare it to the photo taken on the previous cycle, computing the number of pixels of horizontal translation find_displacement() but only in the x direction).
- Use that optical flow displacement to modulate N.
- Have my robot rotate at approximately 1000rpm (approximately 16 frames per second) with extremely low frame jitter (something like 200us max) in the optical flow correction path.
OpenMV uses MicroPython, which can do many things. However it doesn’t seem to be able to:
- Configure servos to be clocked at a rate other than 50Hz.
- Support a counter that will interrupt every N cycles of an internal clock to trigger a snapshot.
- Run in hard realtime since it is a garbage collected language.
Am I right in assuming I can’t do those things in MicroPython?
I could probably add 1) and 2) to MicroPython by wrapping new C modules, but is 3) likely to be a killer in my application? What are peoples’ experience with frame jitter due to the interpreted and garbage collected nature of Python?
Better to remove python and program the OpenMV directly in C for this?