Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Robot should not be restarted in onStart() #11

Closed
Windwoes opened this issue Aug 1, 2019 · 3 comments
Closed

Robot should not be restarted in onStart() #11

Windwoes opened this issue Aug 1, 2019 · 3 comments

Comments

@Windwoes
Copy link
Member

Windwoes commented Aug 1, 2019

Currently onStart() in FtcRobotControllerActivity contains the following, which restarts the robot:

    // If we're start()ing after a stop(), then shut the old robot down so
    // we can refresh it with new state (e.g., with new hw configurations)
    shutdownRobot();
    updateUIAndRequestRobotSetup();
    cfgFileMgr.getActiveConfigAndUpdateUI();

The comment indicates that this is intended to restart the robot if the user edited the hw config. However, by putting this in onStart(), the robot is restarted in many other cases. For instance, simply opening the About activity and returning to the main activity triggers a restart robot. Also, I frequently run with the screen of the RC off during testing to save battery, and whenever the screen is turned back on a restart robot is triggered.

If the intent really is to restart if the hw config has been changed, then this code should be moved to the if (request == RequestCode.CONFIGURE_ROBOT_CONTROLLER.ordinal() block inside onActivityResult(). However, this will still restart robot even if the config hasn't been changed. To fix this, the result code returned by the configure activity should have a value to indicate whether save was ever clicked during the course of user interactions.

@gearsincorg
Copy link

Also, I frequently run with the screen of the RC off during testing to save battery, and whenever the screen is turned back on a restart robot is triggered.

Funny, I had often wondered why this was the case.

For the longest time I assumed that if the screen was blanked, the opmodes would not run, but clearly this is not the case. It does seem that the robot restart is performed as a default cleanup under a lot of situations. Possibly a few too many.

@Windwoes
Copy link
Member Author

Windwoes commented Aug 1, 2019

For the longest time I assumed that if the screen was blanked, the opmodes would not run, but clearly this is not the case.

Yeah it goes against what might seem logical. The reason that the OpModes, networking, etc. continue to work even when the app is not in the foreground is because all of those core routines are run inside of a Service, rather than in the context of an Activity.

Craniumski pushed a commit to IronReign/SkyStone that referenced this issue Sep 9, 2019
New changes - including code refactor, teleop adjustments, auto-latch, and crater auto.
@TimVargo
Copy link

To fix this, the result code returned by the configure activity should have a value to indicate whether save was ever clicked during the course of user interactions.

This would be good, but an even better solution would be to evaluate if the CRC of the HW config file has changed during the course of user interactions. This way, no restart will occur even if the user enters edit mode, makes no changes, and clicks save.

jandrew pushed a commit to jandrew/SkyStone that referenced this issue Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants