View Single Post
  #2   Spotlight this post!  
Unread 15-01-2011, 13:03
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
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: Mecanum Problems

Quote:
Originally Posted by captainking View Post
Hey guys, we're trying to program mecanum this year using the polar form but we're having some troubles.

For magnitude we are taking the x and y values of the joystick and using the pythagorean theorem

For direction we are taking the y value and dividing by the x value, taking the arctangent, and then multiplying by 180/pi in order to get the answer in degrees.

for rotation we are using the rotation axis off of our 3 axis controller.



For some reason, when we enable the robot, the motors all recieve full forward PWM values without us touching the controller.

We've checked the wiring and it's fine, and the only thing affecting the motors is the holonomic drive function.

Any ideas?
When X is zero, are you dividing by zero? This may not be the cause of the problem you described, but you should look into it.

Dividing Y by X and taking the arctangent isn't going to give the right answer in all quadrants. Try it in an Excel spreadsheet and see what I mean.

Why are you using the polar form? If you are using a 3-axis joystick and LabVIEW, just feed the 3 axis values directly into the cartesian form. No math required.

If you want to code it yourself in a text language, here's some reference code:

Code:
// 3-axis joystick interface to a mecanum or omni drive


// first define your driver interface,
// in this case a 3-axis joystick:


forward = -Y;   // push joystick forward to go forward
right = X;      // push joystick to the right to strafe right
clockwise = Z;  // twist joystick clockwise turn clockwise


// here is where you would put any special shaping of the joystick
// response curve, such as deadband or gain adjustment


// now apply the inverse kinematic tranformation
// to convert your vehicle motion command 
// to 4 wheel speed commands:

front_left = forward + clockwise + right;
front_right = forward - clockwise - right;
rear_left = forward + clockwise - right;
rear_right = forward - clockwise + right;


// finally, normalize the wheel speed commands
// so that no wheel speed command exceeds magnitude of 1:

max = abs(front_left);
if (abs(front_right)>max) max = abs(front_right);
if (abs(rear_left)>max) max=abs(rear_left);
if (abs(rear_right)>max) max=abs(rear_right);

if (max>1) 
  {front_left/=max; front_right/=max; rear_left/=max; rear_right/=max;}


// you're done. send these four wheel commands to their respective wheels



Reply With Quote