I’m programming a tank drive train using Falcon 500. While I was programming and I went to put the motors on each side into a MotorControllerGroup I got this error The import edu.wpi.first.wpilibj.MotorControllerGroup cannot be resolved
Java(268435846). i
Can you share your code for this?
// 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 edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import com.ctre.phoenix.motorcontrol.can.TalonFX;
import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.MotorControllerGroup;
/**
- This is a demo program showing the use of the DifferentialDrive class, specifically it contains
- the code necessary to operate a robot with tank drive.
*/
public class Robot extends TimedRobot {
private DifferentialDrive m_myRobot;
private Joystick m_leftStick;
private Joystick m_rightStick;
private final TalonFX m_leftMotor1 = new TalonFX(0);
private final TalonFX m_leftMotor2 = new TalonFX(1);
private final TalonFX m_leftMotor3 = new TalonFX(2);
private final TalonFX m_rightMotor1 = new TalonFX(3);
private final TalonFX m_rightMotor2 = new TalonFX(4);
private final TalonFX m_rightMotor3 = new TalonFX(5);
@Override
public void robotInit() {
// We need to invert one side of the drivetrain so that positive voltages
// result in both sides moving forward. Depending on how your robot’s
// gearbox is constructed, you might have to invert the left side instead.
m_leftMotor1.setInverted(true);
m_leftMotor2.setInverted(true);
m_leftMotor3.setInverted(true);
MotorControllerGroup leftMotors = new MotorControllerGroup(m_leftMotor1, m_leftMotor2, m_leftMotor3);
MotorControllerGroup rightMotors = new MotorControllerGroup(m_rightMotor1, m_rightMotor2, m_rightMotor3);
m_myRobot = new DifferentialDrive(leftMotors, rightMotors);
m_leftStick = new Joystick(0);
m_rightStick = new Joystick(1);
}
@Override
public void teleopPeriodic() {
m_myRobot.tankDrive(-m_leftStick.getY(), -m_rightStick.getY());
}
}
edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup
Slightly different import path that was causing the issue.
Thanks
You’ll also need to consider this: WPI/NI Software Integration — Phoenix documentation
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.