|
Re: swerve drive with arduino mega 2560
I tried running swerve calculations on an XMOS, which is approximately 20x as powerful as an Arduino Mega. I don't believe I threaded on it though, so it was only about 5x as powerful.
My advice: don't do it. Crab drive is very easy to get working, but if you want true swerve motions like snake/ocelot turns, it's going to be difficult due to the math involved in vector addition. The Arduino is not optimized for the trig functions you need to use, and it will slow you down a lot- and that's before even trying PID or even just P controls on module rotation.
I believe I got somewhere between 50-100ms per loop, from reading joystick to motor controller outputs. This was however fr from optimized, as I was using a custom PWM generator that ran once per loop to make the motor control signals. Using the Arduino Servo library to control would help reduce the main loop loading.
If you do try it, optimize for speed. Avoid full swerve motion (crab is cool enough anyway, and scrub shouldn't be a problem on a small scale). If you want to do full swerve, find a way to approximate the trig to add vectors so you don't bog down the processor.
__________________
<Now accepting CAD requests and commissions>
Last edited by asid61 : 27-05-2016 at 11:15.
|