mechanum with talon closed loop

Does anyone know how to use MecanumDrive_Cartesian() if you also want to use velocity closed loop on a can Talon?

From what I read, the PID in velocity loop built into them require native units : I.E. that means that you set it up in terms of feedback counts per 100mS (for instance, if I get 10,000 counts per second, then 100% speed is 1000 and the 100% command I send is also 1000)

But the input to MecanumDrive_Cartesian() is up to ±1. Somehow the PID needs to go in between this call and the write to the Talon

RobotDrive uses a scale up to m_maxOutput, which defaults to kDefaultMaxOutput, a constant with value 1.0. You can’t just change m_maxOutput, since it’s a protected field, but if you extend RobotDrive with a new class that adds nothing except a wrapper for the particular constructor you need, you can set it there.


public class MyRobotDrive extends RobotDrive {
    public MyRobotDrive(SpeedController frontLeftMotor, SpeedController rearLeftMotor,
                        SpeedController frontRightMotor, SpeedController rearRightMotor) {
        super(frontLeftMotor, rearLeftMotor, frontRightMotor, rearRightMotor);
        m_maxOutput = 8500; // 100% wheel speed in encoder velocity units
    }
}

There may be a way to rescale at the Talon SRX level with something like configEncoderCodesPerRev(), but the above does work.

To follow up, we ended up doing a :

robotDrive.SetMaxOutput(387)

where 387 represents the motor at 100%, and this is the number of pulses that we got back from the quadrature encoder per 100mS no load.

The PIDF then scaled to those units fine. We used the software manual routing of first setting F to the proportionality to speed, a P until just before it oscillates ,and then some I.