FRC 2020 MecanumDrive Help plz

Hey everyone
We’re trying to code the daisy chain with TalonSRX for Mecanum Drive for the first time, after having used only sparks with Arcade Drive previous years. We used the WPI_TalonSRX() class in order to make them compatible with driveCartesian, but when we deploy the code and run it, going forward and back does some weird tilt, left and right make it spin, and twisting makes it move forward and backward. We double checked the ports, and have tried various combinations of XYZ out of desperation, but none have worked. Here is our code:

package frc.robot;

import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;

import com.ctre.phoenix.motorcontrol.ControlMode;

import edu.wpi.first.wpilibj.TimedRobot;

import edu.wpi.first.wpilibj.Joystick;


public class Robot extends TimedRobot {

WPI_TalonSRX fLeft = new WPI_TalonSRX(4);

WPI_TalonSRX fRight = new WPI_TalonSRX(1);

WPI_TalonSRX rRight = new WPI_TalonSRX(2);

WPI_TalonSRX rLeft = new WPI_TalonSRX(3);

private MecanumDrive drive;

private Joystick joystick;


public void robotInit() {



joystick = new Joystick(2);

drive = new MecanumDrive(fLeft, rLeft, fRight, rRight);



public void autonomousInit() {



public void autonomousPeriodic() {



public void teleopInit() {



public void teleopPeriodic() {

 drive.driveCartesian(joystick.getY(), joystick.getX(), joystick.getZ());



public void testInit() {



public void testPeriodic() {



It seems your robot is setup correctly, so to me the issue sounds like with how the joystick values are being read. Its possible that getY (and X and Z) are using the wrong axis for your joystick. You can look in the driver station USB tab to check the axis number, and then use getRawAxis. Also in my experience, the Y axis is inverted on joysticks (ie Y is positive when you pull it back).

One thing to check, is that mechanically, when viewed from above the robot, the wheels appear form an X shape.

\\\    ///

///    \\\

If they form an O, you’ve got the wheels on wrong and will get weird driving behaviour.

Few troubleshooting suggestions…

  1. Confirm the wheel orientation @bsimmons mentioned.
  2. Confirm the axes are correct. Y-axis is typically inverted as mentioned, but that should only affect forward/reverse, not strafing or rotation
  3. Put the robot up on blocks and run the following tests (ideally with values set by code, not from the joysticks): (ref:
    1. drive.driveCartesian(1.0, 0.0, 0.0); - All 4 wheels should spin forward (i.e. CW for right side, CCW for left when viewed from the respective side)
    2. drive.driveCartesian(0.0, 1.0, 0.0); - Right wheels should spin toward center, and Left should spin away from center (i.e. CCW for front wheels, and CW for rear wheels when viewed from the respective side)
    3. drive.driveCartesian(0.0, 0.0, 1.0); - Right wheels should spin toward back, and Left wheels should spin forward (i.e. CCW for all wheels when viewed from the respective side)

Let me know if and how your test varies from what I’ve described, and we’ll attempt to figure out where the fault is.


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.