Our programming team has decided to make the switch from LabVIEW to Java over the summer. After getting over the initial bit of the learning curve, everything has been running fairly smoothly until today. The driver station keeps fluctuating between “Teleoperated Disabled” and “No Robot Code” every 5 seconds or so, with the com light on the rio changing from green to red with it. If I enable when it thinks it has code, it disables a few seconds later with “No Robot Code.” I’ve tried resetting the rio, reinstalling Java onto it, trying a new ethernet cord, restarting the robot, and redeploying code but the com light still keeps changing back and forth. Any help would be appreciated!
Can you post your code? Sounds to me like it’s crashing on initialization.
For context, we’re working on a breadboard. This is just some sample code with a ton added to it as we try to figure things out one component at a time, so sorry if it’s messy. The same code was working fine two days ago.
package org.usfirst.frc.team3146.robot;
import com.ctre.CANTalon;
import com.ctre.CANTalon.TalonControlMode;
import edu.wpi.first.wpilibj.*;
public class Robot extends SampleRobot {
private static final int True = 0;
final int kPotChannel = 0;
CANTalon talon = new CANTalon(3);
private SpeedController motor = new CANTalon(3);
private SpeedController motortwo = new Talon(0);
private Joystick stick = new Joystick(0);
AnalogInput potentiometer = new AnalogInput(kPotChannel);
DigitalInput home = new DigitalInput(4);
Solenoid blue = new Solenoid(1, 7);
Solenoid red = new Solenoid(1, 4);
Solenoid green= new Solenoid(1, 5);
Solenoid yellow = new Solenoid(1, 6);
Solenoid click = new Solenoid(1, 0);
Solenoid clicky = new Solenoid(1, 1);
private final double kUpdatePeriod = 0.005;
public Robot() {
}
@Override
public void operatorControl() {
while (isOperatorControl() && isEnabled()) {
motor.set(stick.getY());
double servo = potentiometer.getAverageVoltage();
motortwo.set(servo);
boolean buttonValue1 = stick.getRawButton(1);
if (buttonValue1 == true)
blue.set(true);
else
blue.set(false);
boolean buttonValue6 = stick.getRawButton(6);
if (buttonValue6 == true)
click.set(true);
else
click.set(false);
boolean buttonValue7 = stick.getRawButton(7);
if (buttonValue7 == true)
clicky.set(true);
else
clicky.set(false);
boolean buttonValue4 = stick.getRawButton(4);
if (buttonValue4 == true)
red.set(true);
else
red.set(false);
boolean buttonValue5 = stick.getRawButton(5);
if (buttonValue5 == true)
green.set(true);
else
green.set(false);
boolean buttonValue2 = stick.getRawButton(2);
if (buttonValue2 == true)
yellow.set(true);
else
yellow.set(false);
Timer.delay(kUpdatePeriod); // wait 5ms to the next update
}
}
}
Try loading in some extremely basic code. Basically a new project with nothing added. See if that lets you connect properly without dropping. If so, you’ll know it’s something in your code specifically. You can then incrementally add functionality from your original project until it breaks again, letting you identify the part that’s causing an issue.
I deleted one line from the code and everything’s back to normal. Thanks for the help!
Out of curiosity mind sharing what it was? I’m always looking to learn how people solved their issues so I can better assist teams.
Not OP but I’ve personally had this issue happen randomly multiple times over the last two years. That is, losing robot code after some minor changes that create no errors. Sometimes the changes could be something as minor as changing a constant from one value to another. Undoing back to what it was on the last deploy, deploying, then making the changes and deploying the changed code seemed to fix it, which led me to think that it is something to do with the building/deploying process.
In my experience this is almost always caused by an exception during code initialization. A common cause is using a subsystem before it is initialized, but there are others.
When it happens check your console log for clues.