Go to Post I'm looking foward to the challenge! - Adrienne E. [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 20-03-2007, 19:52
Mr. Freeman Mr. Freeman is offline
Put better title here.
AKA: Kellan
no team (CSM Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Colorado
Posts: 198
Mr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to behold
Mecanum drivetrain programming problems

My team recently purchased a set of andymark mecanum wheels for off season testing use. We haven't managed to build a chassis for them yet, but I want to get started on the programming so we have something to work with when we have the chassis built. I've been searching these forums for a few weeks now and I'm pretty sure I've read everything ever posted about mecanum wheels....twice. I've found a lot of code snippets but no explanation of the algorithms behind them.

Anyway, I've come up with this so far: http://img83.imageshack.us/img83/4896/mecanumqx7.jpg

I'm working under the assumption that each wheel will move at a 45 degree angle when powered. Thus, each wheel will attempt to move in the directions indicated by the green arrows. The green arrows show the movement of the wheels when the back two are turned backwards and the front two are turned forwards. They are then combined into the vectors shown by the blue arrows. Because the blue arrows are at 90 degrees from each other, you can orient them on the grid shown by the red lines.

I came up with the following equations, where x is the movement of the left front and back right wheels, and y is the movement of the right front and back left wheels:
y = sin(theta-45)*(magnitude of R)
x = cos(theta-45)*(magnitude of R)

R and theta being the vector indicated by the joystick you're using to control the drivetrain.

This should return a value between -1 and +1 that should correspond to a PWM value between 0 and 255. If this function returns 0, the PWM value should be 127, if it returns 1 the PWM value should be 255, etc.

I ran a couple of values through this function and found the following problem. If I want the robot to go straight, theta is 90 and magnitude of R is 1.
Thus,
y = sin(90-45)*(1) = .707
x = cos(90-45)*(1) = .707
The PWM value for this should be:
.707 * 127 = 90
90 + 127 = 217

The problem with this is that all four wheels will move at the same speed (and therefore in the correct direction) but not at full power. I'm assuming that when the magnitude of R is 1, it indicates full speed, I think my problem lies here but I can't be sure. Any help would be much appreciated.
__________________
"Time is an illusion, lunchtime doubly so."
-Douglas Adams
“Why is it that I can walk into Wal-Mart and buy boxes of bullets and black powder, but I can’t buy potassium perchlorate to do science because it can also be used to make explosives?”
-Theodore Gray
  #2   Spotlight this post!  
Unread 20-03-2007, 20:22
meatmanek meatmanek is offline
Programmer/physicist/mathematician
FRC #0868 (TechHounds)
Team Role: Programmer
 
Join Date: Mar 2004
Rookie Year: 2004
Location: Carmel, Indiana
Posts: 142
meatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to beholdmeatmanek is a splendid one to behold
Re: Mecanum drivetrain programming problems

Last year we used mecanum wheels.

I don't have access to our old code at the moment, but it looked something like this (values are centered at 0 rather than 127)

Code:
x = p1_x;
y = p1_y;
rotate = p1_wheel;

drive_FR = y + rotate + x;
drive_FL = y - rotate - x;
drive_BR = y + rotate - x;
drive_BL = y - rotate + x;

scale = 128;
if (drive_FR > scale)
 scale = drive_FR;
if (drive_FR < -scale)
 scale = -drive_FR;
if (drive_FL > scale)
 scale = drive_FL;
if (drive_FL < -scale)
 scale = -drive_FL;
// and so on for BR and BL

drive_FR = drive_FR * 128 / scale; 
// and so on for the rest
The first part determines which direction and speed each wheel should be going.
The second part scales all of the wheels back if one is above 127. We scaled back rather than clip because if you clip, it won't go in the direction you want.

EDIT:
I suppose I ought to include an explanation as well.
Forward and turning are identical to tank drive. In fact, we use code very similar to this on this year's tank drive robot for one joystick drive.
To go sideways, you drive each wheel on one side of the robot in a different direction. Because of the angled rollers, if you drive a wheel forward but pull backward on the axle, it will pull sideways. To get a combination of all of these, you simply add the values together.
__________________
Real programmers use vim.

Last edited by meatmanek : 20-03-2007 at 20:29. Reason: Included explanation.
  #3   Spotlight this post!  
Unread 20-03-2007, 20:26
TheOtherGuy's Avatar
TheOtherGuy TheOtherGuy is offline
Unregistered User
AKA: Kevin Forbes
FRC #4183 (Bit Buckets)
Team Role: Engineer
 
Join Date: Jul 2006
Rookie Year: 2006
Location: Tucson, AZ
Posts: 408
TheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond reputeTheOtherGuy has a reputation beyond repute
Re: Mecanum drivetrain programming problems

I think there are much easier ways to program mecanum drive. The above is a good example, and you can also find one here, made by artdutra04 for a holonomic vex robot. I used his code for a vex mecanum robot and it works perfectly.

top view:
Attached Thumbnails
Click image for larger version

Name:	mecanumsettup.jpg
Views:	45
Size:	19.0 KB
ID:	5282  
__________________
  #4   Spotlight this post!  
Unread 20-03-2007, 22:50
talltree357's Avatar
talltree357 talltree357 is offline
Registered User
AKA: Joe Gro
None #0357 (Royal Assault)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Drexel Hill, Pennsylvania
Posts: 46
talltree357 is a jewel in the roughtalltree357 is a jewel in the roughtalltree357 is a jewel in the rough
Send a message via AIM to talltree357
Re: Mecanum drivetrain programming problems

Here is a link to the thread which discusses our Jester Drive mecanum code. I hope you find this helpful.

http://www.chiefdelphi.com/forums/sh...threadid=55896
  #5   Spotlight this post!  
Unread 21-03-2007, 17:11
Mr. Freeman Mr. Freeman is offline
Put better title here.
AKA: Kellan
no team (CSM Robotics)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Colorado
Posts: 198
Mr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to beholdMr. Freeman is a splendid one to behold
Re: Mecanum drivetrain programming problems

Thank you to everyone for your help. I now have some code that I think will work. If this works then I'll post a video of it.

Also, due to the lack of a chassis, I can finally say that the lack of mecanum movement is a hardware problem.
__________________
"Time is an illusion, lunchtime doubly so."
-Douglas Adams
“Why is it that I can walk into Wal-Mart and buy boxes of bullets and black powder, but I can’t buy potassium perchlorate to do science because it can also be used to make explosives?”
-Theodore Gray
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 problems Ian_Xodus General Forum 8 01-02-2007 08:31
mecanum programming mrmummert Programming 27 28-01-2007 13:45
Problems with Programming DHarris Programming 4 16-02-2006 13:08
Problems programming a switch caderader Programming 2 18-02-2005 22:06
Programming Sub-Team Problems Phil Paspalas Programming 9 19-01-2005 21:42


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

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