Skip to content

Commit

Permalink
Some work on the basic test again, but it's still not there
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Jan 5, 2015
1 parent ce083d6 commit d7f8109
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
25 changes: 9 additions & 16 deletions samples/sample/tests/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,17 @@ def test_autonomous(control, fake_time, robot):

# run autonomous mode for 10 seconds
control.set_autonomous(enabled=True)
control.on_step = lambda tm: tm < 10
control.run_test(lambda tm: tm < 15)

robot.robotInit()
robot.autonomous()

# make sure autonomous mode ran for 10 seconds
assert int(fake_time.get()) == 10
# make sure autonomous mode ran for 15 seconds
assert int(fake_time.get()) == 15


def test_disabled(control, fake_time, robot):

# run disabled mode for 5 seconds
control.set_autonomous(enabled=False)
control.on_step = lambda tm: tm < 5

robot.robotInit()
robot.disabled()
control.run_test(lambda tm: tm < 5)

# make sure disabled mode ran for 5 seconds
assert int(fake_time.get()) == 5
Expand All @@ -66,13 +60,17 @@ def on_step(self, tm):
use assert to check a motor value, you have to check to see that
it matches the previous value that you set on the inputs, not the
current value.
:param tm: The current robot time in seconds
'''
self.loop_count += 1
#print(self.loop_count)
#print("STEP", tm)
#print("MOO", hal_data['joysticks'][1]['axes'][1])

# motor value is equal to the previous value of the stick
# -> Note that the PWM value isn't exact, because it was converted to
# a raw PWM value and then back to -1 to 1
assert abs(hal_data['pwm'][8]['value'] - self.stick_prev) < 0.1

# set the stick value based on time
Expand All @@ -82,10 +80,5 @@ def on_step(self, tm):
return not self.loop_count == 1000

control.set_operator_control(enabled=True)
control.on_step = TestController

robot.robotInit()
robot.operatorControl()

# do something like assert the motor == stick value
control.run_test(TestController)

2 changes: 1 addition & 1 deletion samples/sample/tests/pyfrc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
to test basic functionality of just about any robot.
'''

from pyfrc.tests.sample_robot import *
from pyfrc.tests import *

0 comments on commit d7f8109

Please sign in to comment.