|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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 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. Last edited by meatmanek : 20-03-2007 at 20:29. Reason: Included explanation. |
|
#3
|
|||||
|
|||||
|
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: |
|
#4
|
||||
|
||||
|
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
|
|||
|
|||
|
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. ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |