assert in initializeHardwareConfiguration() in RobotBase

These are the first few lines of the initializeHardwareConfiguration() method in the RobotBase class of a version of the Java FRC libraries:

    int rv = HAL.initialize(0);
    assert rv == 1;

    // Set some implementations so that the static methods work properly
    Timer.SetImplementation(new HardwareTimer());
    HLUsageReporting.SetImplementation(new HardwareHLUsageReporting());

The lower lines should provide some context; I really like seeing the internals of what a robot program actually does.

I was under the impression that assert was only to be used in development, to check that an operation was done correctly. Does anyone know what HAL.initialize() returns or what the argument means? The HAL class doesn’t shed light on it because it’s a native method which accepts an int that is just called mode. My guess is rv is short for return value.

Presumably a return value of 1 means “success” and 0 means “failure”. Here is where HAL_Initialize() is implemented, which is what the Java wrapper calls. It doesn’t appear to return anything other than 0 or 1 (0 in a few error conditions, 1 otherwise). “mode” only affects behavior when another robot process is running and couldn’t be killed normally.