diff options
author | Raspberry Pi <pi@umn.edu> | 2019-10-15 17:10:04 -0500 |
---|---|---|
committer | Raspberry Pi <pi@umn.edu> | 2019-10-15 17:10:04 -0500 |
commit | 066662d02c3185331af137a14cb1caab3b3af356 (patch) | |
tree | a428e1c6e110a915dc772b23a83d05d34ff5e87f /System_Python/test_System.py | |
parent | Add a linear encoder class for abstracting the angular-to-linear encoding, wh... (diff) | |
download | ee4511w-066662d02c3185331af137a14cb1caab3b3af356.tar ee4511w-066662d02c3185331af137a14cb1caab3b3af356.tar.gz ee4511w-066662d02c3185331af137a14cb1caab3b3af356.tar.bz2 ee4511w-066662d02c3185331af137a14cb1caab3b3af356.tar.lz ee4511w-066662d02c3185331af137a14cb1caab3b3af356.tar.xz ee4511w-066662d02c3185331af137a14cb1caab3b3af356.tar.zst ee4511w-066662d02c3185331af137a14cb1caab3b3af356.zip |
Updated encoder for proper zero setting and offset behavior. Tested system library and successfully got the encoder position controlling the motor speed.
Diffstat (limited to '')
-rw-r--r-- | System_Python/test_System.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/System_Python/test_System.py b/System_Python/test_System.py index af218e0..32ff56d 100644 --- a/System_Python/test_System.py +++ b/System_Python/test_System.py @@ -1,17 +1,21 @@ # This test file implements a super simple control-type function for testing the System library.
# DO NOT TEST ON ASSEMBLED PHYSICAL SYSTEM! It will probably break it.
+import time
from system import System
# Return a speed based on current encoder angle.
# Convert an angle to speed (180 degrees = max speed)
def control_function(angle):
- return (angle / 180.0) * 100.0
-
+ return (abs(angle) / 180.0) * 100.0
+
# Main program
sys = System()
while 1:
- angle, linear = sys.measure()
- speed = control_function(angle)
- sys.adjust(speed)
-
\ No newline at end of file + angle, linear = sys.measure()
+ #print(angle)
+ speed = control_function(angle)
+ print(speed)
+ sys.adjust(speed)
+ time.sleep(0.05)
+
\ No newline at end of file |