Mecanum Drifting

We have been working on a mecanum chassis for this years competition. We are using the mecanum cartesian function provided in the library. We feed it the following values.

(joystickx, joysticky, joysticktwist, 0.0)

The robot drives fine using this except it seems to drift one way quite a bit (especially at lower speeds). We have been trying to correct for this in the programming, but to no avail.

The motors are configured like this
| = andymark toughbox

  • or _ = cim

|- -|
|_ _|

And the chains go from the output straight to the wheel (so nothing fancy there). In the code we had to invert two of the motors so they would spin in the right direction. I was wondering if that would cause the robot to drift because of the cims spinning slower in reverse.

I would just like to gather input from the community because I have racked my brain on this one for a while.

Is it mechanical / electrical?
If not suggestions for how to fix the drifting in the code?

Are you using Victors or Jaguars to control the motor? How are you defining the four motors in your initialization code?

We are using Victors

RobotDrive *m_robotDrive;
m_robotDrive = new RobotDrive(1, 2, 3, 4);

we inverted the right hand side motors in the code by doing this

m_robotDrive->SetInvertedMotor(RobotDrive::kFrontRightMotor, true);
m_robotDrive->SetInvertedMotor(RobotDrive::kRearRightMotor, true);

I think that’s the root of your problem. The version of the RobotDrive constructor that takes four PWM channel numbers sets them up as Jaguars. You need to open four Victors and pass them to the version of the RobotDrive constructor that takes four motor references.

The reason this makes a difference is that the factory-calibrated neutral PWM value for a Victor is slightly higher than the neutral PWM value for a Jaguar. Because of the incorrect translation from -1…1 speed control to PWM pulse width, you’ll end up running motors a bit faster in reverse than with the same forward speed command. In your case, the right motors will go faster than the left ones when you’re driving forward. At very low speeds, the difference will be relatively large.

Definitely makes sense, I see that in the RobotDrive source it defaults to jaguars.

You need to open four Victors and pass them to the version of the RobotDrive constructor that takes four motor references.

I will give this a try sometime tomorrow and let you know how it turned out.

Thanks a ton for the help!

Just wanted to say that this did indeed fix our problem!

Thank you very much Alan!