Im trying to learn Python by combining my interest in designing an AWD radio controlled car (3D printed, Im decent with Fusion 360 too) with some smarts from Pi/Python to allow things like software differential, toggleable front/rear bias etc. There was a project about 5 years ago using a STM32 board (and Matlab/Simiulink for really advanced mathematics) but I couldnt get it working on my STM43 407 discovery board. The author is no longer updating either.
I always wanted to do something with my pile of Raspberry Pi's and Joan's pigpio library makes this viable (I think!) on the Raspberry Pi directly.
I've got the old Python 2.x "raspberry-pi-multiple-esc-calibration-with-pigpio-for-drone" code cleaned up and running in Python 3.8 and calibrating, controlling and manually sending pulsewidths to my ESC's (BLHeli_32 driven) then motors (AvRoto 400Kv, massive, heavy duty drone motors). All good, this thing should be a rocket!
I've also got the Pi reading PWM input from my RC Receiver (V8FR-II, Turnigy 9x) using the Monitor PWM example from pigpio's example page. Again, quicker progress for a total newb than expected. I couldnt get this part working on the STM32 discovery board reliably. I modified the pigpio example code to just show the pulsewidth as the Frequency and Duty cycle arent needed.
Where I need some guidance, is simply integrating these two pieces of code together. I understand I fundamentally want to:
- Set 2 GPIO pins to input (steering and throttle) and 5 to output (1 per motor, 1 steering servo)
- Read the pulsewidth on the inputs and (with ability to modify signal later, but for now as is) send specific outputs
Could anyone give me some tips? The PWM monitor example creates a reader class and starts to look complicated. I want to add this into the multi-calibration python code but I cant get it working.