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.
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:
// 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
Yes. First check the hardware to make sure it is working properly.
Load the default 4-motor tank drive code that came with the Framework, and test your robot with that, with the robot on blocks so you can observe the wheels.
Once you’ve got that working properly, THEN load your mecanum code and debug it (see my previous post).
I don’t understand what you mean. Do you want to use a gyro and “just have it work”, or do you not want to use a gyro at all? There’s no connection I can think of between using a gyro and the choice of polar vs. cartesian mecanum drive control.
If you don’t want to use the gyro at all, you can wire (LabVIEW) a zero constant to gyro on the holonomic VI. It will then drive normally without any respect to the gyro/field orientation, just like simple tank/arcade/etc. drive. I found this by looking at the help page for that VI.