Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

magicbot mode exit methods #205

Open
auscompgeek opened this issue Apr 3, 2023 · 2 comments
Open

magicbot mode exit methods #205

auscompgeek opened this issue Apr 3, 2023 · 2 comments
Labels
enhancement magicbot magicbot package

Comments

@auscompgeek
Copy link
Member

auscompgeek commented Apr 3, 2023

For the 2022 season methods were added to TimedRobot to run code on mode exit, i.e. disabledExit, autonomousExit, teleopExit, and testExit. magicbot should have the same, although we should make sure the ordering makes sense with all the interactions with components.

I suspect we want the following, with the philosophy that more specific methods are called later:

  • autonomous
    • component on_enable
    • autonomousInit
    • auto routine on_enable
    • (execute auto routine / periodics)
    • component on_disable
    • autonomousExit
    • auto routine on_disable
  • teleop
    • component on_enable
    • teleopInit
    • (teleopPeriodic / component execute / robotPeriodic)
    • component on_disable
    • teleopExit

Obviously disabledExit and testExit would be called at the very end of disabled and test modes, and there's no ordering concerns as no other code really runs in those modes.

robotPeriodic will continue to run after all other periodic code as its intent is for user telemetry code.

@auscompgeek auscompgeek added enhancement magicbot magicbot package labels Apr 3, 2023
@auscompgeek
Copy link
Member Author

@virtuald do you agree with the ordering for auto here? I think we currently call the auto routine's on_disable before component on_disable, so this'd be a breaking change.

@auscompgeek auscompgeek moved this to Todo in 2024 Season Nov 5, 2023
@virtuald virtuald removed this from 2024 Season Nov 3, 2024
@auscompgeek auscompgeek moved this to Backlog in 2025 Season Nov 30, 2024
@auscompgeek
Copy link
Member Author

I guess that ordering of on_disable may be a bit confusing to document. Right now one can simply think of it like a method that automatically gets called when disabledInit is (i.e. when entering disabled mode).

It'd also be less straightforward to implement it as proposed in the OP. Although it wouldn't be much more complicated, since we actually call on_disable both at the end of autonomous/teleop and at the beginning of disabled - I'm guessing the double call isn't quite intended.

On the other hand, the current behaviour doesn't quite match the documentation. Since we call on_disable when entering disabled mode, it also means it's called when exiting test mode.

def on_disable(self) -> None:
"""
Called when the robot leaves autonomous or teleoperated
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement magicbot magicbot package
Projects
Status: Backlog
Development

No branches or pull requests

1 participant