Log in

View Full Version : My mecanum method wont strafe


Robototes2412
16-02-2010, 11:55
I wrote this after looking at some documentation someone wrote up.


public void mechanumDrive(double v, double r, double s){
/*
* You all love Dr. Tran, so Try His mega-awesome MECANUM DRIVE!!!
*/
double FLval; double FRval; double RLval; double RRval;
FLval = v - r - s;
FRval = v + r + s;
RLval = v - r + s;
RRval = v + r - s;

FLjag.set(FLval);
FRjag.set(FRval);
LRjag.set(RLval);
RRjag.set(RRval);

/*if (leftStick.getRawButton(2)) {
v = v * Math.sqrt(2.0);
double dirInRad = (s + 45.0) * 3.14159 / 180.0;
double cosD = Math.cos(dirInRad);
double sinD = Math.sin(dirInRad);

FLval = sinD * v - r;
FRval = cosD * v + r;
RLval = sinD * v + r;
RRval = cosD * v - r;

FLjag.set(FLval);
FRjag.set(FRval);
LRjag.set(RLval);
RRjag.set(RRval);

}*/

}

void rawStrafe(String direction, double speed) {
direction.toLowerCase();
if (direction.compareTo("left") == 0) {
FLjag.set(-speed);
FRjag.set(speed);
RRjag.set(-speed);
LRjag.set(speed);
} else if (direction.compareTo("right") == 0) {
FLjag.set(speed);
FRjag.set(-speed);
RRjag.set(speed);
LRjag.set(-speed);
}
}



I cannot get either if these to strafe. what happens when I try is the wheels "stick" in place (thats about the best way I can describe it)

BradAMiller
16-02-2010, 15:55
There is a macanum drive method built into the RobotDrive class in WPILib. If you create a RobotDrive object with the port numbers for the 4 SpeedControllers, you can call the holonomicDrive method that takes a direction (X and Y value) and a rate of rotation. There are a number of teams that are using that code and it seems to be working for them.

If you would like to write it yourself, feel free to check out the source code for that class. The math is pretty well tested.

Robototes2412
16-02-2010, 16:34
the holoNomic Drive function wont let my robot go forwards

BradAMiller
16-02-2010, 17:13
the holoNomic Drive function wont let my robot go forwards

It's designed for 4 macanum wheels toed in 45 degrees. Is that what you have?

Here are the comments for the holonomicDrive method:
/**
* Holonomic drive class for Mecanum wheeled robots.
*
* Experimental class for driving with Mecanum wheeled robots. There are 4 wheels
* on the robot, arranged so that the front and back wheels are toed in 45 degrees.
*
* For holonomic drive with omni-wheels, the rotation value will need to be
* offset based on the drive configuration.
*
* @param magnitude The speed that the robot should drive in a given direction.
* @param direction The direction the robot should drive in degrees. The direction and maginitute are
* independent of the rotation rate.
* @param rotation The rate of rotation for the robot that is completely independent of
* the magnitute or direction.
*/

Robototes2412
16-02-2010, 17:58
We have the wheels as such (birds-eye view):
\/
/\

(from bottom)
/\
\/

Daedalus
16-02-2010, 19:26
We have the wheels as such (birds-eye view):
\/
/\

(from bottom)
/\
\/

You need to switch your wheels. The bottom view should look like your top view currently does. That should fix your problem, the reason your robot will not work right now is because the force vectors are incorrect and will prevent your robot from moving.

jhersh
17-02-2010, 02:51
You need to switch your wheels. The bottom view should look like your top view currently does. That should fix your problem, the reason your robot will not work right now is because the force vectors are incorrect and will prevent your robot from moving.

Actually he has it correct and you are recommending that he make it wrong. The bottom should be a diamond.

Robototes2412
17-02-2010, 13:18
then we spent an hour switching the wheels for nothing?

jhersh
17-02-2010, 14:04
then we spent an hour switching the wheels for nothing?

It would seem so. It appears that is the only post that user account has made. Perhaps if you had searched you would have seen this thread (http://www.chiefdelphi.com/forums/showthread.php?t=63421) or this thread (http://www.chiefdelphi.com/forums/showthread.php?t=52672) or this thread (http://www.chiefdelphi.com/forums/showthread.php?p=907174#post907174).

Searching is your friend... you don't have to wait for a reply and others don't have to keep answering the same questions.

-Joe