
I've discovered micropython a few weeks ago and I am just loving it! I've recently been working on a hexapod robot and I am currently controlling it with a rasberry pi. Since the code is writted in python and I want the robot to be wirelessly controlled, I thought that a esp32 running micropython could do the job. The only problem: the code is really slow. I have already tryed optimizing it different times and managed to cut about 20ms off, but it still takes about 35 milliseconds per iteration on an esp32, and I have yet to implement all the wi-fi code! For a real-time robot that needs to be constantly fed new servo positions 35ms is not ideal (on the pi the same unoptimized code runs at ~20ms). So I would like to ask some questions about code optimization.
- Is there a way to speed up I2C? I am using x2 pca9685 to control the servos, and about 15ms of the total execution time goes to controlling the boards. I am using the adafruit library for the pca9685.
- There are functions that gets called again and again during one execution, so beeing able to compile those as .mpy files or rewrite them in C would be great for speed. Is there any beginner-friendly documentation/guide on how to do it?
- How can I achieve RC like performances using wi-fi? What protocol is best suited for live data streaming across devices?
Any sources or links to learn more about any of those topics is greatly appreciated. Thanks in advantance
