I have no idea why the issue with this program escapes me. I have been looking at it for days with no headway. Maybe a new set of eyes can see the problem. The program is simple. It uses my XBox class to control a four motor arcade drive system using one of the joysticks on the controller. Some buttons then control a couple accessory motors.
Not sure what is causing your error yet, but it sounds like an undefined pointer.
But you should move a few lines around in your Motor1 and Motor2 classes. Right now you have the instantiation of the SpeedController above your constructor.
SpeedController motor = new Victor(4);
public Motor1() {
}
change it to.
Private SpeedController motor;
public Motor1(){
motor = new Victor(4);
}
ERROR Unhandled exception: java.lang.IllegalArgumentException: Subsystem must not be null. at [edu.wpi.first.wpilibj.command.Command.requires(Command.java:194), org.usfirst.frc.team4623.robot.commands.Extend.<init>(Extend.java:16), org.usfirst.frc.team4623.robot.OI.<init>(OI.java:56), org.usfirst.frc.team4623.robot.Robot.robotInit(Robot.java:44), edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:72), edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:241)]
Just a quick question. Are you reading the errors or just posting them here? It’s ok if you are because they aren’t the most lovely things to read (though you should try. It’ll be much faster) What it’s giving you is what’s called a stack trace. It basically tells you the path the code took before it got an error. I’ve added a comment on what the error tells you.
ERROR Unhandled exception: java.lang.IllegalArgumentException: Subsystem must not be null. at
edu.wpi.first.wpilibj.command.Command.requires(Com mand.java:194), #6
org.usfirst.frc.team4623.robot.commands.Extend.<in it>(Extend.java:16), #5
^------------This is the file-------------------------^---------------Line #- ^
org.usfirst.frc.team4623.robot.OI.<init>(OI.java:5 6), #4
org.usfirst.frc.team4623.robot.Robot.robotInit(Rob ot.java:44), #3
du.wpi.first.wpilibj.IterativeRobot.startCompetit ion(IterativeRobot.java:72), #2
edu.wpi.first.wpilibj.RobotBase.main(RobotBase.jav a:241)] #1
So you start at the bottom and read up. Notice how it goes to robotInit at #3, then goes into OI at 4, then to the Extend class. At Line 16 (note my comment in the code) is where the error is. Looking at line 16 in the code shows
requires(Robot.pnue);
Looking in the Robot class I can see pneu, but the problem is it’s initialized AFTER OI. So OI is looking for a null object, hence the error. Try putting OI after everything.
The problem is when you create a new OI object, it looks for robot.pneu. But as you can see pneu hasn’t been created because it is after new OI(). So put new OI below the creation of everything else (in this case swap them).
Okay that makes perfect sense. I did trace it back and could deduct that it had something to do with the extend class but never thought of movie the onus constructor
Ok I think the problem is when you call the retract command you create a new solenoid on ports 0 and 1. Don’t do this. If you call the retract command more than once (or call the extend command once) then you can’t call it again because it tries to create a new solenoid. Create the solenoid somewhere and pass it to the command.