SwerveDriveSpecialties / Do-not-use-swerve-lib-2022-unmaintained

29 stars 76 forks source link

Library crash on simulation #5

Open Ramtech59Sensei opened 2 years ago

Ramtech59Sensei commented 2 years ago

library crash when run in simulation mode. trace the problem to enable voltage compensation. I guess Rev Robotics is not doing motor controller simulation will be nice if library can report error but not stop execution will in simulation

Error at com.swervedrivespecialties.swervelib.rev.RevUtils.checkNeoError(RevUtils.java:10): Unhandled exception instantiating robot com.swervedrivespecialties.swervelib.rev.RevUtils java.lang.RuntimeException: Failed to enable voltage compensation: kParamMismatchType at com.swervedrivespecialties.swervelib.rev.RevUtils.checkNeoError(RevUtils.java:10) at com.swervedrivespecialties.swervelib.rev.NeoDriveControllerFactoryBuilder$FactoryImplementation.create(NeoDriveControllerFactoryBuilder.java:46) at com.swervedrivespecialties.swervelib.rev.NeoDriveControllerFactoryBuilder$FactoryImplementation.create(NeoDriveControllerFactoryBuilder.java:38) at com.swervedrivespecialties.swervelib.DriveControllerFactory.create(DriveControllerFactory.java:19) at com.swervedrivespecialties.swervelib.SwerveModuleFactory.create(SwerveModuleFactory.java:27) at com.swervedrivespecialties.swervelib.Mk4SwerveModuleHelper.createNeo(Mk4SwerveModuleHelper.java:184) at com.swervedrivespecialties.swervelib.Mk4SwerveModuleHelper.createNeo(Mk4SwerveModuleHelper.java:214) at org.frc.subsystems.DrivetrainSubsystem.(DrivetrainSubsystem.java:105) at org.frc.RobotContainer.(RobotContainer.java:24) at org.frc.Robot.(Robot.java:35) at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:289) at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:387) at java.base/java.lang.Thread.run(Thread.java:834) Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:303): Robots should not quit, but yours did!

Ramtech59Sensei commented 2 years ago

You can solve the problem in the library if you apply this changes for CtreUtils.java and RevUtils.java

public static void checkCtreError(ErrorCode errorCode, String message) { if (errorCode != ErrorCode.OK) { if (RobotBase.isReal()){ throw new RuntimeException(String.format("%s: %s", message, errorCode.toString())); } } }