|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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. Last edited by asid61 : 27-05-2016 at 11:15. |
|
#2
|
|||
|
|||
|
Re: swerve drive with arduino mega 2560
Running a full swerve system on an Arduino is certainly possible, but it may be more of a challenge than you would like to take on. The biggest issue with the Arduino is that it does not have a floating point execution unit in the CPU. That means that all floating point operations have to be performed in software. Relatively speaking, this is very slow. In a typical swerve application, there are many FP operations required to determine steering angle, and wheel speed utilizing trig functions, PID loops, etc. If you attempted to do this directly on the Arduino, it would not have the processing power to perform these operations in a timely manner. A number of teams had swerve drives in the old IFI controller days. These controllers, while quicker than the Arduino - 40 MHz as opposed to 16 MHz for a Mega, also did not have a FP unit. Several strategies were used as work arounds to minimize or eliminate the need for floating point calculations including fixed point math and integer trig approximations. I would also recommend that you look into efficient interrupt driven routines for, what I will call, background tasks (encoders, analog signal A/D, PWM generation); again to minimize CPU usage and unnecessary delays.
For reference, I used an old IFI controller (2007 vintage - it was free) to make a swerve drive about a year ago using the techniques I mentioned above. It is a full swerve, with multiple modes including snake, and I am confident that I could make it work on an Arduino as well. However, I wouldn't recommend it unless you are willing to put a fair amount of time as it will not be easy (but a great learning experience!). Mike |
|
#3
|
||||
|
||||
|
Re: swerve drive with arduino mega 2560
This robot is running full 4 wheel swerve on an Arduino...
https://youtu.be/hdAmpk0PQ3I The controls code is based on the Ether paper. Ether also helped write some integer based routines to optimize the code...it works great. More firepower would be great, but it isn't required. |
|
#4
|
||||
|
||||
|
Re: swerve drive with arduino mega 2560
If you want trig functions you don't actually need full floating point support: use a look-up table.
http://www.societyofrobots.com/progr...rigtable.shtml BTW there are trig look-ups masked into the Parallex Propeller just for this reason, https://www.parallax.com/sites/defau...anual-v1.2.pdf Page 34. Last edited by techhelpbb : 27-05-2016 at 14:23. |
|
#5
|
||||
|
||||
|
Re: swerve drive with arduino mega 2560
all oof the answers are confusing me, the calculations i can probably figure out on my own, and the whole thing is completely set up except for the code, which is what i need help with. i put the issue in the description of the problem im having. butvtganks anywayb
also, i cant switch the setup of what im using significantly, like using somethingbother than a swerve drive, arduino, ot talons, but i can out thungs on it. also, sorry for the spelling mistakes, im using a touch screen computer and its hard to type correctly |
|
#6
|
||||
|
||||
|
Re: swerve drive with arduino mega 2560
i just realized I didn't put the issue in for lack of time, here is what is going wrong:
i clicked burn bootlegger after doing all previous steps correctly and this came up- Arduino: 1.6.9 (Windows 8.1), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)" avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03 Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. |
|
#7
|
||||
|
||||
|
Re: swerve drive with arduino mega 2560
I'm not sure why you would have to do "burn bootloader." Arduino boards come hot out of the gate ready to go.
Under "tools->board" make sure you have the correct Arduino hardware selected. Then check that you have the correct "com" port selected. Then press the upload arrow and you should be running code. Test this with the supplied examples before trying to upload your own custom code. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|