Go to Post Battle Bots and other robot fighting competitions is to First Like McDonalds to Hamburgers They get the idea, and have the taste, but they are bad for you in the long run. - Conor Ryan [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-04-2010, 13:29
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Swerve vs. Mecanum Programming

I have seen many people talk about the advantages and disadvantages of Swerve vs. Mecanum. I have seen one argument that a swerve is harder to program than a mecanum but I think it is the other way around. I have built at least 2 VIs (I use LabView) for a swerve drive and my dad has built at least 5. I still have yet to figure out how to program a mecanum drive.

So my two questions
1. What is you opinion on Swerve vs. Mecanum Programing difficulty.
2 Am I missing an equation or formula that can be used in programing a mecanum drive that makes it easier?
  #2   Spotlight this post!  
Unread 17-04-2010, 14:16
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by kgzak View Post

I have seen one argument that a swerve is harder to program than a mecanum but I think it is the other way around.

I still have yet to figure out how to program a mecanum drive.

Am I missing an equation or formula that can be used in programing a mecanum drive that makes it easier?
Here are two simple algorithms:

2 JOYSTICK TANK DRIVE MECANUM SEPARATION OF VARIABLES
http://www.chiefdelphi.com/forums/sh...94&postcount=1

3-AXIS JOYSTICK MECANUM ALGORITHM
http://www.chiefdelphi.com/forums/sh...383#post916383

The above algorithms are not optimum, but they work.

~
  #3   Spotlight this post!  
Unread 17-04-2010, 14:42
buchanan buchanan is offline
Registered User
FRC #2077 (Laser Robotics)
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2007
Location: Wales, WI
Posts: 68
buchanan is just really nicebuchanan is just really nicebuchanan is just really nicebuchanan is just really nice
Re: Swerve vs. Mecanum Programming

Without getting into detailed equations, the mathematical principles of fully holonomic omni/mecanum drives are relatively simple and can be approached this way:

Each wheel has a direction vector along which it can transmit force in either direction. For a mecanum this is at 45 degrees to the plane of the wheel, parallel to the axle of the roller contacting the ground. For an omni it's along the flat plane of the wheel. No force is or can be transmitted except along this vector.

To get the wheel speeds necessary for any desired motion, you need to compute the projection of the motion vector onto each wheel's direction vector. For mecanums there's an additional constant to correct for the 45 degree angle. This can be done with dot products and no trigonometry.

For simple directional motion, regardless of direction, that's all there is to it. To handle rotation, the motion vectors are tangent to a circle about the center of rotation, projected on the same wheel vectors, and scaled by relative radius. For rotation about the center of a normally configured robot, these end up the same for each wheel. Rotation about other points or for odd wheel configurations is a bit more complex but conceptually the same. You can rotate and move simultaneously by solving the wheel speeds for each separately, then adding the motion and rotation components for each wheel to get its final drive speed.

This approach lends itself well to a two stick motion/rotation or single stick/twist control setup, and the vector math shouldn't take more than a couple of dozen lines of Java or C. It handles any motion physically possible with the robot. The motor drive functions needed for swerve drives, especially for complex motions, are considerably more complicated.

It should be noted that there are simpler but still useful ways to employ mecanum/omni wheels short of full holonomic, and other ways to program swerves short of the "almost holonomic" of which they're capable.
  #4   Spotlight this post!  
Unread 17-04-2010, 15:27
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by Ether View Post
Here are two simple algorithms:

2 JOYSTICK TANK DRIVE MECANUM SEPARATION OF VARIABLES
http://www.chiefdelphi.com/forums/sh...94&postcount=1

3-AXIS JOYSTICK MECANUM ALGORITHM
http://www.chiefdelphi.com/forums/sh...383#post916383

The above algorithms are not optimum, but they work.

~
I want to be able to go any direction with mecanum wheels not just forward backward and strafe. I have seen it done before and want to use that to create a field oriented drive so I press the joystick in any direction and it moves in that direction.
  #5   Spotlight this post!  
Unread 17-04-2010, 15:42
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by buchanan View Post
Without getting into detailed equations, the mathematical principles of fully holonomic omni/mecanum drives are relatively simple and can be approached this way:

Each wheel has a direction vector along which it can transmit force in either direction. For a mecanum this is at 45 degrees to the plane of the wheel, parallel to the axle of the roller contacting the ground. For an omni it's along the flat plane of the wheel. No force is or can be transmitted except along this vector.

To get the wheel speeds necessary for any desired motion, you need to compute the projection of the motion vector onto each wheel's direction vector. For mecanums there's an additional constant to correct for the 45 degree angle. This can be done with dot products and no trigonometry.

For simple directional motion, regardless of direction, that's all there is to it. To handle rotation, the motion vectors are tangent to a circle about the center of rotation, projected on the same wheel vectors, and scaled by relative radius. For rotation about the center of a normally configured robot, these end up the same for each wheel. Rotation about other points or for odd wheel configurations is a bit more complex but conceptually the same. You can rotate and move simultaneously by solving the wheel speeds for each separately, then adding the motion and rotation components for each wheel to get its final drive speed.

This approach lends itself well to a two stick motion/rotation or single stick/twist control setup, and the vector math shouldn't take more than a couple of dozen lines of Java or C. It handles any motion physically possible with the robot. The motor drive functions needed for swerve drives, especially for complex motions, are considerably more complicated.

It should be noted that there are simpler but still useful ways to employ mecanum/omni wheels short of full holonomic, and other ways to program swerves short of the "almost holonomic" of which they're capable.
Thanks, that helped. Between you and Ether I figured it out. I thank both of you.
  #6   Spotlight this post!  
Unread 17-04-2010, 15:43
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by kgzak View Post
I want to be able to go any direction with mecanum wheels not just forward backward and strafe.
The algorithms in both links allow all 3 degrees of freedom: forward/reverse, stafe left/right, and rotate clockwise/counterclockwise.

Quote:
Originally Posted by kgzak View Post
I want to use that to create a field oriented drive so I press the joystick in any direction and it moves in that direction.
The 3-axis joystick algorithm can be made field-oriented simply by doing a coordinate axis rotation of the X,Y joystick values before feeding them to the algorithm.

x' = xcos(theta) - ysin(theta)

y' = xsin(theta) + ycos(theta)

... but Buchanan's approach is technically more correct and will yield more optimal control (more accurate directional control, smoother operation, and less scrubbing of the wheels)


~

Last edited by Ether : 17-04-2010 at 15:53.
  #7   Spotlight this post!  
Unread 17-04-2010, 15:59
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by Ether View Post
The algorithms in both links allow all 3 degrees of freedom: forward/reverse, stafe left/right, and rotate clockwise/counterclockwise.



The 3-axis joystick algorithm can be made field-oriented simply by doing a coordinate axis rotation of the X,Y joystick values before feeding them to the algorithm.

x' = xcos(theta) - ysin(theta)

y' = xsin(theta) + ycos(theta)

... but Buchanan's approach is technically more correct and will yield more optimal control (more accurate directional control, smoother operation, and less scrubbing of the wheels)


~
Thanks. That'll help. I think I have it figured out. Now if only our coach will do off season stuff
  #8   Spotlight this post!  
Unread 17-04-2010, 19:00
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: Swerve vs. Mecanum Programming

AM has a great powerpoint about omnidirectional drive, which has several diagrams that may make seeing the vectors talked about above easier to see.

http://www.andymark.biz/presentations.html

Also, if you use a gamepad or similar control device, using the left joystick to control the movement of the actual robot and using the right joystick x axis to rotate the robot, it makes it very easy for someone who has played Halo to figure out how to drive your robot.
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
  #9   Spotlight this post!  
Unread 17-04-2010, 19:03
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by buildmaster5000 View Post
Also, if you use a gamepad or similar control device, using the left joystick to control the movement of the actual robot and using the right joystick x axis to rotate the robot, it makes it very easy for someone who has played Halo to figure out how to drive your robot.
I was thinking that and since I am not only the programer, I am the driver I can basically make any driver station I want.
  #10   Spotlight this post!  
Unread 17-04-2010, 19:21
buildmaster5000 buildmaster5000 is offline
Trying to program the swerve drive
AKA: Alex
FRC #2421 (Rolling Thunder Robotics)
Team Role: Alumni
 
Join Date: May 2009
Rookie Year: 2009
Location: Northern Virginia
Posts: 207
buildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud ofbuildmaster5000 has much to be proud of
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by kgzak View Post
I was thinking that and since I am not only the programer, I am the driver I can basically make any driver station I want.
Then use whatever works for you. We need to get a gamepad to work with Java before we start to tackle programming a swerve...
__________________
-Alex



2010 Washington DC Regional: Engineering Excellence Award
  #11   Spotlight this post!  
Unread 21-05-2010, 21:15
tanguma26 tanguma26 is offline
Registered User
FRC #3999
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Killeen
Posts: 48
tanguma26 is an unknown quantity at this point
Re: Swerve vs. Mecanum Programming

Hey we are team 647 and we are trying to develop our own swerve drive and I was wondering if you can post some examples of your program we are having some troble with our program and we are using Lab View.

Thank You
  #12   Spotlight this post!  
Unread 22-05-2010, 12:49
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by tanguma26 View Post
Hey we are team 647 and we are trying to develop our own swerve drive and I was wondering if you can post some examples of your program we are having some troble with our program and we are using Lab View.

Thank You
I can post some examples. I will post them later right now I am at my friends house and don't have the ability to do so.

Baisically what my code does is it compares two numbers and if the pos_in(position the feedback tells you you are in) is greater than pos_to(Position to go to) then it sets the speed to -1 and 1 if it is the other way around. I also have a lot of safeties built in such as: If the feedback isn't counting, if it is turning the wrong way, etc. You may have a few questions because I really haven't commented any of it and it even confused my dad at first, so I will be willing to answer any other questions you have.
  #13   Spotlight this post!  
Unread 23-05-2010, 00:03
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by kgzak View Post
I can post some examples. I will post them later right now I am at my friends house and don't have the ability to do so.

Baisically what my code does is it compares two numbers and if the pos_in(position the feedback tells you you are in) is greater than pos_to(Position to go to) then it sets the speed to -1 and 1 if it is the other way around. I also have a lot of safeties built in such as: If the feedback isn't counting, if it is turning the wrong way, etc. You may have a few questions because I really haven't commented any of it and it even confused my dad at first, so I will be willing to answer any other questions you have.
a simpler way to do this exists.
it's called proportional control. p from pid.

Basically, you say;
Code:
error = setpoint - process_variable
output = error * Kp
And Kp (gain) is constant. Nice and easy. You should only need a safety at the left/right boundaries to cut off the output when it gets out of range, and possibly some functions to invert motor and rotate inverse. You tune the gain so that it goes as fast as it can without oscillating.

Edit: Forgot to talk about I and D:
Integral (I):
Basically you integrate the error and add it to the output:
Code:
integral += error
output += integral * kI
Ki is Integral Gain. You also need to reset integral to prevent integral windup. Generally you do not need to implement I unless you cannot get enough accuracy with P alone.

Derivative (D):
You calculate the derivative of the previous action to determine how momentum will affect the stopping ability. Basically, it works against P and I to slow it down when it nears the end, allowing a higher P gain. You will almost certainly not need this with crab steering, as the friction of turning the pods will probably slow their rotation very quickly (D would be useful for, say, a 6' arm that has a lot of mass at the end).
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack

Last edited by apalrd : 23-05-2010 at 00:10.
  #14   Spotlight this post!  
Unread 23-05-2010, 20:00
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Quote:
Originally Posted by apalrd View Post
a simpler way to do this exists.
it's called proportional control. p from pid.

Basically, you say;
Code:
error = setpoint - process_variable
output = error * Kp
And Kp (gain) is constant. Nice and easy. You should only need a safety at the left/right boundaries to cut off the output when it gets out of range, and possibly some functions to invert motor and rotate inverse. You tune the gain so that it goes as fast as it can without oscillating.

Edit: Forgot to talk about I and D:
Integral (I):
Basically you integrate the error and add it to the output:
Code:
integral += error
output += integral * kI
Ki is Integral Gain. You also need to reset integral to prevent integral windup. Generally you do not need to implement I unless you cannot get enough accuracy with P alone.

Derivative (D):
You calculate the derivative of the previous action to determine how momentum will affect the stopping ability. Basically, it works against P and I to slow it down when it nears the end, allowing a higher P gain. You will almost certainly not need this with crab steering, as the friction of turning the pods will probably slow their rotation very quickly (D would be useful for, say, a 6' arm that has a lot of mass at the end).
I do know there are other ways of doing this but I like the challenge of completely writing code from scratch. The safeties are in there because one of our mentors was afraid we were going to break his swerve drive. He was afraid that the encoder/pot was going to fall off and since our drive could not continually rotate without breaking the frame, he was always afraid when we made changes to the code. My code is actually based off the code my dad uses for his drives at his work, minus he torque controllers. I have speed and position/distance controllers.
  #15   Spotlight this post!  
Unread 23-05-2010, 20:22
kgzak's Avatar
kgzak kgzak is offline
Registered User
AKA: Kris
FRC #4392 (Decievers) FRC #2075 (Enigma)
Team Role: College Student
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Grand Rapids, Michigan
Posts: 418
kgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to beholdkgzak is a splendid one to behold
Re: Swerve vs. Mecanum Programming

Ok I have attached my code for the swerve drive. I will answer any questions.
Attached Files
File Type: vi Position_Controller.vi (32.5 KB, 34 views)
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mecanum or Swerve? buildmaster5000 Technical Discussion 73 18-04-2010 11:19
Programming Mecanum Zrob Java 22 04-04-2010 23:00
Mecanum Programming Help Mars Programming 8 27-02-2008 15:41
mecanum programming mrmummert Programming 27 28-01-2007 13:45
Need help programming our swerve with feedback? activemx Programming 25 13-04-2004 07:29


All times are GMT -5. The time now is 23:13.

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