Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bhall-ctre committed May 29, 2024
1 parent 79b30ce commit 1cbe9f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion python/MotionMagic/tests/pyfrc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def assert_almost_equal(a: float, b: float, range_val: float):
# PID loop means we should be kinda fast, let's target 10ms
LOOP_PERIOD = 0.01
def wait_with_sim(time: float, fx: hardware.TalonFX, dcmotorsim: DCMotorSim):
feed_enable(0.2)
sleep(0.1)

start_time = 0
while start_time < time:
feed_enable(0.1)
Expand Down Expand Up @@ -65,7 +68,7 @@ def test_position_closed_loop():
target_control = controls.MotionMagicVoltage(position=1.0)
talonfx.set_control(target_control)

wait_with_sim(1, talonfx, motorsim)
wait_with_sim(2, talonfx, motorsim)

# Verify position is close to target
pos.wait_for_update(1)
Expand Down
5 changes: 4 additions & 1 deletion python/PositionClosedLoop/tests/pyfrc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def assert_almost_equal(a: float, b: float, range_val: float):
# PID loop means we should be kinda fast, let's target 10ms
LOOP_PERIOD = 0.01
def wait_with_sim(time: float, fx: hardware.TalonFX, dcmotorsim: DCMotorSim):
feed_enable(0.2)
sleep(0.1)

start_time = 0
while start_time < time:
feed_enable(0.1)
Expand Down Expand Up @@ -57,7 +60,7 @@ def test_position_closed_loop():
target_control = controls.PositionVoltage(position=1.0)
talonfx.set_control(target_control)

wait_with_sim(1, talonfx, motorsim)
wait_with_sim(2, talonfx, motorsim)

# Verify position is close to target
pos.wait_for_update(1)
Expand Down
5 changes: 4 additions & 1 deletion python/VelocityClosedLoop/tests/pyfrc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def assert_almost_equal(a: float, b: float, range_val: float):
# PID loop means we should be kinda fast, let's target 10ms
LOOP_PERIOD = 0.01
def wait_with_sim(time: float, fx: hardware.TalonFX, dcmotorsim: DCMotorSim):
feed_enable(0.2)
sleep(0.1)

start_time = 0
while start_time < time:
feed_enable(0.1)
Expand Down Expand Up @@ -55,7 +58,7 @@ def test_velocity_closed_loop():
target_control = controls.VelocityVoltage(velocity=10)
talonfx.set_control(target_control)

wait_with_sim(1, talonfx, motorsim)
wait_with_sim(2, talonfx, motorsim)

# Verify velocity is close to target
vel.wait_for_update(1)
Expand Down

0 comments on commit 1cbe9f1

Please sign in to comment.