mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Fix main function initialization (#1176)
I don't have a good way to ensure this always works, so this is going to be a documentation issue. But initializeHardwareConfiguration is now reentrant, so we can just have all tests call it.
This commit is contained in:
committed by
Peter Johnson
parent
f5b1028b5a
commit
89d15f061b
@@ -21,8 +21,6 @@ import edu.wpi.first.wpilibj.hal.FRCNetComm.tInstances;
|
||||
import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.wpilibj.hal.HAL;
|
||||
import edu.wpi.first.wpilibj.hal.HALUtil;
|
||||
import edu.wpi.first.wpilibj.internal.HardwareHLUsageReporting;
|
||||
import edu.wpi.first.wpilibj.internal.HardwareTimer;
|
||||
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
|
||||
import edu.wpi.first.wpilibj.util.WPILibVersion;
|
||||
|
||||
@@ -84,7 +82,6 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
* to put this code into it's own task that loads on boot so ensure that it runs.
|
||||
*/
|
||||
protected RobotBase() {
|
||||
initializeHardwareConfiguration();
|
||||
NetworkTableInstance inst = NetworkTableInstance.getDefault();
|
||||
setupCameraServerShared();
|
||||
inst.setNetworkIdentity("Robot");
|
||||
@@ -198,24 +195,6 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common initialization for all robot programs.
|
||||
*/
|
||||
public static void initializeHardwareConfiguration() {
|
||||
if (!HAL.initialize(500, 0)) {
|
||||
throw new IllegalStateException("Failed to initialize. Terminating");
|
||||
}
|
||||
|
||||
// Set some implementations so that the static methods work properly
|
||||
Timer.SetImplementation(new HardwareTimer());
|
||||
HLUsageReporting.SetImplementation(new HardwareHLUsageReporting());
|
||||
RobotState.SetImplementation(DriverStation.getInstance());
|
||||
|
||||
// Call a CameraServer JNI function to force OpenCV native library loading
|
||||
// Needed because all the OpenCV JNI functions don't have built in loading
|
||||
CameraServerJNI.enumerateSinks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting point for the applications.
|
||||
*/
|
||||
@@ -226,6 +205,10 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
throw new IllegalStateException("Failed to initialize. Terminating");
|
||||
}
|
||||
|
||||
// Call a CameraServer JNI function to force OpenCV native library loading
|
||||
// Needed because all the OpenCV JNI functions don't have built in loading
|
||||
CameraServerJNI.enumerateSinks();
|
||||
|
||||
HAL.report(tResourceType.kResourceType_Language, tInstances.kLanguage_Java);
|
||||
|
||||
String robotName = "";
|
||||
|
||||
Reference in New Issue
Block a user