RobotState for FTC Programming

Within the wpilibj, there is a RobotState class used by the CommandSchedular to determine whether a robot is enabled, disabled, in auto, etc. It makes a call to the Driverstation.

Is there a comparable class for FTC where similar information can be pulled from?

Update 1:
There is an isRobotRunning( ) method in the FTCRobotControllerActivity class, but it is private.

Within the External qualcomm libraries, there is a Enum called RobotState. It appears one can call robot.eventLoopManager.state to get the current state. Will confirm that this is correct upon testing.

While that’s true, I have found that it’s hard to get an instance of EventLoopManager to instantiate the Robot class you need to call that function robustly. It seems more effective to directly modify FtcRobotControllerActivity.java (which is legal via <RS08b>) where the state is freely accessible or the instantiating materials are available. Then, you can get an instance of FtcRobotControllerActivity.java by also including a getInstance() function in it as well. That’s more work I suppose, but it’s the best way that I’ve found to do it so far.

1 Like

Yeah, it seems like some sort of modification of the FTCcontroller files will be necessary.

What about modifying the FtcRobotControllerService class so that the onStateChange() method would update an public class that the state could be pulled from. That way, the protected nature of the FtcRobotControllerActivity.java’s variables would remain as originally intended.

Well, that would work but it’s illegal - part of the pre-packaged .aar files. What are you trying to do with the state?

I don’t know anything about FTC Java, but you could use reflection to see the state of that variable.

Or, you could make a getter function for controllerService. Admittedly, it is protected, but that would still make it possible to get an instance of Robot as done in isRobotRunning().

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.