Skip to content

add on enable and on disable to test #217

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

Merged
merged 2 commits into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions magicbot/magiccomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setup(self) -> None:

def on_enable(self) -> None:
"""
Called when the robot enters autonomous or teleoperated mode. This
Called when the robot enters autonomous, teleoperated or test mode mode. This
function should initialize your component to a "safe" state so
that unexpected things don't happen when enabling the robot.

Expand All @@ -60,7 +60,7 @@ def on_enable(self) -> None:

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

def execute(self) -> None:
Expand Down
7 changes: 3 additions & 4 deletions magicbot/magicrobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ def autonomous(self) -> None:
watchdog=self.watchdog,
)

self._on_mode_disable_components()

def _disabled(self) -> None:
"""
This function is called in disabled mode. You should not
Expand Down Expand Up @@ -513,8 +511,6 @@ def _operatorControl(self) -> None:
delay.wait()
watchdog.reset()

self._on_mode_disable_components()

def _test(self) -> None:
"""Called when the robot is in test mode"""
watchdog = self.watchdog
Expand All @@ -526,6 +522,9 @@ def _test(self) -> None:
wpilib.LiveWindow.setEnabled(True)
# Shuffleboard.enableActuatorWidgets()

# initialize things
self._on_mode_enable_components()

try:
self.testInit()
except:
Expand Down