Skip to content

Commit e22306b

Browse files
authored
Merge pull request #102 from auscompgeek/magicbot-test-mode
Miscellaneous changes related to magicbot test mode
2 parents 3c5547c + 0ae4f63 commit e22306b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

magicbot/magic_tunable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def feedback(f=None, *, key: str = None):
141141
* A component: ``/components/COMPONENTNAME/VARNAME``
142142
* Your main robot class: ``/robot/VARNAME``
143143
144-
The NetworkTables value will be auto-updated in all modes (except test mode).
144+
The NetworkTables value will be auto-updated in all modes.
145145
146146
.. warning:: The function should only act as a getter, and must not
147147
take any arguments (other than self).

magicbot/magicrobot.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ def robotPeriodic(self):
162162
This function gets called last in each mode.
163163
You may use it for any code you need to run
164164
during all modes of the robot (e.g NetworkTables updates)
165+
166+
The default implementation will update SmartDashboard and LiveWindow.
165167
"""
166-
pass
168+
wpilib.SmartDashboard.updateValues()
169+
wpilib.LiveWindow.updateValues()
167170

168171
def onException(self, forceReport=False):
169172
'''
@@ -256,6 +259,7 @@ def autonomous(self):
256259

257260
self.__nt.putString('mode', 'auto')
258261
self.__nt.putBoolean('is_ds_attached', self.ds.isDSAttached())
262+
wpilib.LiveWindow.setEnabled(False)
259263

260264
self._on_mode_enable_components()
261265

@@ -277,6 +281,7 @@ def disabled(self):
277281

278282
self.__nt.putString('mode', 'disabled')
279283
ds_attached = None
284+
wpilib.LiveWindow.setEnabled(False)
280285

281286
delay = PreciseDelay(self.control_loop_wait_time)
282287

@@ -314,6 +319,7 @@ def operatorControl(self):
314319
# don't need to update this during teleop -- presumably will switch
315320
# modes when ds is no longer attached
316321
self.__nt.putBoolean('is_ds_attached', self.ds.isDSAttached())
322+
wpilib.LiveWindow.setEnabled(False)
317323

318324
delay = PreciseDelay(self.control_loop_wait_time)
319325

@@ -345,10 +351,12 @@ def test(self):
345351

346352
self.__nt.putString('mode', 'test')
347353
self.__nt.putBoolean('is_ds_attached', self.ds.isDSAttached())
354+
wpilib.LiveWindow.setEnabled(True)
348355

349356
while self.isTest() and self.isEnabled():
350-
wpilib.LiveWindow.run()
351-
wpilib.Timer.delay(.01)
357+
self._update_feedback()
358+
self.robotPeriodic()
359+
wpilib.Timer.delay(self.control_loop_wait_time)
352360

353361
def _on_mode_enable_components(self):
354362
# initialize things

0 commit comments

Comments
 (0)