Setting custom disable behaviors

Tried the following snippet on DisabledInit() and DisabledPeriodic(). Neôther worked.

@Override
Public void DisabledInit()
{
Super.DisabledInit();
LED.disable();
}

It didn’t like the override. I may have typed it in wrong, as I’m going off of 2-month old memory, but still.

How do I get this to work?

Should be


public void disabledInit()
{
    super.disabledInit();
    LED.disable();
}


Unfortunately annotations are not supported in the version of java that runs on the cRIO.

Note that disabled, by definition, disables all outputs, regardless of what code you write. This is a safety feature (or “feature”, depending on who you talk to.) It doesn’t look like you’re trying to activate any inputs, but it’s something to be aware of when customizing disable code.

Is there an alternate way to override then?

You don’t need annotations to actually override, just using the same method signature will override the method.

In that case, where do I put it? Because I tried this, and I distinctly remember it not working. I’m thinking I must have put it in the wrong place or something, maybe.

Only PWM and Relay outputs are disabled. Digital In, Digital Out, and Analog In are all fully functional during the disabled state of the robot. You can set digital output pins high or low in disabled. Digital IO should never be used to drive actuators as per FRC rules, which is why its state are allowed to be commanded during disable.

Unless you are creating a new class which extends IterativeRobot, the super.DisableInit() does not exist. That implies that disabledInit() exist in the parent class you are inheriting from.

The first definition of DisabledInit() is in the IterativeRobot class, so is you are trying to call super.DisabledInit() inside of IterativeRobot, or CommandBasedRobot, that is probably why its failing.

Also do not include any @override annotations, as mentioned already they are not supported by the JVM on the cRIO.

Hope this helps,
Kevin

While this helps explain why it doesn’t work, it doesn’t explain how to make it work. Should I just put that in robotcode.java and see what happens?

I am not sure what file robotcode.java is. If that is the file where you have disableInit. Then yes.

It would be helpful if you pasted you full file so we can better assist you.

Importantly, it’s not DisabledInit(), but rather disabledInit(). Capitalization matters. The same thing goes for DisabledPeriodic() - it’s disabledPeriodic().

If you aren’t sure if the code is getting called, you can try adding


System.out.println("Yes, I'm working properly.");

to the method.