Go to Post And THAT is why they have safety manuals. - Eria4044 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-05-2016, 12:21
beckster1999's Avatar
beckster1999 beckster1999 is offline
Becky the robotic cat *prrrrr beep*
AKA: Becky
FRC #2877 (Ligerbots)
Team Role: Electrical
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Newton
Posts: 28
beckster1999 is an unknown quantity at this point
swerve drive with arduino mega 2560

hi, thus isnt for my team, but in my engineering class at school im working on a swerve drive but, but i have no experience programming since i usually stay on electrical. could someone help me figure out the code?
Reply With Quote
  #2   Spotlight this post!  
Unread 26-05-2016, 12:44
EmileH's Avatar
EmileH EmileH is offline
uses the Talon SRX way too much
AKA: Emile Hamwey
FRC #1058 (The PVC Pirates) & SLFF (NE Way You Want It)
Team Role: Programmer
 
Join Date: Dec 2014
Rookie Year: 2011
Location: New England
Posts: 539
EmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant futureEmileH has a brilliant future
Re: swerve drive with arduino mega 2560

You will need encoders for each wheel's rotation, a motor to spin each wheel module, and a motor to drive each wheel. More info on swerve drive mechanics can be found here.

For the programming, check out this document published by Ether which will help you control how your swerve works.
__________________
2016-present: High School Student, FRC 1058 PVC Pirates

Reply With Quote
  #3   Spotlight this post!  
Unread 26-05-2016, 20:02
asid61's Avatar
asid61 asid61 is offline
Registered User
AKA: Anand Rajamani
FRC #0115 (MVRT)
Team Role: Mechanical
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Cupertino, CA
Posts: 2,224
asid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond reputeasid61 has a reputation beyond repute
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 27-05-2016, 10:54
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
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
Reply With Quote
  #5   Spotlight this post!  
Unread 27-05-2016, 13:50
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 648
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
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.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
Reply With Quote
  #6   Spotlight this post!  
Unread 27-05-2016, 14:20
techhelpbb's Avatar
techhelpbb techhelpbb is offline
Registered User
FRC #0011 (MORT - Team 11)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 1997
Location: New Jersey
Posts: 1,622
techhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond reputetechhelpbb has a reputation beyond repute
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 31-05-2016, 10:37
beckster1999's Avatar
beckster1999 beckster1999 is offline
Becky the robotic cat *prrrrr beep*
AKA: Becky
FRC #2877 (Ligerbots)
Team Role: Electrical
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Newton
Posts: 28
beckster1999 is an unknown quantity at this point
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
Reply With Quote
  #8   Spotlight this post!  
Unread 31-05-2016, 10:53
beckster1999's Avatar
beckster1999 beckster1999 is offline
Becky the robotic cat *prrrrr beep*
AKA: Becky
FRC #2877 (Ligerbots)
Team Role: Electrical
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Newton
Posts: 28
beckster1999 is an unknown quantity at this point
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.
__________________
becky the robotic gerbil (btw anyone wanna help me make on starting next school year? i need a team and many years which is why I am starting in high school)
Reply With Quote
  #9   Spotlight this post!  
Unread 31-05-2016, 11:11
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 648
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
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.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
Reply With Quote
  #10   Spotlight this post!  
Unread 31-05-2016, 11:38
frcguy's Avatar
frcguy frcguy is offline
#GearsAllDay
AKA: Nicholas Dal Porto
FRC #5940 (B.R.E.A.D.)
Team Role: Tactician
 
Join Date: Dec 2015
Rookie Year: 2012
Location: Burlingame, CA
Posts: 887
frcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond reputefrcguy has a reputation beyond repute
Quote:
Originally Posted by ajlapp View Post
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.


+1. It looks to me like they may be saving their compiled code as a .hex file and flashing it to the Arduino. OP, you should try uploading code with the Arduino IDE.
__________________


2017: Team 5940 (Silicon Valley Regional/San Francisco Regional)
2016: Team 5940 (Silicon Valley Regional Rookie All-Star and Quarterfinalist, Curie Quarterfinalist)

Volunteer: 2016 (Chezy Champs Field Reset, Capital City Classic FTA, MadTown ThrowDown FTA)
Reply With Quote
  #11   Spotlight this post!  
Unread 31-05-2016, 11:42
ajlapp ajlapp is offline
Registered User
AKA: Anthony Lapp
None #0118 (Team RUSH and Robonauts)
 
