^ The above is an image that displays the intended/actual behavior found in my team’s Mecanum code.
Our Team’s Forward/Backwards and Left/Right strafing works great. However, when trying to turn using wpilibj’s MecanumDrive, the wheels spin incorrectly and the robot basically sputters in place.
package frc.robot;
//Blah Blah imports, you (or your IDE) know what's here
public class Robot extends TimedRobot
{
private SparkMaxMotor leftRear; // SparkMaxMotor is just a wrapper around CANSparkMax, yes I know about the deprecation
private SparkMaxMotor rightRear;
private SparkMaxMotor leftFront;
private SparkMaxMotor rightFront;
private final XboxController controller = new XboxController(0);
private MecanumDrive drive; // wpilib mecanumdrive
@Override
public void robotInit()
{ // motor = new SparkMaxMotor(id, MotorType)
leftRear=new SparkMaxMotor(0, CANSparkMaxLowLevel.MotorType.kBrushless);
rightRear=new SparkMaxMotor(1, CANSparkMaxLowLevel.MotorType.kBrushless);
leftFront=new SparkMaxMotor(2, CANSparkMaxLowLevel.MotorType.kBrushless);
rightFront=new SparkMaxMotor(3, CANSparkMaxLowLevel.MotorType.kBrushless);
drive = new MecanumDrive(leftFront, leftRear, rightFront, rightRear);
}
@Override
public void teleopPeriodic()
{
double y = controller.getLeftY();
double x = controller.getLeftX();
double turn = controller.getRightX();
drive.driveCartesian(y, x, turn);
}
public void periodic() {
leftRear.periodic();;
rightRear.periodic();
leftFront.periodic();
rightFront.periodic();
}
}
- Kaiden McMartin, 5183