View Single Post
  #45   Spotlight this post!  
Unread 13-04-2010, 13:15
Andrew Schreiber Andrew Schreiber is offline
Joining the 900 Meme Team
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,058
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: Mecanum or Swerve?

Quote:
Originally Posted by Laaba 80 View Post
I admit that I have never programmed a mecanum drive, but I dont see it being easy to program. Sure, maybe the basic movements are simple, however I have seen few mechanum drive robots that are controlled effectively. This tells me that either the drivers dont know how to reap the benefits of a mecanum drive, or that the drive code is not up to par.

I programmed an omni drive robot in 08, and by no means was it easy, and it was nowhere near as controllable as I hoped.
Shedding some light on programming of mecanums. 2337's uses a simple version of linear interpolation. The 4 cardinal directions were declared in an array. We then look up which two to use based on which angle we want to move at and interpolate between the two. Pseudo-code below:

Code:
//Define the motors for the cardinal directions
cardDir = [[1,1,1,1],[1,-1,1,-1],[-1,-1,-1,-1],[-1,1,-1,1]];

//Angle is the angle we want to move at. 
a = angle/90;
b = a+1;
t = (angle-(a*90))/90;

//Lerp the thing
motors = cardDir[a] + t*cardDir(b); //Yes, I know b is completely unnecessary but it helped with readability imho 

//Scale it by the velocity

motors *= magitude
Turning is done by specifying a rate of turn and then multiplying the left motors by that percent and the right motors by the negative of the percent. (This part could be backwards, I can't recall)

This was written after we looked at the ugly mess of sines and cosines that did the same thing. We may have more than the 4 cardinal directions and may divide by less than 90 but I can't recall.

Not hard and allows for field centric controls given a good way of determining orientation.

EDIT: Yes, I left out the fact that you need to add the matrices but really it isn't hard.
__________________




.

Last edited by Andrew Schreiber : 13-04-2010 at 13:20.