Programming Error: Don't Know how to solve

Hello, This is Nicole from team 1662. I am following this Youtube video “https://www.youtube.com/watch?v=wqJ4tY0u6IQ&feature=youtu.be” and I have run into an error. If you go to 28:54 - 32 in the video that is the part I am having trouble with. My error is happening at “new DifferentialDriveOdometry(kinematics, getHeading());”
The error that it is giving me is “The constructor DifferentialDriveOdometry(DifferentialDriveKinematics, Rotation2d) is undefinedJava(134217858)”

This is my code

public class Drivetrain extends SubsystemBase {

TalonFX leftMaster = new TalonFX(3);
TalonFX rightMaster = new TalonFX(1);

TalonFX leftSlave = new TalonFX(2);
TalonFX rightSlave = new TalonFX(0);

PigeonIMU gyro = new PigeonIMU(0);

DifferentialDriveKinematics kinematics = new DifferentialDriveKinematics(Units.inchesToMeters(20));
DifferentialDriveOdometry odometry = new DifferentialDriveOdometry(kinematics, getHeading());

public Drivetrain() {

leftSlave.follow(leftMaster);
rightSlave.follow(rightMaster); 

leftMaster.setInverted(false);
rightMaster.setInverted(true);

}

public Rotation2d getHeading() {
return Rotation2d.fromDegrees(-gyro.getFusedHeading());
}

}

Thank You,
Nicole Stoddart

Click on the “quick fix” lightbulb that comes up when you click on the line where the error is. You may need to import a library for odometry.

The update method in DifferentialDriveOdometry has been updated to use encoder positions instead of encoder velocities (like in the video) and consequently, the kinematics parameter is no longer needed in the constructor.

I made the video during the beta testing period before this change was made. The trajectory tutorial on docs.wpilib.org has a more up-to-date explanation of what to do at this step.

1 Like

Thank you so much! That fixed the problem!

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