Bug in code

We are doing some off season protype and we wrote this code but have a bug we can not find the fix. Anyone know what the problem is?

The line is “m_robotDrive = new MecanumDrive(frontLeft, rearLeft, frontRight, rearRight);”

package frc.robot;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.MecanumDrive;
import edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax;
import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.can.TalonFX;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;

/** This is a demo program showing how to use Mecanum control with the MecanumDrive class. */
public class Robot extends TimedRobot {
private static final int kFrontLeftChannel = 1;
private static final int kRearLeftChannel = 4;
private static final int kFrontRightChannel = 2;
private static final int kRearRightChannel = 3;

private static final int kJoystickChannel = 0;

private MecanumDrive m_robotDrive;
private Joystick m_stick;

public void robotInit() {
TalonFX frontLeft = new TalonFX(kFrontLeftChannel);
TalonFX rearLeft = new TalonFX(kRearLeftChannel);
TalonFX frontRight = new TalonFX(kFrontRightChannel);
TalonFX rearRight = new TalonFX(kRearRightChannel);

// Invert the right side motors.
// You may need to change or remove this to match your robot.

m_robotDrive = new MecanumDrive(frontLeft, rearLeft, frontRight, rearRight);

m_stick = new Joystick(kJoystickChannel);


public void teleopPeriodic() {
// Use the joystick X axis for forward movement, Y axis for lateral
// movement, and Z axis for rotation.
m_robotDrive.driveCartesian(-m_stick.getY(), -m_stick.getX(), -m_stick.getZ());

What is the specific error that line gives?

This is what we get

You need to use WPI_TalonFX, not TalonFX.


Okay that worked thank you.

Make sure to hit the “solution” button next to the post to mark it as solved.

1 Like