Help with deploying Java

This year we are trying to switch to Java, and have already rewrote our existing C++ code in Java. When we initially tried to deploy Java to our robot, we encountered a deploy error. This was rectified when we downloaded the JVM and deploying now executes without errors. However, the driver station says “no robot code” after deploying. Does anyone have a comprehensive checklist of things that must be done in order to deploy Java code to the roborio successfully? Our code is here:

Are there any error messages on the right side of the driverstation? (clear the log and redownload it to make sure)

If the download succeeds you are likely seeing an exception. I would try the advice about the DS messages window above first. If that doesn’t work I would try rioLog:

The error messages on the right side of the driverstation are below.

➔ Launching «’/usr/local/frc/JRE/bin/java’ ‘-jar’ ‘/home/lvuser/FRCUserProgram.jar’»
edu.wpi.first.wpilibj.networktables2.server.ServerConnectionAdapter@881f78 entered connection state: GOT_CONNECTION_FROM_CLIENT
edu.wpi.first.wpilibj.networktables2.server.ServerConnectionAdapter@881f78 entered connection state: CONNECTED_TO_CLIENT
Drivetrain constructor called
ERROR Unhandled exception: edu.wpi.first.wpilibj.util.AllocationException: PWM channel 0 is already allocated at [edu.wpi.first.wpilibj.PWM.initPWM(, edu.wpi.first.wpilibj.PWM.<init>(, edu.wpi.first.wpilibj.SafePWM.<init>(, edu.wpi.first.wpilibj.Victor.<init>(, org.usfirst.frc.team8.subsystems.Lifter.<init>(, org.usfirst.frc.team8.robot.Robot.robotInit(, edu.wpi.first.wpilibj.IterativeRobot.startCompetition(, edu.wpi.first.wpilibj.RobotBase.main(]
WARNING: Robots don’t quit!
—> The startCompetition() method (or methods called by it) should have handled the exception above.

At the risk of being unhelpful, this one should be pretty straightforward to find and it’s important to learn how to debug these.

Start with the error itself

ERROR Unhandled exception: edu.wpi.first.wpilibj.util.AllocationException: PWM channel 0 is already allocated

Then look towards the end of the call chain (the text after the error I quoted) to figure out where in the code the error is happening. That should help you figure out what’s going on. If you can’t figure it out, let us know and I or someone else can help more (I did find the error in the code).

I did look into this, and I thought that the error was conflicting port numbers. So I went to line 25 in lifter, and changed that port around to many different numbers. However, each time I would redeploy and the same error would occur, which confused me. Any thoughts? Thanks.

EDIT: This was after some changes to ports were made on the driver station, which unfortunately aren’t pushed. The new error is basically the same as the old one, except it is on line 25 in lifter and complains that PWM 1 is allocated. However, changes to the port on line 25 in lifter have no effect.

After looking a bit more closely, we understand a bit more on what the PWM issue is about. However we aren’t sure if there is a step we are missing in the initialization of our Victors/Talons etc. We thought that changing ports would help fix it, but we haven’t figured out which ports are conflicting?

Also we have no idea what the start competition method is or is supposed to be, there was no such method in C++ as far as we recall.

In general are there some resources that go beyond the documentation or sample iterative robot code we could look at?

The error is conflicting port numbers. Something is opening PWM 0 before Lifter is (or PWM 1 after you changed it).

PWM 0-3 are assigned to the drivetrain based on lines 11-14 of /robot/ and lines 75-78 of /subsytems/

Is there a reason is not using PORT_LIFTER_VICTOR_1 and PORT_LIFTER_VICTOR_2 from

Changing the port on the line causing the exception must have an effect if the change is saved, builds properly and deploys properly, the exception clearly reports the line it occurs on. At a minimum making a change should change the port with a conflict, if you pick a port that is actually free it will clear the exception.

EDIT: StartCompetition exists in C++ as well, you just never went looking for it. The differences between the C++ and Java versions of WPILib are pretty small, the C++ equivalent of the code you have here would fail in a very similar manner.

The latest code has now been pushed, I did indeed find some port conflicts which have now been fixed. Thanks guys! I will test tomorrow and get back to you all.

So when I pulled the new code and tried to deploy, the same error appeared. We managed to get the robot code to appear and run after we commented out the lifter though.