mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Notify the Driver Station that code is ready after robotInit is called
Change-Id: Id833a2a945c14bcbb4761d4fe463c6c9f7c4430c
This commit is contained in:
@@ -61,12 +61,6 @@ public class IterativeRobot extends RobotBase {
|
||||
m_testInitialized = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prestart() {
|
||||
// Don't immediately say that the robot's ready to be enabled.
|
||||
// See below.
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an alternate "main loop" via startCompetition().
|
||||
*
|
||||
@@ -76,10 +70,7 @@ public class IterativeRobot extends RobotBase {
|
||||
|
||||
robotInit();
|
||||
|
||||
// We call this now (not in prestart like default) so that the robot
|
||||
// won't enable until the initialization has finished. This is useful
|
||||
// because otherwise it's sometimes possible to enable the robot
|
||||
// before the code is ready.
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramStarting();
|
||||
|
||||
// loop forever, calling the appropriate mode-dependent function
|
||||
@@ -171,7 +162,12 @@ public class IterativeRobot extends RobotBase {
|
||||
*
|
||||
* Users should override this method for default Robot-wide initialization
|
||||
* which will be called when the robot is first powered on. It will be called
|
||||
* exactly 1 time.
|
||||
* exactly one time.
|
||||
*
|
||||
* Warning: the Driver Station "Robot Code" light and FMS "Robot Ready"
|
||||
* indicators will be off until RobotInit() exits. Code in RobotInit() that
|
||||
* waits for enable will cause the robot to never indicate that the code is
|
||||
* ready, causing the robot to be bypassed in a match.
|
||||
*/
|
||||
public void robotInit() {
|
||||
System.out.println("Default IterativeRobot.robotInit() method... Overload me!");
|
||||
|
||||
@@ -148,18 +148,6 @@ public abstract class RobotBase {
|
||||
*/
|
||||
public abstract void startCompetition();
|
||||
|
||||
/**
|
||||
* This hook is called right before startCompetition(). By default, tell the
|
||||
* DS that the robot is now ready to be enabled. If you don't want for the
|
||||
* robot to be enabled yet, you can override this method to do nothing. If you
|
||||
* do so, you will need to call FRCNetworkCommunicationsLibrary.
|
||||
* FRCNetworkCommunicationOvserveUserProgramStarting() from your code when you
|
||||
* are ready for the robot to be enabled.
|
||||
*/
|
||||
protected void prestart() {
|
||||
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramStarting();
|
||||
}
|
||||
|
||||
public static boolean getBooleanProperty(String name, boolean defaultValue) {
|
||||
String propVal = System.getProperty(name);
|
||||
if (propVal == null) {
|
||||
@@ -213,7 +201,6 @@ public abstract class RobotBase {
|
||||
RobotBase robot;
|
||||
try {
|
||||
robot = (RobotBase) Class.forName(robotName).newInstance();
|
||||
robot.prestart();
|
||||
} catch (Throwable t) {
|
||||
DriverStation.reportError("ERROR Unhandled exception instantiating robot " + robotName + " "
|
||||
+ t.toString() + " at " + Arrays.toString(t.getStackTrace()), false);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.wpilibj.communication.UsageReporting;
|
||||
import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary;
|
||||
import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tInstances;
|
||||
import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
@@ -41,9 +42,13 @@ public class SampleRobot extends RobotBase {
|
||||
* Robot-wide initialization code should go here.
|
||||
*
|
||||
* Users should override this method for default Robot-wide initialization
|
||||
* which will be called when the robot is first powered on.
|
||||
* which will be called when the robot is first powered on. It will be called
|
||||
* exactly one time.
|
||||
*
|
||||
* Called exactly 1 time when the competition starts.
|
||||
* Warning: the Driver Station "Robot Code" light and FMS "Robot Ready"
|
||||
* indicators will be off until RobotInit() exits. Code in RobotInit() that
|
||||
* waits for enable will cause the robot to never indicate that the code is
|
||||
* ready, causing the robot to be bypassed in a match.
|
||||
*/
|
||||
protected void robotInit() {
|
||||
System.out.println("Default robotInit() method running, consider providing your own");
|
||||
@@ -116,11 +121,15 @@ public class SampleRobot extends RobotBase {
|
||||
public void startCompetition() {
|
||||
UsageReporting.report(tResourceType.kResourceType_Framework, tInstances.kFramework_Sample);
|
||||
|
||||
robotInit();
|
||||
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
FRCNetworkCommunicationsLibrary.FRCNetworkCommunicationObserveUserProgramStarting();
|
||||
|
||||
robotMain();
|
||||
if (!m_robotMainOverridden) {
|
||||
// first and one-time initialization
|
||||
LiveWindow.setEnabled(false);
|
||||
robotInit();
|
||||
|
||||
while (true) {
|
||||
if (isDisabled()) {
|
||||
|
||||
Reference in New Issue
Block a user