Skip to content

Commit 2c535d4

Browse files
authored
Merge pull request #217 from LucienMorey/enable_disable_in_test
add on enable and on disable to test
2 parents bd2bf5e + 0e6cc38 commit 2c535d4

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

magicbot/magiccomponent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def setup(self) -> None:
4949

5050
def on_enable(self) -> None:
5151
"""
52-
Called when the robot enters autonomous or teleoperated mode. This
52+
Called when the robot enters autonomous, teleoperated or test mode mode. This
5353
function should initialize your component to a "safe" state so
5454
that unexpected things don't happen when enabling the robot.
5555
@@ -60,7 +60,7 @@ def on_enable(self) -> None:
6060

6161
def on_disable(self) -> None:
6262
"""
63-
Called when the robot leaves autonomous or teleoperated
63+
Called when the robot enters disabled mode.
6464
"""
6565

6666
def execute(self) -> None:

magicbot/magicrobot.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,6 @@ def autonomous(self) -> None:
413413
watchdog=self.watchdog,
414414
)
415415

416-
self._on_mode_disable_components()
417-
418416
def _disabled(self) -> None:
419417
"""
420418
This function is called in disabled mode. You should not
@@ -513,8 +511,6 @@ def _operatorControl(self) -> None:
513511
delay.wait()
514512
watchdog.reset()
515513

516-
self._on_mode_disable_components()
517-
518514
def _test(self) -> None:
519515
"""Called when the robot is in test mode"""
520516
watchdog = self.watchdog
@@ -526,6 +522,9 @@ def _test(self) -> None:
526522
wpilib.LiveWindow.setEnabled(True)
527523
# Shuffleboard.enableActuatorWidgets()
528524

525+
# initialize things
526+
self._on_mode_enable_components()
527+
529528
try:
530529
self.testInit()
531530
except:

0 commit comments

Comments
 (0)