Simulating Robot Code in WPILIB causes several errors to appear

I’m new to programming this year, and I have had several issues trying to figure out the program. I finally got it to display no problems, but when I try to simulate the robot code, several errors show up that I’m not completely sure how to fix.
I am also not 100% sure what pneumatics or compressor modules I should be using for this program.
Any help is greatly appreciated.

Error at frc.robot.Robot.(Robot.java:52): Unhandled exception instantiating robot edu.wpi.first.wpilibj.PneumaticsBase java.lang.IllegalArgumentException: Unknown module type
at edu.wpi.first.wpilibj.PneumaticsBase.getForType(PneumaticsBase.java:21)
at edu.wpi.first.wpilibj.Compressor.(Compressor.java:35)
at frc.robot.Robot.(Robot.java:52)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:322)
at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:443)
at java.base/java.lang.Thread.run(Thread.java:829)

(https://github.com/Smitefall/FRC-Drive-Train/blob/22dbe27f6743a9d06b29346263a6d247b12b0ee9/Team%207654%20Drive%20Train)

You’re giving the compressor constructor null instead of a module type. Replace null with PneumaticsModuleType.CTREPCM like you did with the solenoid.

Thank you! That actually got the simulator working; now I’m trying to figure out the errors for the driving of the robot:

at frc.robot.Robot.(Robot.java:52)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:322)
at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:443)

You’re missing the actual error. I recommend reading through this page a few times. Reading Stacktraces — FIRST Robotics Competition documentation

1 Like

You’re getting into the world of understanding the difference between compile time and run time errors.

Here’s a decent write up explaining this conceptually in Java.

So, what Fletch said is correct, you need to learn how to read the stacktrace so you can properly identify your runtime errors. The stacktrace will typically tell you exactly what is wrong, and which file and line number where the error happened so they can be quite informative.

1 Like