Mecanum and Encoders

We have mecanum wheels with attached Optical Quadrature Encoders. They’re hooked up to our CAN Jaguars.

Right now, the wheels are turning at different speeds. And we want them to turn at the same speed because our mecanum system is hard to manually adjust on the field.

Is there a way to use the encoder values to dynamically regulate the speeds of the wheels? Or should we just use the encoders, get some values, find a magic number, and program them in?

We’re using Java.

Look at using the speed control mode of the jaguar. Are you using CAN or pwm?

If you use CAN you can use the speed control mode other wise you need to hook the encoders to the cRio and use PIDController.

As an example for speed control.

CANJaguar jag = new CANJaguar(channel, CANJaguar.ControlMode.kSpeed);
jag.setPID(P, I, D);

replace the following:
channel with the jag number
ENCODER_TICKS with how many pulses per revolution the encoder is
P I and D with your Proportional Integral and Derivative terms

To figure out your PID values you will need to do some tuning. Head over the the Technical->Electrical->CAN section there are many threads there.

When you go to set the value of the jag set it to the speed in RPM not -1 to 1. so for example we limited our output to 400 rpm in normal mode.

jag.set(joystick1.getY() * 400);