Join Date: Sep 2001
Rookie Year: 1996
Location: Ortonville, MI
Posts: 648
ajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond reputeajlapp has a reputation beyond repute
Re: swerve drive with arduino mega 2560

Agreed.

The whole point of an Arduino is to be "foolproof." Start with using their supplied tool and examples to make sure everything is working as expected...then try your custom config.
__________________
Anthony Lapp
FIRST Engineering Mentor
Owner/Operator 221 Robotic Systems
221 Robotics Systems - Quality Hardware, Made in the USA
RobotOpen
anthony@221robotics.com
Twitter us: @221RobotSystems
Team 1 --> 94 --> 68 --> 221 --> 857 --> 27 --> 118
Design Engineer/Fabricator and 17 year vet
Team Rush (FRC27) and Robonauts (FRC118)
Reply With Quote
  #12   Spotlight this post!  
Unread 31-05-2016, 21:30
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: swerve drive with arduino mega 2560

Hi Becky,

I just ran through an installation of the Arduino software (I needed to upgrade anyway) and downloaded to a Mega and will list the steps that I went through to get it to work (there may be other ways, this is just what I used). Most of this is just a repeat of what others have said above.

1) Open a new sketch and cut/paste the Blink code example that can be found here near the bottom of the page. This is just to have a known good sketch to test.
2) In the menu item Tools->Board select "Arduino/Genuino Mega or Mega 2560"
3) In the menu item Tools->Programmer select "AVR ISP"
4) Verify your code by clicking on the left hand button with a Check Mark in it just below the menu items (The word "Verify" should display to the right of the buttons when you hover your mouse over it). It should return some messages at the bottom if the IDE indicating how large the sketch is and global variable use.
5) Plug in your Mega if you haven't already done so.
6) In the menu item Tools->Port, select the your Mega. Mine was labeled "COM3 (Arduino/Genuino Mega or Mega 2560)". Yours may have a different COM number.
7) Upload to the Mega the Blink program by pressing the right arrow button next to the verify button you used earlier. To the right of the buttons it should show the word "Upload" when you hover over it with your mouse. After a few seconds a message indicating "Done uploading." should be shown below your sketch and above the message area it it worked correctly. Also, the led on the mega (yellow on mine) will be blinking at 1 second intervals.

This worked on mine. If this works for you, then you should be able to upload your own sketch, but you may have to change the Board, Programmer & Port again (Steps 2,3 & 6) after you open your sketch. If this doesn't work, if you can post any error messages you are seeing, that would help us identify the problem.

Mike

Last edited by Mike Bortfeldt : 31-05-2016 at 21:32. Reason: Corrected a couple of words
Reply With Quote
  #13   Spotlight this post!  
Unread 01-06-2016, 11:36
beckster1999's Avatar
beckster1999 beckster1999 is offline
Becky the robotic cat *prrrrr beep*
AKA: Becky
FRC #2877 (Ligerbots)
Team Role: Electrical
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Newton
Posts: 28
beckster1999 is an unknown quantity at this point
Re: swerve drive with arduino mega 2560

it is working now, but I still don't know how to code more than in extremely basic python, so im not sure what to do. ill post a picture of the whole thing in a few minutes in case that is helpful. the code is empty as of right now.
__________________
becky the robotic gerbil (btw anyone wanna help me make on starting next school year? i need a team and many years which is why I am starting in high school)
Reply With Quote
  #14   Spotlight this post!  
Unread 01-06-2016, 11:39
beckster1999's Avatar
beckster1999 beckster1999 is offline
Becky the robotic cat *prrrrr beep*
AKA: Becky
FRC #2877 (Ligerbots)
Team Role: Electrical
 
Join Date: Feb 2016
Rookie Year: 2013
Location: Newton
Posts: 28
beckster1999 is an unknown quantity at this point
Re: swerve drive with arduino mega 2560

blob:https%3A//mail.google.com/6927b9bd-8c0e-4b71-91b0-fd0a0535bec7

here it is
__________________
becky the robotic gerbil (btw anyone wanna help me make on starting next school year? i need a team and many years which is why I am starting in high school)
Reply With Quote
  #15   Spotlight this post!  
Unread 01-06-2016, 14:31
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: swerve drive with arduino mega 2560

The URL doesn't seem to work for me. Can you try to post the picture or copy it to some other location?

Mike
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi