Error in mecanumDrive_Polar of WPILIBJ

We determined that the mecanum drive function has an error. Specifically the line
double sinD = Math.cos(dirInRad);
should be
double sinD = Math.sin(dirInRad);

Can someone provide information on how to get this fixed in the WPILIBJ library.


What we do when this kind of thing happens is just copy the entire FRC supplied class into our package and correct the part that seems wrong. And use the one in our package instead of the one in wpilib.

Good catch! This explains why mecanumDrive_Polar() isn’t working. Thanks.

I added this as a bug at as artf1315.

Does the problem exist in mecanumDrive_Cartesian too? We’re seeing similar problems.

This is what we’re doing:

drive.mecanumDrive_Cartesian(lstick.getX(), lstick.getY(), rstick.getX(), gyro.getAngle());

I have experienced problems with mecanumDrive_Cartesian too. It actually works when I put a fixed 0 degrees or 180 degress in the angle input. However, other values have not worked for me (from what I remember). I have spent some time trying to figure out the problem. No luck yet. But rotateVector() in RobotDrive is okay. Our team got field relative driving running by using rotateVector() to manually transform coordinates.

Is there any way to get a working mecanum drive until mecanumDrive_Polar() is fixed?

You could write your own. It’s not that hard. Here’s some help.


There sure is, Patrick explained how in post #2:

attatched should be enough to be a better mecanum drive with no black box

You just did get it fixed. Will be in the next release. Thanks for the patch!