Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/maxswerve/swerveutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def stepTowardsCircular(current: float, target: float, stepsize: float) -> float
current = wrapAngle(current)
target = wrapAngle(target)

stepDirection = math.copysign(target - current, 1)
stepDirection = math.copysign(1, target - current)
difference = abs(current - target)

if difference <= stepsize:
Expand Down
18 changes: 18 additions & 0 deletions examples/maxswerve/tests/test_swerveutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) FIRST and other WPILib contributors.
# Open Source Software; you can modify and/or share it under the terms of
# the WPILib BSD license file in the root directory of this project.
#

import swerveutils


def test_stepTowardsCircular1():
current = 0.6408134451373411
stepsize = 0.3455804605358387
target = 0.0 # stepping towards zero direction
result = swerveutils.stepTowardsCircular(
current=current, stepsize=stepsize, target=target
)
# stepping towards zero angle should result in smaller absolute value
assert abs(result) < abs(current)