I got a error for MotorControllerGroup

this is the error : The constructor MotorControllerGroup(TalonFX, TalonFX, TalonFX) is undefinedJava(134217858)

here is the code:// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package frc.robot;

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

import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
import edu.wpi.first.wpilibj.motorcontrol.Talon;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;

/**

  • The VM is configured to automatically run this class, and to call the functions corresponding to
  • each mode, as described in the TimedRobot documentation. If you change the name of this class or
  • the package after creating this project, you must also update the build.gradle file in the
  • project.
    /
    public class Robot extends TimedRobot {
    /
    *
    • This function is run when the robot is first started up and should be used for any
    • initialization code.
      */
      //Drivetrain
      TalonFX motorRight1 = new TalonFX(0); //ID: 0
      TalonFX motorRight2 = new TalonFX(1); //ID: 1
      TalonFX motorRight3 = new TalonFX(2); //ID: 2
      MotorControllerGroup groupRight = new MotorControllerGroup(motorRight1, motorRight2,motorRight3);

private final TalonFX motorLeft1 = new TalonFX(4);//ID: 4
private final TalonFX motorLeft2 = new TalonFX(3); //ID: 3
private final TalonFX motorLeft3 = new TalonFX(5); //ID: 5
MotorControllerGroup groupLeft = new MotorControllerGroup(motorLeft1, motorLeft2, motorLeft3 );

//Controller
Joystick gamePad = new Joystick(0);
Joystick joystick = new Joystick(1);

@Override
public void robotInit()
{
//Inverted setting
groupRight.setInverted(false);
groupLeft.setInverted(true);
motorRight1.follow(motorRight2);
motorLeft1.follow(motorLeft2);
motorRight1.follow(motorRight3);
motorLeft1.follow(motorLeft3);

}

@Override
public void robotPeriodic() {}

@Override
public void autonomousInit() {}

@Override
public void autonomousPeriodic() {}

@Override
public void teleopInit() {}

@Override
public void teleopPeriodic() {}

@Override
public void disabledInit()
{

}

@Override
public void disabledPeriodic() {}

@Override
public void testInit() {}

@Override
public void testPeriodic() {}

@Override
public void simulationInit() {}

@Override
public void simulationPeriodic() {}
}

Use WPI_TalonFX instead of TalonFX

Have you tried using WPI_TalonFX instead of TalonFX?

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